Skip to content

Commit

Permalink
aws-sdk-java: Disable testing encrypting when HTTPS is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
vadmeste committed Apr 18, 2018
1 parent 4dca798 commit 3f0cffa
Showing 1 changed file with 75 additions and 33 deletions.
108 changes: 75 additions & 33 deletions build/aws-sdk-java/src/FunctionalTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class FunctionalTests {
private static String secretKey;
private static String region;
private static String endpoint;
private static String enableHTTPS;
private static boolean enableHTTPS;

private static final Random random = new Random(new SecureRandom().nextLong());
private static String bucketName = getRandomName();
Expand Down Expand Up @@ -149,12 +149,16 @@ public static void teardown() throws IOException {
s3Client.deleteBucket(bucketName);
}

// Test regular upload object
public static void uploadObject_test1() throws Exception {
// Test regular object upload using encryption
public static void uploadObjectEncryption_test1() throws Exception {
if (!mintEnv) {
System.out.println("Test: uploadObject(String bucketName, String objectName, String f, SSECustomerKey sseKey)");
}

if (!enableHTTPS) {
return;
}

long startTime = System.currentTimeMillis();
String file1MbMD5 = Utils.getFileMD5(file1Mb);
String objectName = "testobject";
Expand All @@ -174,12 +178,17 @@ public static void uploadObject_test1() throws Exception {
}
}

// Test downloading an object with a wrong key
public static void downloadObject_test1() throws Exception {
// Test downloading an object with a wrong encryption key
public static void downloadObjectEncryption_test1() throws Exception {
if (!mintEnv) {
System.out.println("Test: downloadObject(String bucketName, String objectName, SSECustomerKey sseKey)");
}

if (!enableHTTPS) {
return;
}


long startTime = System.currentTimeMillis();

String file1MbMD5 = Utils.getFileMD5(file1Mb);
Expand Down Expand Up @@ -207,13 +216,17 @@ public static void downloadObject_test1() throws Exception {
}
}

// Test copying object with a new different key
public static void copyObject_test1() throws Exception {
// Test copying object with a new different encryption key
public static void copyObjectEncryption_test1() throws Exception {
if (!mintEnv) {
System.out.println("Test: copyObject(String bucketName, String objectName, SSECustomerKey sseKey, " +
"String destBucketName, String dstObjectName, SSECustomerKey sseKey2, boolean replaceDirective)");
}

if (!enableHTTPS) {
return;
}

long startTime = System.currentTimeMillis();
String file1MbMD5 = Utils.getFileMD5(file1Mb);
String objectName = "testobject";
Expand All @@ -238,13 +251,17 @@ public static void copyObject_test1() throws Exception {
startTime);
}

// Test copying object with wrong source key
public static void copyObject_test2() throws Exception {
// Test copying object with wrong source encryption key
public static void copyObjectEncryption_test2() throws Exception {
if (!mintEnv) {
System.out.println("Test: copyObject(String bucketName, String objectName, SSECustomerKey sseKey, " +
"String destBucketName, String dstObjectName, SSECustomerKey sseKey2, boolean replaceDirective)");
}

if (!enableHTTPS) {
return;
}

String objectName = "testobject";
String dstObjectName = "dir/newobject";

Expand Down Expand Up @@ -277,13 +294,17 @@ public static void copyObject_test2() throws Exception {
}
}

// Test download object with Get Range, 0 -> 1024*1024
public static void downloadGetRange_test1() throws Exception {
// Test downloading encrypted object with Get Range, 0 -> 1024*1024
public static void downloadGetRangeEncryption_test1() throws Exception {
if (!mintEnv) {
System.out.println("Test: downloadObjectGetRange(String bucketName, String objectName, " +
"SSECustomerKey sseKey, String expectedMD5, int start, int length)");
}

if (!enableHTTPS) {
return;
}

long startTime = System.currentTimeMillis();

String objectName = "testobject";
Expand All @@ -307,13 +328,17 @@ public static void downloadGetRange_test1() throws Exception {
startTime);
}

// Test download object with Get Range, 0 -> 1
public static void downloadGetRange_test2() throws Exception {
// Test downloading encrypted object with Get Range, 0 -> 1
public static void downloadGetRangeEncryption_test2() throws Exception {
if (!mintEnv) {
System.out.println("Test: downloadObjectGetRange(String bucketName, String objectName, " +
"SSECustomerKey sseKey, String expectedMD5, int start, int length)");
}

if (!enableHTTPS) {
return;
}

long startTime = System.currentTimeMillis();

String objectName = "testobject";
Expand All @@ -338,13 +363,17 @@ public static void downloadGetRange_test2() throws Exception {
}


// Test download object with Get Range, 0 -> 1024*1024-1
public static void downloadGetRange_test3() throws Exception {
// Test downloading encrypted object with Get Range, 0 -> 1024*1024-1
public static void downloadGetRangeEncryption_test3() throws Exception {
if (!mintEnv) {
System.out.println("Test: downloadObjectGetRange(String bucketName, String objectName, " +
"SSECustomerKey sseKey, String expectedMD5, int start, int length)");
}

if (!enableHTTPS) {
return;
}

long startTime = System.currentTimeMillis();

String objectName = "testobject";
Expand All @@ -368,13 +397,17 @@ public static void downloadGetRange_test3() throws Exception {
startTime);
}

// Test download object with Get Range, 1 -> 1024*1024-1
public static void downloadGetRange_test4() throws Exception {
// Test downloading encrypted object with Get Range, 1 -> 1024*1024-1
public static void downloadGetRangeEncryption_test4() throws Exception {
if (!mintEnv) {
System.out.println("Test: downloadObjectGetRange(String bucketName, String objectName, " +
"SSECustomerKey sseKey, String expectedMD5, int start, int length)");
}

if (!enableHTTPS) {
return;
}

long startTime = System.currentTimeMillis();

String objectName = "testobject";
Expand All @@ -398,13 +431,17 @@ public static void downloadGetRange_test4() throws Exception {
startTime);
}

// Test download object with Get Range, 64*1024 -> 64*1024
public static void downloadGetRange_test5() throws Exception {
// Test downloading encrypted object with Get Range, 64*1024 -> 64*1024
public static void downloadGetRangeEncryption_test5() throws Exception {
if (!mintEnv) {
System.out.println("Test: downloadObjectGetRange(String bucketName, String objectName, " +
"SSECustomerKey sseKey, String expectedMD5, int start, int length)");
}

if (!enableHTTPS) {
return;
}

long startTime = System.currentTimeMillis();

String objectName = "testobject";
Expand All @@ -428,13 +465,17 @@ public static void downloadGetRange_test5() throws Exception {
startTime);
}

// Test download object with Get Range, 64*1024 -> 1024*1024-64*1024
public static void downloadGetRange_test6() throws Exception {
// Test downloading encrypted object with Get Range, 64*1024 -> 1024*1024-64*1024
public static void downloadGetRangeEncryption_test6() throws Exception {
if (!mintEnv) {
System.out.println("Test: downloadObjectGetRange(String bucketName, String objectName, " +
"SSECustomerKey sseKey, String expectedMD5, int start, int length)");
}

if (!enableHTTPS) {
return;
}

long startTime = System.currentTimeMillis();

String objectName = "testobject";
Expand Down Expand Up @@ -465,19 +506,19 @@ public static void runTests() {
// Quick tests
public static void runQuickTests() throws Exception {

uploadObject_test1();
uploadObjectEncryption_test1();

downloadObject_test1();
downloadObjectEncryption_test1();

copyObject_test1();
copyObject_test2();
copyObjectEncryption_test1();
copyObjectEncryption_test2();

downloadGetRange_test1();
downloadGetRange_test2();
downloadGetRange_test3();
downloadGetRange_test4();
downloadGetRange_test5();
downloadGetRange_test6();
downloadGetRangeEncryption_test1();
downloadGetRangeEncryption_test2();
downloadGetRangeEncryption_test3();
downloadGetRangeEncryption_test4();
downloadGetRangeEncryption_test5();
downloadGetRangeEncryption_test6();
}

public static void main(String[] args) throws Exception,
Expand All @@ -486,10 +527,11 @@ public static void main(String[] args) throws Exception,
endpoint = System.getenv("SERVER_ENDPOINT");
accessKey = System.getenv("ACCESS_KEY");
secretKey = System.getenv("SECRET_KEY");
enableHTTPS = System.getenv("ENABLE_HTTPS");
enableHTTPS = System.getenv("ENABLE_HTTPS").equals("1");

region = "us-east-1";

if (enableHTTPS.contains("1")) {
if (enableHTTPS) {
endpoint = "https://" + endpoint;
} else {
endpoint = "http://" + endpoint;
Expand Down

0 comments on commit 3f0cffa

Please sign in to comment.