Skip to content
Permalink
Browse files
Fix #3728 AWS S3 integration test should remove all objects in finall…
…y block (#3729)
  • Loading branch information
zhfeng committed Apr 15, 2022
1 parent 9a282a5 commit ec671ceb29c7479745f26c31ae6c73c970d16f81
Showing 1 changed file with 63 additions and 54 deletions.
@@ -164,47 +164,51 @@ public void testKms() throws Exception {
final String oid = UUID.randomUUID().toString();
final String blobContent = "Hello KMS " + oid;

// Create
RestAssured.given()
.contentType(ContentType.TEXT)
.body(blobContent)
.post("/aws2/s3/object/" + oid + "?useKms=true")
.then()
.statusCode(201);

// Read
RestAssured.get("/aws2/s3/object/" + oid + "?useKms=true")
.then()
.statusCode(200)
.body(is(blobContent));
try {
// Create
RestAssured.given()
.contentType(ContentType.TEXT)
.body(blobContent)
.post("/aws2/s3/object/" + oid + "?useKms=true")
.then()
.statusCode(201);

// Delete
deleteObject(oid);
// Read
RestAssured.get("/aws2/s3/object/" + oid + "?useKms=true")
.then()
.statusCode(200)
.body(is(blobContent));
} finally {
// Delete
deleteObject(oid);
}
}

@Test
public void upload() throws Exception {
final String oid = UUID.randomUUID().toString();
final String content = RandomStringUtils.randomAlphabetic(8 * 1024 * 1024);

RestAssured.given()
.contentType(ContentType.TEXT)
.body(content)
.post("/aws2/s3/upload/" + oid)
.then()
.statusCode(200);

String result = RestAssured.get("/aws2/s3/object/" + oid)
.then()
.statusCode(200)
.extract().asString();
try {
RestAssured.given()
.contentType(ContentType.TEXT)
.body(content)
.post("/aws2/s3/upload/" + oid)
.then()
.statusCode(200);

// Delete
deleteObject(oid);
String result = RestAssured.get("/aws2/s3/object/" + oid)
.then()
.statusCode(200)
.extract().asString();

// strip the chuck-signature
result = result.replaceAll("\\s*[0-9]+;chunk-signature=\\w{64}\\s*", "");
assertEquals(content, result);
// strip the chuck-signature
result = result.replaceAll("\\s*[0-9]+;chunk-signature=\\w{64}\\s*", "");
assertEquals(content, result);
} finally {
// Delete
deleteObject(oid);
}
}

@Test
@@ -284,39 +288,44 @@ public void downloadLink() throws Exception {
final String oid = UUID.randomUUID().toString();
final String blobContent = "Hello " + oid;

// Create
createObject(oid, blobContent);
try {
// Create
createObject(oid, blobContent);

// Download link
RestAssured.given()
.contentType(ContentType.TEXT)
.get("/aws2/s3/downloadlink/" + oid)
.then()
.statusCode(200);
// Download link
RestAssured.given()
.contentType(ContentType.TEXT)
.get("/aws2/s3/downloadlink/" + oid)
.then()
.statusCode(200);

// Delete
deleteObject(oid);
} finally {
// Delete
deleteObject(oid);
}
}

@Test
public void objectRange() {
final String oid = UUID.randomUUID().toString();
final String blobContent = "Hello " + oid;

// Create
createObject(oid, blobContent);

// Object range
RestAssured.given()
.contentType(ContentType.TEXT)
.param("start", "0").param("end", "4")
.get("/aws2/s3/object/range/" + oid)
.then()
.statusCode(200)
.body(is("Hello"));
try {
// Create
createObject(oid, blobContent);

// Delete
deleteObject(oid);
// Object range
RestAssured.given()
.contentType(ContentType.TEXT)
.param("start", "0").param("end", "4")
.get("/aws2/s3/object/range/" + oid)
.then()
.statusCode(200)
.body(is("Hello"));
} finally {
// Delete
deleteObject(oid);
}
}

private void createObject(String oid, String blobContent) {

0 comments on commit ec671ce

Please sign in to comment.