Skip to content
Permalink
Browse files
Ensure the S3 download link really works (#3734)
  • Loading branch information
ppalaga committed Apr 20, 2022
1 parent 0945027 commit 8eb364a27e758136e1a62e4fd165eb4126f1019a
Showing 2 changed files with 26 additions and 4 deletions.
@@ -235,7 +235,7 @@ public String downloadLink(@PathParam("key") String key, @QueryParam("bucket") S
}

String link = producerTemplate.requestBodyAndHeader(
componentUri(bucket, AWS2S3Operations.createDownloadLink) + "&accessKey=xxx&secretKey=yyy&region=eu-west-1",
componentUri(bucket, AWS2S3Operations.createDownloadLink),
null,
AWS2S3Constants.KEY,
key,
@@ -16,6 +16,7 @@
*/
package org.apache.camel.quarkus.component.aws2.s3.it;

import java.net.URI;
import java.util.Locale;
import java.util.UUID;
import java.util.stream.Stream;
@@ -292,12 +293,33 @@ public void downloadLink() throws Exception {
// Create
createObject(oid, blobContent);

// Download link
RestAssured.given()
// Get the download link
final String downloadLink = RestAssured.given()
.contentType(ContentType.TEXT)
.get("/aws2/s3/downloadlink/" + oid)
.then()
.statusCode(200);
.statusCode(200)
.extract().body().asString();

final URI downloadUri = new URI(downloadLink);

// Make sure that the download link works
// Note that localstack produces a real AWS link so when testing against localstack,
// the link won't work
final String realKey = System.getenv("AWS_ACCESS_KEY");
final String realSecret = System.getenv("AWS_SECRET_KEY");
final String realRegion = System.getenv("AWS_REGION");
final boolean realCredentialsProvided = realKey != null && realSecret != null && realRegion != null;
if (realCredentialsProvided) {
RestAssured.given()
.log().all()
.contentType(ContentType.TEXT)
.port(downloadUri.getPort())
.get(downloadLink)
.then()
.statusCode(200)
.body(is(blobContent));
}

} finally {
// Delete

0 comments on commit 8eb364a

Please sign in to comment.