This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 0a67ccdf86 Aws2: Add testing of defaultCredentialProvider to each
extension #4442
0a67ccdf86 is described below
commit 0a67ccdf86b50c4b0c8649546919f4e4c8480ddd
Author: JiriOndrusek <[email protected]>
AuthorDate: Thu Feb 2 13:19:36 2023 +0100
Aws2: Add testing of defaultCredentialProvider to each extension #4442
---
.../aws2-quarkus-client/aws2-ddb/pom.xml | 5 +
.../aws2-quarkus-client/aws2-s3/pom.xml | 5 +
.../aws2-quarkus-client/aws2-ses/pom.xml | 5 +
.../aws2-quarkus-client/aws2-sqs-sns/pom.xml | 5 +
.../aws2-quarkus-client/aws2-sqs/pom.xml | 5 +
integration-test-groups/aws2/aws2-cw/pom.xml | 5 +
.../component/aws2/cw/it/Aws2CwResource.java | 28 ++----
.../quarkus/component/aws2/cw/it/Aws2CwTest.java | 71 ++++++--------
integration-test-groups/aws2/aws2-ddb/pom.xml | 5 +
.../component/aws2/ddb/it/Aws2DdbResource.java | 9 +-
.../quarkus/component/aws2/ddb/it/Aws2DdbTest.java | 16 ++-
integration-test-groups/aws2/aws2-kinesis/pom.xml | 5 +
.../kinesis/it/Aws2KinesisFirehoseResource.java | 9 +-
.../aws2/kinesis/it/Aws2KinesisResource.java | 9 +-
.../aws2/kinesis/it/Aws2KinesisFirehoseIT.java | 12 +--
...nesisTest.java => Aws2KinesisFirehoseTest.java} | 35 +++----
.../component/aws2/kinesis/it/Aws2KinesisTest.java | 78 ++-------------
integration-test-groups/aws2/aws2-lambda/pom.xml | 9 +-
.../aws2/lambda/it/Aws2LambdaResource.java | 12 ++-
.../component/aws2/lambda/it/Aws2LambdaTest.java | 15 ++-
integration-test-groups/aws2/aws2-s3/pom.xml | 5 +
.../component/aws2/s3/it/Aws2S3Resource.java | 46 +++++----
.../quarkus/component/aws2/s3/it/Aws2S3Test.java | 67 +++++++------
integration-test-groups/aws2/aws2-ses/pom.xml | 5 +
.../component/aws2/ses/it/Aws2SesResource.java | 9 +-
.../quarkus/component/aws2/ses/it/Aws2SesTest.java | 23 ++++-
integration-test-groups/aws2/aws2-sqs-sns/pom.xml | 5 +
.../component/aws2/sns/it/Aws2SqsSnsResource.java | 26 +++--
.../component/aws2/sns/it/Aws2SqsSnsTest.java | 11 ++-
integration-test-groups/aws2/aws2-sqs/pom.xml | 5 +
.../component/aws2/sqs/it/Aws2SqsResource.java | 23 +++--
.../quarkus/component/aws2/sqs/it/Aws2SqsTest.java | 11 ++-
integration-tests-jvm/aws-secrets-manager/pom.xml | 5 +
integration-tests-support/aws2/pom.xml | 59 ++++++++---
...rAvailabilityCondition.java => Aws2Helper.java} | 29 +++---
.../test/support/aws2/BaseAws2Resource.java | 95 ++++++++++++++++++
.../quarkus/test/support/aws2/Aws2Client.java | 0
...ltCredentialsProviderAvailabilityCondition.java | 30 +++---
.../quarkus/test/support/aws2/Aws2LocalStack.java | 0
.../test/support/aws2/Aws2TestEnvContext.java | 0
.../test/support/aws2/Aws2TestEnvCustomizer.java | 0
.../test/support/aws2/Aws2TestResource.java | 1 -
.../test/support/aws2/BaseAWs2TestSupport.java | 108 +++++++++++++++++++++
integration-tests/aws2-grouped/pom.xml | 5 +
.../aws2-quarkus-client-grouped/pom.xml | 5 +
poms/bom-test/pom.xml | 32 ++++++
46 files changed, 661 insertions(+), 287 deletions(-)
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
b/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
index 896d35efe2..b09ffd2f50 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
@@ -62,6 +62,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-s3/pom.xml
b/integration-test-groups/aws2-quarkus-client/aws2-s3/pom.xml
index 5ed6074336..f7d00ef6e6 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-s3/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-s3/pom.xml
@@ -66,6 +66,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-ses/pom.xml
b/integration-test-groups/aws2-quarkus-client/aws2-ses/pom.xml
index a2cca44c0a..65d9f38039 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-ses/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-ses/pom.xml
@@ -62,6 +62,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-sqs-sns/pom.xml
b/integration-test-groups/aws2-quarkus-client/aws2-sqs-sns/pom.xml
index a41a008e51..f702a22661 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-sqs-sns/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-sqs-sns/pom.xml
@@ -70,6 +70,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-sqs/pom.xml
b/integration-test-groups/aws2-quarkus-client/aws2-sqs/pom.xml
index a994aba34d..2980f3b83d 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-sqs/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-sqs/pom.xml
@@ -62,6 +62,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/integration-test-groups/aws2/aws2-cw/pom.xml
b/integration-test-groups/aws2/aws2-cw/pom.xml
index ad54c28ed2..e993182ba4 100644
--- a/integration-test-groups/aws2/aws2-cw/pom.xml
+++ b/integration-test-groups/aws2/aws2-cw/pom.xml
@@ -58,6 +58,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwResource.java
b/integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwResource.java
index 72786fd320..5b1630ddf1 100644
---
a/integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwResource.java
+++
b/integration-test-groups/aws2/aws2-cw/src/main/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwResource.java
@@ -36,17 +36,21 @@ import jakarta.ws.rs.core.Response;
import org.apache.camel.CamelExecutionException;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.cw.Cw2Constants;
-import org.eclipse.microprofile.config.ConfigProvider;
+import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
@Path("/aws2-cw")
@ApplicationScoped
-public class Aws2CwResource {
+public class Aws2CwResource extends BaseAws2Resource {
@Inject
ProducerTemplate producerTemplate;
private volatile String endpointUri;
+ public Aws2CwResource() {
+ super("cw");
+ }
+
@Scheduled(every = "1s")
void schedule() {
if (endpointUri != null) {
@@ -75,17 +79,14 @@ public class Aws2CwResource {
@Produces(MediaType.TEXT_PLAIN)
public Response postMap(
@PathParam("namespace") String namespace,
- @HeaderParam("defaultCredentialsProvider") boolean
defaultCredentialsProvider,
- @HeaderParam("setCredentials") boolean setCredentials,
@HeaderParam("returnExceptionMessage") boolean
returnExceptionMessage,
@HeaderParam("customClientName") String customClientName,
MultivaluedMap<String, String> formParams) throws Exception {
- String uri = "aws2-cw://" + namespace;
+ String uri = "aws2-cw://" + namespace +
"?useDefaultCredentialsProvider="
+ + isUseDefaultCredentials();
if (customClientName != null && !customClientName.isEmpty()) {
- uri = uri + "?autowiredEnabled=false&amazonCwClient=#" +
customClientName;
- } else if (defaultCredentialsProvider) {
- uri = uri + "?useDefaultCredentialsProvider=true";
+ uri = uri + "&autowiredEnabled=false&amazonCwClient=#" +
customClientName;
}
Map<String, Object> typedHeaders =
formParams.entrySet().stream().collect(Collectors.toMap(
@@ -103,12 +104,6 @@ public class Aws2CwResource {
return val;
}));
try {
- if (defaultCredentialsProvider && setCredentials) {
- System.setProperty("aws.accessKeyId",
-
ConfigProvider.getConfig().getValue("camel.component.aws2-cw.access-key",
String.class));
- System.setProperty("aws.secretAccessKey",
-
ConfigProvider.getConfig().getValue("camel.component.aws2-cw.secret-key",
String.class));
- }
producerTemplate.requestBodyAndHeaders(uri, null, typedHeaders,
String.class);
} catch (Exception e) {
if (returnExceptionMessage && e instanceof CamelExecutionException
&& e.getCause() != null) {
@@ -117,11 +112,6 @@ public class Aws2CwResource {
.build();
}
throw e;
- } finally {
- if (defaultCredentialsProvider && setCredentials) {
- System.clearProperty("aws.accessKeyId");
- System.clearProperty("aws.secretAccessKey");
- }
}
return Response
diff --git
a/integration-test-groups/aws2/aws2-cw/src/test/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwTest.java
b/integration-test-groups/aws2/aws2-cw/src/test/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwTest.java
index 7d85c6c8a5..f1eba98918 100644
---
a/integration-test-groups/aws2/aws2-cw/src/test/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwTest.java
+++
b/integration-test-groups/aws2/aws2-cw/src/test/java/org/apache/camel/quarkus/component/aws2/cw/it/Aws2CwTest.java
@@ -26,16 +26,14 @@ import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
-import io.restassured.response.ValidatableResponse;
import org.apache.camel.component.aws2.cw.Cw2Constants;
import org.apache.camel.quarkus.test.support.aws2.Aws2Client;
-import
org.apache.camel.quarkus.test.support.aws2.Aws2DefaultCredentialsProviderAvailabilityCondition;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
+import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
import org.apache.camel.util.CollectionHelper;
import org.awaitility.Awaitility;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
import org.testcontainers.containers.localstack.LocalStackContainer.Service;
import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
import software.amazon.awssdk.services.cloudwatch.model.Datapoint;
@@ -44,16 +42,40 @@ import
software.amazon.awssdk.services.cloudwatch.model.GetMetricStatisticsReque
import software.amazon.awssdk.services.cloudwatch.model.Statistic;
import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.startsWith;
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
-class Aws2CwTest {
+class Aws2CwTest extends BaseAWs2TestSupport {
private static final Logger LOG = Logger.getLogger(Aws2CwTest.class);
@Aws2Client(Service.CLOUDWATCH)
CloudWatchClient client;
+ public Aws2CwTest() {
+ super("/aws2-cw");
+ }
+
+ @Override
+ public void testMethodForDefaultCredentialsProvider() {
+ final String namespace = "cq-metrics-" +
java.util.UUID.randomUUID().toString().replace("-", "");
+ final String metricName = "metricName" +
java.util.UUID.randomUUID().toString().replace("-", "");
+
+ Map<String, String> item = CollectionHelper.mapOf(
+ Cw2Constants.METRIC_NAMESPACE, namespace,
+ Cw2Constants.METRIC_NAME, metricName,
+ Cw2Constants.METRIC_VALUE, 0,
+ Cw2Constants.METRIC_UNIT, "Count",
+ Cw2Constants.METRIC_DIMENSION_NAME, "type",
+ Cw2Constants.METRIC_DIMENSION_VALUE, "even");
+
+ RestAssured.given()
+ .contentType("application/x-www-form-urlencoded;
charset=utf-8")
+ .formParams(item)
+ .post("/aws2-cw/send-metric-map/" + namespace)
+ .then()
+ .statusCode(201);
+ }
+
@Test
public void metric() {
@@ -245,43 +267,4 @@ class Aws2CwTest {
.body(is("CloudWatchClientMock"));
}
- //test can be executed only if mock backend is used and no
defaultCredentialsprovider is defined in the system
- @ExtendWith(Aws2DefaultCredentialsProviderAvailabilityCondition.class)
- @Test
- public void defaultCredentialsProviderOnLocalstackTest() {
- testDefaultCredentialsProvider(false, true).statusCode(200)
-
.body(startsWith(Aws2DefaultCredentialsProviderAvailabilityCondition.UNABLE_TO_LOAD_CREDENTIALS_MSG));
- ;
-
- testDefaultCredentialsProvider(true, false).statusCode(201);
- }
-
- //called twice from the defaultCredentialsProviderOnLocalstackTest
- private ValidatableResponse testDefaultCredentialsProvider(boolean
setCredenbtials, boolean returnErrorMessage) {
- final Instant startTime =
Instant.ofEpochMilli(System.currentTimeMillis() - 10000);
-
- final String namespace = "cq-metrics-" +
java.util.UUID.randomUUID().toString().replace("-", "");
- final String metricName = "metricName" +
java.util.UUID.randomUUID().toString().replace("-", "");
-
- List<Map<String, String>> data = new LinkedList<>();
-
- Map<String, String> item = CollectionHelper.mapOf(
- Cw2Constants.METRIC_NAMESPACE, namespace,
- Cw2Constants.METRIC_NAME, metricName,
- Cw2Constants.METRIC_VALUE, 0,
- Cw2Constants.METRIC_UNIT, "Count",
- Cw2Constants.METRIC_DIMENSION_NAME, "type",
- Cw2Constants.METRIC_DIMENSION_VALUE, "even");
-
- return RestAssured.given()
- .contentType("application/x-www-form-urlencoded;
charset=utf-8")
- .formParams(item)
- .header("defaultCredentialsProvider", true)
- .header("returnExceptionMessage", returnErrorMessage)
- .header("setCredentials", setCredenbtials)
- .post("/aws2-cw/send-metric-map/" + namespace)
- .then();
-
- }
-
}
diff --git a/integration-test-groups/aws2/aws2-ddb/pom.xml
b/integration-test-groups/aws2/aws2-ddb/pom.xml
index ccc92978ad..71b39d8605 100644
--- a/integration-test-groups/aws2/aws2-ddb/pom.xml
+++ b/integration-test-groups/aws2/aws2-ddb/pom.xml
@@ -58,6 +58,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/integration-test-groups/aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java
b/integration-test-groups/aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java
index f53f799f8d..5edff427ef 100644
---
a/integration-test-groups/aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java
+++
b/integration-test-groups/aws2/aws2-ddb/src/main/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbResource.java
@@ -43,6 +43,7 @@ import org.apache.camel.Message;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.ddb.Ddb2Constants;
import org.apache.camel.component.aws2.ddb.Ddb2Operations;
+import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
import org.apache.camel.util.CollectionHelper;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import software.amazon.awssdk.services.dynamodb.model.AttributeAction;
@@ -55,7 +56,11 @@ import
software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughputDescr
@Path("/aws2-ddb")
@ApplicationScoped
-public class Aws2DdbResource {
+public class Aws2DdbResource extends BaseAws2Resource {
+
+ public Aws2DdbResource() {
+ super("ddb");
+ }
public enum Table {
basic, operations, stream
@@ -298,6 +303,6 @@ public class Aws2DdbResource {
default:
tableName = this.tableName;
}
- return "aws2-ddb://" + tableName + "?operation=" + op;
+ return "aws2-ddb://" + tableName + "?operation=" + op +
"&useDefaultCredentialsProvider=" + isUseDefaultCredentials();
}
}
diff --git
a/integration-test-groups/aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
b/integration-test-groups/aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
index fd5d062670..dc066b1517 100644
---
a/integration-test-groups/aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
+++
b/integration-test-groups/aws2/aws2-ddb/src/test/java/org/apache/camel/quarkus/component/aws2/ddb/it/Aws2DdbTest.java
@@ -31,6 +31,7 @@ import io.restassured.response.Response;
import org.apache.camel.component.aws2.ddb.Ddb2Constants;
import org.apache.camel.component.aws2.ddb.Ddb2Operations;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
+import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
import org.awaitility.Awaitility;
import org.hamcrest.Matchers;
import org.jboss.logging.Logger;
@@ -42,10 +43,14 @@ import static org.hamcrest.CoreMatchers.is;
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
-class Aws2DdbTest {
+class Aws2DdbTest extends BaseAWs2TestSupport {
private static final Logger LOG = Logger.getLogger(Aws2DdbTest.class);
+ public Aws2DdbTest() {
+ super("/aws2-ddb");
+ }
+
@Test
public void crud() {
final String key = "key" + UUID.randomUUID().toString().replace("-",
"");
@@ -291,4 +296,13 @@ class Aws2DdbTest {
map -> map.isEmpty());
}
+ @Override
+ public void testMethodForDefaultCredentialsProvider() {
+ final String key = "key" + UUID.randomUUID().toString().replace("-",
"");
+
+ //simple interaction with aws ddb
+ RestAssured.get("/aws2-ddb/item/" + key)
+ .then()
+ .statusCode(204);
+ }
}
diff --git a/integration-test-groups/aws2/aws2-kinesis/pom.xml
b/integration-test-groups/aws2/aws2-kinesis/pom.xml
index e35b19d504..f81cf4854f 100644
--- a/integration-test-groups/aws2/aws2-kinesis/pom.xml
+++ b/integration-test-groups/aws2/aws2-kinesis/pom.xml
@@ -58,6 +58,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/integration-test-groups/aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseResource.java
b/integration-test-groups/aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseResource.java
index 43a5d1ccd2..66f5895478 100644
---
a/integration-test-groups/aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseResource.java
+++
b/integration-test-groups/aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseResource.java
@@ -28,11 +28,12 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.kinesis.Kinesis2Constants;
+import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
import org.eclipse.microprofile.config.inject.ConfigProperty;
@Path("/aws2-kinesis-firehose")
@ApplicationScoped
-public class Aws2KinesisFirehoseResource {
+public class Aws2KinesisFirehoseResource extends BaseAws2Resource {
@ConfigProperty(name = "aws-kinesis-firehose.delivery-stream-name")
String deliveryStreamName;
@@ -40,6 +41,10 @@ public class Aws2KinesisFirehoseResource {
@Inject
ProducerTemplate producerTemplate;
+ public Aws2KinesisFirehoseResource() {
+ super("kinesis-firehose");
+ }
+
@Path("/send")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@@ -58,7 +63,7 @@ public class Aws2KinesisFirehoseResource {
}
private String componentUri() {
- return "aws2-kinesis-firehose://" + deliveryStreamName;
+ return "aws2-kinesis-firehose://" + deliveryStreamName +
"?useDefaultCredentialsProvider=" + isUseDefaultCredentials();
}
}
diff --git
a/integration-test-groups/aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisResource.java
b/integration-test-groups/aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisResource.java
index 835cadcac6..d3a556d253 100644
---
a/integration-test-groups/aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisResource.java
+++
b/integration-test-groups/aws2/aws2-kinesis/src/main/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisResource.java
@@ -32,12 +32,13 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.kinesis.Kinesis2Constants;
+import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.logging.Logger;
@Path("/aws2-kinesis")
@ApplicationScoped
-public class Aws2KinesisResource {
+public class Aws2KinesisResource extends BaseAws2Resource {
private static final Logger log =
Logger.getLogger(Aws2KinesisResource.class);
@@ -51,6 +52,10 @@ public class Aws2KinesisResource {
@Named("aws2KinesisMessages")
Queue<String> aws2KinesisMessages;
+ public Aws2KinesisResource() {
+ super("kinesis");
+ }
+
@Path("/send")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@@ -76,7 +81,7 @@ public class Aws2KinesisResource {
}
private String componentUri() {
- return "aws2-kinesis://" + streamName;
+ return "aws2-kinesis://" + streamName +
"?useDefaultCredentialsProvider=" + isUseDefaultCredentials();
}
}
diff --git
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2LocalStack.java
b/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseIT.java
similarity index 72%
copy from
integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2LocalStack.java
copy to
integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseIT.java
index 09fa1e8544..1347c84e3d 100644
---
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2LocalStack.java
+++
b/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseIT.java
@@ -14,15 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.test.support.aws2;
+package org.apache.camel.quarkus.component.aws2.kinesis.it;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import io.quarkus.test.junit.QuarkusIntegrationTest;
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface Aws2LocalStack {
+@QuarkusIntegrationTest
+class Aws2KinesisFirehoseIT extends Aws2KinesisFirehoseTest {
}
diff --git
a/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java
b/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseTest.java
similarity index 88%
copy from
integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java
copy to
integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseTest.java
index 2cce2d2f24..0524a5dfd6 100644
---
a/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java
+++
b/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisFirehoseTest.java
@@ -26,6 +26,7 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.apache.camel.quarkus.test.support.aws2.Aws2Client;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
+import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
import org.apache.commons.lang3.RandomStringUtils;
import org.awaitility.Awaitility;
import org.eclipse.microprofile.config.Config;
@@ -43,31 +44,15 @@ import software.amazon.awssdk.services.s3.model.S3Object;
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
-class Aws2KinesisTest {
+class Aws2KinesisFirehoseTest extends BaseAWs2TestSupport {
- private static final Logger LOG = Logger.getLogger(Aws2KinesisTest.class);
+ private static final Logger LOG =
Logger.getLogger(Aws2KinesisFirehoseTest.class);
@Aws2Client(Service.S3)
S3Client client;
- @Test
- public void kinesis() {
- final String msg = "kinesis-" +
java.util.UUID.randomUUID().toString().replace("-", "");
- RestAssured.given() //
- .contentType(ContentType.TEXT)
- .body(msg)
- .post("/aws2-kinesis/send") //
- .then()
- .statusCode(201);
-
- Awaitility.await().atMost(10, TimeUnit.SECONDS).until(
- () ->
RestAssured.get("/aws2-kinesis/receive").then().extract(),
- response -> {
- final int status = response.statusCode();
- final String body = status == 200 ?
response.body().asString() : null;
- LOG.info("Got " + status + " " + body);
- return response.statusCode() == 200 && msg.equals(body);
- });
+ public Aws2KinesisFirehoseTest() {
+ super("/aws2-kinesis-firehose");
}
@Test
@@ -128,4 +113,14 @@ class Aws2KinesisTest {
}
+ @Override
+ public void testMethodForDefaultCredentialsProvider() {
+ RestAssured.given() //
+ .contentType(ContentType.TEXT)
+ .body("test")
+ .post("/aws2-kinesis-firehose/send") //
+ .then()
+ .statusCode(201);
+ ;
+ }
}
diff --git
a/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java
b/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java
index 2cce2d2f24..0d3f75c2cc 100644
---
a/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java
+++
b/integration-test-groups/aws2/aws2-kinesis/src/test/java/org/apache/camel/quarkus/component/aws2/kinesis/it/Aws2KinesisTest.java
@@ -16,8 +16,6 @@
*/
package org.apache.camel.quarkus.component.aws2.kinesis.it;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
import java.util.concurrent.TimeUnit;
import io.quarkus.test.common.QuarkusTestResource;
@@ -26,30 +24,26 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.apache.camel.quarkus.test.support.aws2.Aws2Client;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
-import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
import org.awaitility.Awaitility;
-import org.eclipse.microprofile.config.Config;
-import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.localstack.LocalStackContainer.Service;
-import software.amazon.awssdk.core.ResponseInputStream;
import software.amazon.awssdk.services.s3.S3Client;
-import software.amazon.awssdk.services.s3.model.GetObjectRequest;
-import software.amazon.awssdk.services.s3.model.GetObjectResponse;
-import software.amazon.awssdk.services.s3.model.ListObjectsRequest;
-import software.amazon.awssdk.services.s3.model.ListObjectsResponse;
-import software.amazon.awssdk.services.s3.model.S3Object;
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
-class Aws2KinesisTest {
+class Aws2KinesisTest extends BaseAWs2TestSupport {
private static final Logger LOG = Logger.getLogger(Aws2KinesisTest.class);
@Aws2Client(Service.S3)
S3Client client;
+ public Aws2KinesisTest() {
+ super("/aws2-kinesis");
+ }
+
@Test
public void kinesis() {
final String msg = "kinesis-" +
java.util.UUID.randomUUID().toString().replace("-", "");
@@ -70,62 +64,8 @@ class Aws2KinesisTest {
});
}
- @Test
- public void firehose() {
- final String msg = RandomStringUtils.randomAlphanumeric(32 * 1024);
- final String msgPrefix = msg.substring(0, 32);
- final long maxDataBytes =
Aws2KinesisTestEnvCustomizer.BUFFERING_SIZE_MB * 1024 * 1024;
- long bytesSent = 0;
- LOG.info("Sending " + Aws2KinesisTestEnvCustomizer.BUFFERING_SIZE_MB +
" MB of data to firehose using chunk "
- + msgPrefix + "...");
- final long deadline = System.currentTimeMillis() +
(Aws2KinesisTestEnvCustomizer.BUFFERING_TIME_SEC * 1000);
- while (bytesSent < maxDataBytes && System.currentTimeMillis() <
deadline) {
- /*
- * Send at least 1MB of data but do not spend more than a minute
by doing it.
- * This is to overpass minimum buffering limits we have set via
BufferingHints in the EnvCustomizer
- */
- RestAssured.given() //
- .contentType(ContentType.TEXT)
- .body(msg)
- .post("/aws2-kinesis-firehose/send") //
- .then()
- .statusCode(201);
- bytesSent += msg.length();
- LOG.info("Sent " + bytesSent + "/" + maxDataBytes + " bytes of
data");
- }
- LOG.info("Sent " + Aws2KinesisTestEnvCustomizer.BUFFERING_SIZE_MB + "
MB of data to firehose");
-
- final Config config = ConfigProvider.getConfig();
-
- final String bucketName =
config.getValue("aws-kinesis.s3-bucket-name", String.class);
-
- Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(120,
TimeUnit.SECONDS).until(
- () -> {
- final ListObjectsResponse objects = client
-
.listObjects(ListObjectsRequest.builder().bucket(bucketName).build());
- final List<S3Object> objs = objects.contents();
- LOG.info("There are " + objs.size() + " objects in bucket
" + bucketName);
- for (S3Object obj : objs) {
- LOG.info("Checking object " + obj.key() + " of size "
+ obj.size());
- try (ResponseInputStream<GetObjectResponse> o = client
-
.getObject(GetObjectRequest.builder().bucket(bucketName).key(obj.key()).build()))
{
- final StringBuilder sb = new
StringBuilder(msg.length());
- final byte[] buf = new byte[1024];
- int len;
- while ((len = o.read(buf)) >= 0 && sb.length() <
msgPrefix.length()) {
- sb.append(new String(buf, 0, len,
StandardCharsets.UTF_8));
- }
- final String foundContent = sb.toString();
- if (foundContent.startsWith(msgPrefix)) {
- /* Yes, this is what we have sent */
- LOG.info("Found the expected content in object
" + obj.key());
- return true;
- }
- }
- }
- return false;
- });
-
+ @Override
+ public void testMethodForDefaultCredentialsProvider() {
+ kinesis();
}
-
}
diff --git a/integration-test-groups/aws2/aws2-lambda/pom.xml
b/integration-test-groups/aws2/aws2-lambda/pom.xml
index 791204ec7c..f246cfa319 100644
--- a/integration-test-groups/aws2/aws2-lambda/pom.xml
+++ b/integration-test-groups/aws2/aws2-lambda/pom.xml
@@ -35,10 +35,6 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-aws2-lambda</artifactId>
</dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-resteasy</artifactId>
- </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
@@ -58,6 +54,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/integration-test-groups/aws2/aws2-lambda/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaResource.java
b/integration-test-groups/aws2/aws2-lambda/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaResource.java
index 515e3a34fe..1b290f651d 100644
---
a/integration-test-groups/aws2/aws2-lambda/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaResource.java
+++
b/integration-test-groups/aws2/aws2-lambda/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaResource.java
@@ -41,6 +41,7 @@ import org.apache.camel.CamelExecutionException;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.lambda.Lambda2Constants;
import org.apache.camel.component.aws2.lambda.Lambda2Operations;
+import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.logging.Logger;
import software.amazon.awssdk.core.SdkBytes;
@@ -65,7 +66,7 @@ import
software.amazon.awssdk.services.lambda.model.UpdateFunctionCodeResponse;
@Path("/aws2-lambda")
@ApplicationScoped
-public class Aws2LambdaResource {
+public class Aws2LambdaResource extends BaseAws2Resource {
private static final Logger LOG =
Logger.getLogger(Aws2LambdaResource.class);
@@ -78,6 +79,10 @@ public class Aws2LambdaResource {
@Inject
ProducerTemplate producerTemplate;
+ public Aws2LambdaResource() {
+ super("lambda");
+ }
+
@Path("/function/create/{functionName}")
@POST
@Consumes("application/zip")
@@ -395,8 +400,9 @@ public class Aws2LambdaResource {
}
}
- private static String componentUri(String functionName, Lambda2Operations
operation) {
- return "aws2-lambda:" + functionName + "?operation=" + operation;
+ private String componentUri(String functionName, Lambda2Operations
operation) {
+ return "aws2-lambda:" + functionName + "?operation=" + operation +
"&useDefaultCredentialsProvider="
+ + isUseDefaultCredentials();
}
@Provider
diff --git
a/integration-test-groups/aws2/aws2-lambda/src/test/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaTest.java
b/integration-test-groups/aws2/aws2-lambda/src/test/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaTest.java
index 2bf2289a94..97529f7f61 100644
---
a/integration-test-groups/aws2/aws2-lambda/src/test/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaTest.java
+++
b/integration-test-groups/aws2/aws2-lambda/src/test/java/org/apache/camel/quarkus/component/aws2/lambda/it/Aws2LambdaTest.java
@@ -30,6 +30,7 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.ExtractableResponse;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
+import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.Test;
@@ -42,9 +43,13 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
-class Aws2LambdaTest {
+class Aws2LambdaTest extends BaseAWs2TestSupport {
private static final Logger LOG = Logger.getLogger(Aws2LambdaTest.class);
+ public Aws2LambdaTest() {
+ super("/aws2-lambda");
+ }
+
@Test
public void performingOperationsOnLambdaFunctionShouldSucceed() {
final String functionName = "cqFunction" +
java.util.UUID.randomUUID().toString().replace("-", "");
@@ -94,6 +99,14 @@ class Aws2LambdaTest {
.statusCode(204);
}
+ @Override
+ public void testMethodForDefaultCredentialsProvider() {
+ RestAssured.given()
+ .get("/aws2-lambda/function/list/")
+ .then()
+ .statusCode(200);
+ }
+
public void getUpdateListAndInvokeFunctionShouldSucceed(String
functionName) {
final String name = "Joe " +
java.util.UUID.randomUUID().toString().replace("-", "");
diff --git a/integration-test-groups/aws2/aws2-s3/pom.xml
b/integration-test-groups/aws2/aws2-s3/pom.xml
index 6c7f9b2c2e..872bd64b4a 100644
--- a/integration-test-groups/aws2/aws2-s3/pom.xml
+++ b/integration-test-groups/aws2/aws2-s3/pom.xml
@@ -66,6 +66,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/integration-test-groups/aws2/aws2-s3/src/main/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Resource.java
b/integration-test-groups/aws2/aws2-s3/src/main/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Resource.java
index 82f70eaee1..53bdcc45e5 100644
---
a/integration-test-groups/aws2/aws2-s3/src/main/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Resource.java
+++
b/integration-test-groups/aws2/aws2-s3/src/main/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Resource.java
@@ -49,6 +49,7 @@ import org.apache.camel.ConsumerTemplate;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.s3.AWS2S3Constants;
import org.apache.camel.component.aws2.s3.AWS2S3Operations;
+import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import software.amazon.awssdk.core.ResponseInputStream;
import software.amazon.awssdk.services.s3.model.Bucket;
@@ -56,9 +57,9 @@ import
software.amazon.awssdk.services.s3.model.GetObjectResponse;
import software.amazon.awssdk.services.s3.model.NoSuchBucketException;
import software.amazon.awssdk.services.s3.model.S3Object;
-@Path("/aws2")
+@Path("/aws2-s3")
@ApplicationScoped
-public class Aws2S3Resource {
+public class Aws2S3Resource extends BaseAws2Resource {
@Inject
ProducerTemplate producerTemplate;
@@ -72,20 +73,24 @@ public class Aws2S3Resource {
@ConfigProperty(name = "aws-s3.kms-key-id")
Optional<String> kmsKeyId;
- @Path("s3/object/{key}")
+ public Aws2S3Resource() {
+ super("s3");
+ }
+
+ @Path("object/{key}")
@POST
@Consumes(MediaType.TEXT_PLAIN)
public Response post(String message, @PathParam("key") String key,
@QueryParam("useKms") @DefaultValue("false") boolean useKms)
throws Exception {
producerTemplate.sendBodyAndHeader(
- componentUri() + (useKms && kmsKeyId.isPresent() ?
"?useAwsKMS=true&awsKMSKeyId=" + kmsKeyId : ""),
+ componentUri() + (useKms && kmsKeyId.isPresent() ?
"&useAwsKMS=true&awsKMSKeyId=" + kmsKeyId : ""),
message,
AWS2S3Constants.KEY,
key);
return Response.created(new URI("https://camel.apache.org/")).build();
}
- @Path("s3/object/{key}")
+ @Path("object/{key}")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String get(@PathParam("key") String key, @QueryParam("bucket")
String bucket,
@@ -103,14 +108,14 @@ public class Aws2S3Resource {
String.class);
}
- @Path("s3/poll-object/{key}")
+ @Path("poll-object/{key}")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String pollObject(@PathParam("key") String key) throws Exception {
- return consumerTemplate.receiveBody(componentUri() + "?fileName=" +
key, 10000, String.class);
+ return consumerTemplate.receiveBody(componentUri() + "&fileName=" +
key, 10000, String.class);
}
- @Path("s3/object/{key}")
+ @Path("object/{key}")
@DELETE
@Produces(MediaType.TEXT_PLAIN)
public Response read(@PathParam("key") String key) throws Exception {
@@ -122,7 +127,7 @@ public class Aws2S3Resource {
return Response.noContent().build();
}
- @Path("s3/bucket/{bucketName}/object/{key}")
+ @Path("bucket/{bucketName}/object/{key}")
@DELETE
@Produces(MediaType.TEXT_PLAIN)
public Response read(@PathParam("bucketName") String bucketName,
@PathParam("key") String key) throws Exception {
@@ -134,7 +139,7 @@ public class Aws2S3Resource {
return Response.noContent().build();
}
- @Path("s3/object-keys")
+ @Path("object-keys")
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<String> objectKey() throws Exception {
@@ -151,7 +156,7 @@ public class Aws2S3Resource {
* @param newBucketName
* @return
*/
- @Path("s3/autoCreateBucket/{newBucketName}")
+ @Path("autoCreateBucket/{newBucketName}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response autoCreateBucket(@PathParam("newBucketName") String
newBucketName) {
@@ -161,7 +166,7 @@ public class Aws2S3Resource {
return Response.noContent().build();
}
- @Path("s3/upload/{key}")
+ @Path("upload/{key}")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
@@ -171,7 +176,7 @@ public class Aws2S3Resource {
int partSize = 5 * 1024 * 1024;
producerTemplate.sendBodyAndHeader(
- componentUri() + "?multiPartUpload=true&partSize=" + partSize
+ "&autoCreateBucket=true",
+ componentUri() + "&multiPartUpload=true&partSize=" + partSize
+ "&autoCreateBucket=true",
file,
AWS2S3Constants.KEY,
key);
@@ -179,7 +184,7 @@ public class Aws2S3Resource {
return key;
}
- @Path("s3/copy/{key}")
+ @Path("copy/{key}")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_PLAIN)
@@ -197,7 +202,7 @@ public class Aws2S3Resource {
return Response.noContent().build();
}
- @Path("s3/bucket")
+ @Path("bucket")
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<String> listBuckets() throws Exception {
@@ -208,7 +213,7 @@ public class Aws2S3Resource {
return buckets.stream().map(Bucket::name).collect(Collectors.toList());
}
- @Path("s3/bucket/{name}")
+ @Path("bucket/{name}")
@DELETE
@Produces(MediaType.TEXT_PLAIN)
public Response deleteBucket(@PathParam("name") String bucketName) {
@@ -225,7 +230,7 @@ public class Aws2S3Resource {
return Response.noContent().build();
}
- @Path("s3/downloadlink/{key}")
+ @Path("downloadlink/{key}")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String downloadLink(@PathParam("key") String key,
@QueryParam("bucket") String bucket) {
@@ -243,7 +248,7 @@ public class Aws2S3Resource {
return link;
}
- @Path("s3/object/range/{key}")
+ @Path("object/range/{key}")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String objectRange(@PathParam("key") String key,
@@ -273,7 +278,8 @@ public class Aws2S3Resource {
}
private String componentUri(String bucketName, final AWS2S3Operations
operation) {
- return String.format("aws2-s3://%s?operation=%s", bucketName,
operation);
+ return
String.format("aws2-s3://%s?operation=%s&useDefaultCredentialsProvider=%s",
bucketName, operation,
+ isUseDefaultCredentials());
}
private String componentUri(final AWS2S3Operations operation) {
@@ -281,7 +287,7 @@ public class Aws2S3Resource {
}
private String componentUri() {
- return String.format("aws2-s3://%s", bucketName);
+ return String.format("aws2-s3://%s?useDefaultCredentialsProvider=%s",
bucketName, isUseDefaultCredentials());
}
}
diff --git
a/integration-test-groups/aws2/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Test.java
b/integration-test-groups/aws2/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Test.java
index 2596c4d03c..87c2703208 100644
---
a/integration-test-groups/aws2/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Test.java
+++
b/integration-test-groups/aws2/aws2-s3/src/test/java/org/apache/camel/quarkus/component/aws2/s3/it/Aws2S3Test.java
@@ -28,6 +28,7 @@ import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
+import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
@@ -40,10 +41,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
-class Aws2S3Test {
+class Aws2S3Test extends BaseAWs2TestSupport {
private int objects_num_before;
private int objects_num_after;
+ public Aws2S3Test() {
+ super("/aws2-s3");
+ }
+
@BeforeEach
public void before() {
objects_num_before = getObjects().length;
@@ -61,7 +66,7 @@ class Aws2S3Test {
private String[] getObjects() {
final String[] objects = RestAssured.given()
- .get("/aws2/s3/object-keys")
+ .get("/aws2-s3/object-keys")
.then()
.statusCode(200)
.extract()
@@ -78,7 +83,7 @@ class Aws2S3Test {
// Make sure the object does not exist yet
final String[] objects = RestAssured.given()
- .get("/aws2/s3/object-keys")
+ .get("/aws2-s3/object-keys")
.then()
.statusCode(200)
.extract()
@@ -89,12 +94,12 @@ class Aws2S3Test {
RestAssured.given()
.contentType(ContentType.TEXT)
.body(blobContent)
- .post("/aws2/s3/object/" + oid)
+ .post("/aws2-s3/object/" + oid)
.then()
.statusCode(201);
// Read
- RestAssured.get("/aws2/s3/object/" + oid)
+ RestAssured.get("/aws2-s3/object/" + oid)
.then()
.statusCode(200)
.body(is(blobContent));
@@ -104,18 +109,18 @@ class Aws2S3Test {
RestAssured.given()
.contentType(ContentType.TEXT)
.body(updatedContent)
- .post("/aws2/s3/object/" + oid)
+ .post("/aws2-s3/object/" + oid)
.then()
.statusCode(201);
// Read updated
- RestAssured.get("/aws2/s3/object/" + oid)
+ RestAssured.get("/aws2-s3/object/" + oid)
.then()
.statusCode(200)
.body(is(updatedContent));
// Delete
- RestAssured.delete("/aws2/s3/object/" + oid)
+ RestAssured.delete("/aws2-s3/object/" + oid)
.then()
.statusCode(204);
}
@@ -128,7 +133,7 @@ class Aws2S3Test {
// Make sure the object does not exist yet
{
final String[] objects = RestAssured.given()
- .get("/aws2/s3/object-keys")
+ .get("/aws2-s3/object-keys")
.then()
.statusCode(200)
.extract()
@@ -140,12 +145,12 @@ class Aws2S3Test {
RestAssured.given()
.contentType(ContentType.TEXT)
.body(blobContent)
- .post("/aws2/s3/object/" + oid)
+ .post("/aws2-s3/object/" + oid)
.then()
.statusCode(201);
// Consumer
- RestAssured.get("/aws2/s3/poll-object/" + oid)
+ RestAssured.get("/aws2-s3/poll-object/" + oid)
.then()
.statusCode(200)
.body(is(blobContent));
@@ -153,7 +158,7 @@ class Aws2S3Test {
// Make sure the consumer has removed the file from the bucket
{
final String[] objects = RestAssured.given()
- .get("/aws2/s3/object-keys")
+ .get("/aws2-s3/object-keys")
.then()
.statusCode(200)
.extract()
@@ -172,12 +177,12 @@ class Aws2S3Test {
RestAssured.given()
.contentType(ContentType.TEXT)
.body(blobContent)
- .post("/aws2/s3/object/" + oid + "?useKms=true")
+ .post("/aws2-s3/object/" + oid + "?useKms=true")
.then()
.statusCode(201);
// Read
- RestAssured.get("/aws2/s3/object/" + oid + "?useKms=true")
+ RestAssured.get("/aws2-s3/object/" + oid + "?useKms=true")
.then()
.statusCode(200)
.body(is(blobContent));
@@ -196,11 +201,11 @@ class Aws2S3Test {
RestAssured.given()
.contentType(ContentType.TEXT)
.body(content)
- .post("/aws2/s3/upload/" + oid)
+ .post("/aws2-s3/upload/" + oid)
.then()
.statusCode(200);
- String result = RestAssured.get("/aws2/s3/object/" + oid)
+ String result = RestAssured.get("/aws2-s3/object/" + oid)
.then()
.statusCode(200)
.extract().asString();
@@ -226,7 +231,7 @@ class Aws2S3Test {
RestAssured.given()
.contentType(ContentType.TEXT)
.body(blobContent)
- .post("/aws2/s3/object/" + oid1)
+ .post("/aws2-s3/object/" + oid1)
.then()
.statusCode(201);
@@ -242,14 +247,14 @@ class Aws2S3Test {
.contentType(ContentType.URLENC)
.formParam("dest_key", oid2)
.formParam("dest_bucket", destinationBucket)
- .post("/aws2/s3/copy/" + oid1)
+ .post("/aws2-s3/copy/" + oid1)
.then()
.statusCode(204);
// Verify the object
RestAssured.given()
.contentType(ContentType.TEXT)
- .get("/aws2/s3/object/" + oid2 + "?bucket=" +
destinationBucket)
+ .get("/aws2-s3/object/" + oid2 + "?bucket=" +
destinationBucket)
.then()
.statusCode(200)
.body(is(blobContent));
@@ -260,14 +265,14 @@ class Aws2S3Test {
// Delete the object before deleting the bucket
try {
- RestAssured.delete("/aws2/s3/bucket/" + destinationBucket +
"/object/" + oid2)
+ RestAssured.delete("/aws2-s3/bucket/" + destinationBucket +
"/object/" + oid2)
.then()
.statusCode(204);
} catch (Exception ignored) {
}
// Delete the bucket
- RestAssured.delete("/aws2/s3/bucket/" + destinationBucket)
+ RestAssured.delete("/aws2-s3/bucket/" + destinationBucket)
.then()
.statusCode(204);
@@ -298,7 +303,7 @@ class Aws2S3Test {
// Get the download link
final String downloadLink = RestAssured.given()
.contentType(ContentType.TEXT)
- .get("/aws2/s3/downloadlink/" + oid)
+ .get("/aws2-s3/downloadlink/" + oid)
.then()
.statusCode(200)
.extract().body().asString();
@@ -331,7 +336,7 @@ class Aws2S3Test {
RestAssured.given()
.contentType(ContentType.TEXT)
.param("start", "0").param("end", "4")
- .get("/aws2/s3/object/range/" + oid)
+ .get("/aws2-s3/object/range/" + oid)
.then()
.statusCode(200)
.body(is("Hello"));
@@ -345,13 +350,13 @@ class Aws2S3Test {
RestAssured.given()
.contentType(ContentType.TEXT)
.body(blobContent)
- .post("/aws2/s3/object/" + oid)
+ .post("/aws2-s3/object/" + oid)
.then()
.statusCode(201);
}
private void deleteObject(String oid) {
- RestAssured.delete("/aws2/s3/object/" + oid)
+ RestAssured.delete("/aws2-s3/object/" + oid)
.then()
.statusCode(204);
}
@@ -363,7 +368,7 @@ class Aws2S3Test {
*/
private void autoCreateBucket(String newBucketName) {
RestAssured.given()
- .get("/aws2/s3/autoCreateBucket/" + newBucketName)
+ .get("/aws2-s3/autoCreateBucket/" + newBucketName)
.then()
.statusCode(204);
}
@@ -371,7 +376,7 @@ class Aws2S3Test {
private String[] getAllBuckets() {
String[] buckets = RestAssured.given()
.contentType(ContentType.TEXT)
- .get("/aws2/s3/bucket")
+ .get("/aws2-s3/bucket")
.then()
.statusCode(200)
.extract()
@@ -380,4 +385,12 @@ class Aws2S3Test {
return buckets;
}
+ @Override
+ public void testMethodForDefaultCredentialsProvider() {
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .get("/aws2-s3/bucket")
+ .then()
+ .statusCode(200);
+ }
}
diff --git a/integration-test-groups/aws2/aws2-ses/pom.xml
b/integration-test-groups/aws2/aws2-ses/pom.xml
index 5b29663c0d..86ab4ad035 100644
--- a/integration-test-groups/aws2/aws2-ses/pom.xml
+++ b/integration-test-groups/aws2/aws2-ses/pom.xml
@@ -54,6 +54,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/integration-test-groups/aws2/aws2-ses/src/main/java/org/apache/camel/quarkus/component/aws2/ses/it/Aws2SesResource.java
b/integration-test-groups/aws2/aws2-ses/src/main/java/org/apache/camel/quarkus/component/aws2/ses/it/Aws2SesResource.java
index 6e8dc507d1..5948a05106 100644
---
a/integration-test-groups/aws2/aws2-ses/src/main/java/org/apache/camel/quarkus/component/aws2/ses/it/Aws2SesResource.java
+++
b/integration-test-groups/aws2/aws2-ses/src/main/java/org/apache/camel/quarkus/component/aws2/ses/it/Aws2SesResource.java
@@ -30,16 +30,21 @@ import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.camel.FluentProducerTemplate;
import org.apache.camel.component.aws2.ses.Ses2Constants;
+import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
import org.jboss.logging.Logger;
@Path("/aws2-ses")
@ApplicationScoped
-public class Aws2SesResource {
+public class Aws2SesResource extends BaseAws2Resource {
private static final Logger LOG = Logger.getLogger(Aws2SesResource.class);
@Inject
FluentProducerTemplate producerTemplate;
+ public Aws2SesResource() {
+ super("ses");
+ }
+
@Path("/send")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@@ -51,7 +56,7 @@ public class Aws2SesResource {
@HeaderParam("x-subject") String subject,
@HeaderParam("x-returnPath") String returnPath) throws Exception {
Object response = producerTemplate
- .to("aws2-ses:" + from)
+ .to("aws2-ses:" + from + "?useDefaultCredentialsProvider=" +
isUseDefaultCredentials())
.withHeader(Ses2Constants.TO, Collections.singletonList(to))
.withHeader(Ses2Constants.SUBJECT, subject)
.withHeader(Ses2Constants.RETURN_PATH, returnPath)
diff --git
a/integration-test-groups/aws2/aws2-ses/src/test/java/org/apache/camel/quarkus/component/aws2/ses/it/Aws2SesTest.java
b/integration-test-groups/aws2/aws2-ses/src/test/java/org/apache/camel/quarkus/component/aws2/ses/it/Aws2SesTest.java
index 5756bc2414..ef5d327c8a 100644
---
a/integration-test-groups/aws2/aws2-ses/src/test/java/org/apache/camel/quarkus/component/aws2/ses/it/Aws2SesTest.java
+++
b/integration-test-groups/aws2/aws2-ses/src/test/java/org/apache/camel/quarkus/component/aws2/ses/it/Aws2SesTest.java
@@ -33,8 +33,8 @@ import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import org.apache.camel.quarkus.test.support.aws2.Aws2Client;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
+import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
import org.apache.commons.lang3.RandomStringUtils;
-import org.assertj.core.api.Assertions;
import org.awaitility.Awaitility;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
@@ -49,13 +49,16 @@ import software.amazon.awssdk.services.ses.SesClient;
import
software.amazon.awssdk.services.ses.model.DeleteVerifiedEmailAddressRequest;
import software.amazon.awssdk.services.ses.model.VerifyEmailAddressRequest;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
+
/* Disabled on Localstack because Localstack does not send e-mails which we do
assume in our tests
* See
https://github.com/localstack/localstack/issues/339#issuecomment-341727758 */
@EnabledIfEnvironmentVariable(named = "AWS_ACCESS_KEY", matches =
"[a-zA-Z0-9]+")
@EnabledIfEnvironmentVariable(named = "MAILSLURP_API_KEY", matches =
"[a-zA-Z0-9]+")
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
-class Aws2SesTest {
+class Aws2SesTest extends BaseAWs2TestSupport {
private static final Logger LOG = Logger.getLogger(Aws2SesTest.class);
private static final Pattern VERIFCATION_LINK_PATTERN =
Pattern.compile("https://email-verification[^\\s]+");
@@ -63,6 +66,10 @@ class Aws2SesTest {
@Aws2Client(Service.SES)
SesClient sesClient;
+ public Aws2SesTest() {
+ super("/aws2-ses");
+ }
+
@Test
public void test() throws InterruptedException, ExecutionException,
TimeoutException {
@@ -137,12 +144,12 @@ class Aws2SesTest {
WebDriver driver = new HtmlUnitDriver();
driver.get(link);
String source = driver.getPageSource();
- Assertions.assertThat(source).contains("You have
successfully verified an email address");
+ assertThat(source).contains("You have successfully
verified an email address");
verified = true;
break;
}
}
- Assertions.assertThat(verified).isTrue();
+ assertThat(verified).isTrue();
/* All prerequisites should be set up now, so we can send the
message via SES */
final String randomId =
RandomStringUtils.randomAlphanumeric(16).toLowerCase(Locale.ROOT);
@@ -194,4 +201,12 @@ class Aws2SesTest {
}
}
+ @Override
+ public void testMethodForDefaultCredentialsProvider() {
+ try {
+ test();
+ } catch (Exception e) {
+ fail(e);
+ }
+ }
}
diff --git a/integration-test-groups/aws2/aws2-sqs-sns/pom.xml
b/integration-test-groups/aws2/aws2-sqs-sns/pom.xml
index 8db77be3d7..86f4301c50 100644
--- a/integration-test-groups/aws2/aws2-sqs-sns/pom.xml
+++ b/integration-test-groups/aws2/aws2-sqs-sns/pom.xml
@@ -62,6 +62,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/integration-test-groups/aws2/aws2-sqs-sns/src/main/java/org/apache/camel/quarkus/component/aws2/sns/it/Aws2SqsSnsResource.java
b/integration-test-groups/aws2/aws2-sqs-sns/src/main/java/org/apache/camel/quarkus/component/aws2/sns/it/Aws2SqsSnsResource.java
index ad1cc72774..6708491498 100644
---
a/integration-test-groups/aws2/aws2-sqs-sns/src/main/java/org/apache/camel/quarkus/component/aws2/sns/it/Aws2SqsSnsResource.java
+++
b/integration-test-groups/aws2/aws2-sqs-sns/src/main/java/org/apache/camel/quarkus/component/aws2/sns/it/Aws2SqsSnsResource.java
@@ -34,11 +34,12 @@ import jakarta.ws.rs.core.Response;
import org.apache.camel.ConsumerTemplate;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.sqs.Sqs2Constants;
+import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
import org.eclipse.microprofile.config.inject.ConfigProperty;
@Path("/aws2-sqs-sns")
@ApplicationScoped
-public class Aws2SqsSnsResource {
+public class Aws2SqsSnsResource extends BaseAws2Resource {
@ConfigProperty(name = "aws-sqs.queue-name")
String queueName;
@@ -67,11 +68,15 @@ public class Aws2SqsSnsResource {
@Inject
ConsumerTemplate consumerTemplate;
+ public Aws2SqsSnsResource() {
+ super("sns");
+ }
+
@Path("/sqs/purge/queue/{queueName}")
@DELETE
@Produces(MediaType.TEXT_PLAIN)
public Response purgeQueue(@PathParam("queueName") String queueName)
throws Exception {
- producerTemplate.sendBodyAndHeader(componentUri(queueName) +
"?operation=purgeQueue",
+ producerTemplate.sendBodyAndHeader(componentUri(queueName) +
"&operation=purgeQueue",
null,
Sqs2Constants.SQS_QUEUE_PREFIX,
queueName);
@@ -86,10 +91,13 @@ public class Aws2SqsSnsResource {
@QueryParam("queueUrl") String queueUrl,
@DefaultValue("false") @QueryParam("fifo") boolean fifo) throws
Exception {
+ String endpointUri = String.format(
+
"aws2-sns://%s?useDefaultCredentialsProvider=%s&subscribeSNStoSQS=true&queueUrl=RAW(%s)%s",
+ fifo ? fifoTopicName : topicName, isUseDefaultCredentials(),
+ fifo ? snsFifoReceiverQueueArn : snsReceiverQueueArn,
+ fifo ? "&messageGroupIdStrategy=useExchangeId" : "");
final String response = producerTemplate.requestBody(
-
String.format("aws2-sns://%s?subscribeSNStoSQS=true&queueUrl=RAW(%s)%s",
- fifo ? fifoTopicName : topicName, fifo ?
snsFifoReceiverQueueArn : snsReceiverQueueArn,
- fifo ? "&messageGroupIdStrategy=useExchangeId" : ""),
+ endpointUri,
message,
String.class);
return Response
@@ -104,7 +112,7 @@ public class Aws2SqsSnsResource {
public String sqsReceive(@PathParam("queueName") String queueName,
@PathParam("deleteMessage") String deleteMessage)
throws Exception {
return consumerTemplate.receiveBody(componentUri(queueName)
- + "?deleteAfterRead=" + deleteMessage + "&deleteIfFiltered=" +
deleteMessage + "&defaultVisibilityTimeout=0",
+ + "&?deleteAfterRead=" + deleteMessage + "&deleteIfFiltered="
+ deleteMessage + "&defaultVisibilityTimeout=0",
10000,
String.class);
}
@@ -113,17 +121,17 @@ public class Aws2SqsSnsResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public String sqsReceiveViaSqs() throws Exception {
- return consumerTemplate.receiveBody("aws2-sqs://" +
snsReceiverQueueName, 10000, String.class);
+ return
consumerTemplate.receiveBody(componentUri(snsReceiverQueueName), 10000,
String.class);
}
@Path("/snsFifo/receiveViaSqs")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String fifoSqsReceiveViaSqs() throws Exception {
- return consumerTemplate.receiveBody("aws2-sqs://" +
snsFifoReceiverQueueName, 10000, String.class);
+ return
consumerTemplate.receiveBody(componentUri(snsFifoReceiverQueueName), 10000,
String.class);
}
private String componentUri(String queueName) {
- return "aws2-sqs://" + queueName;
+ return "aws2-sqs://" + queueName + "?useDefaultCredentialsProvider=" +
isUseDefaultCredentials();
}
}
diff --git
a/integration-test-groups/aws2/aws2-sqs-sns/src/test/java/org/apache/camel/quarkus/component/aws2/sns/it/Aws2SqsSnsTest.java
b/integration-test-groups/aws2/aws2-sqs-sns/src/test/java/org/apache/camel/quarkus/component/aws2/sns/it/Aws2SqsSnsTest.java
index 6f38a307e4..d84842bd5e 100644
---
a/integration-test-groups/aws2/aws2-sqs-sns/src/test/java/org/apache/camel/quarkus/component/aws2/sns/it/Aws2SqsSnsTest.java
+++
b/integration-test-groups/aws2/aws2-sqs-sns/src/test/java/org/apache/camel/quarkus/component/aws2/sns/it/Aws2SqsSnsTest.java
@@ -25,6 +25,7 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.apache.camel.quarkus.test.support.aws2.Aws2LocalStack;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
+import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
@@ -35,7 +36,11 @@ import static org.hamcrest.core.Is.is;
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
-class Aws2SqsSnsTest {
+class Aws2SqsSnsTest extends BaseAWs2TestSupport {
+
+ public Aws2SqsSnsTest() {
+ super("/aws2-sqs-sns");
+ }
private String getPredefinedQueueName() {
return ConfigProvider.getConfig().getValue("aws-sqs.queue-name",
String.class);
@@ -111,4 +116,8 @@ class Aws2SqsSnsTest {
.body("Message", is(snsMsg));
}
+ @Override
+ public void testMethodForDefaultCredentialsProvider() {
+ sns();
+ }
}
diff --git a/integration-test-groups/aws2/aws2-sqs/pom.xml
b/integration-test-groups/aws2/aws2-sqs/pom.xml
index 3920568c1a..5e50a68cd6 100644
--- a/integration-test-groups/aws2/aws2-sqs/pom.xml
+++ b/integration-test-groups/aws2/aws2-sqs/pom.xml
@@ -58,6 +58,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/integration-test-groups/aws2/aws2-sqs/src/main/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsResource.java
b/integration-test-groups/aws2/aws2-sqs/src/main/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsResource.java
index d28cb79d2f..6bd106b8b9 100644
---
a/integration-test-groups/aws2/aws2-sqs/src/main/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsResource.java
+++
b/integration-test-groups/aws2/aws2-sqs/src/main/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsResource.java
@@ -35,13 +35,14 @@ import jakarta.ws.rs.core.Response;
import org.apache.camel.ConsumerTemplate;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.sqs.Sqs2Constants;
+import org.apache.camel.quarkus.test.support.aws2.BaseAws2Resource;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import software.amazon.awssdk.services.sqs.model.ListQueuesResponse;
import software.amazon.awssdk.services.sqs.model.SendMessageBatchResponse;
@Path("/aws2-sqs")
@ApplicationScoped
-public class Aws2SqsResource {
+public class Aws2SqsResource extends BaseAws2Resource {
@ConfigProperty(name = "aws-sqs.queue-name")
String queueName;
@@ -52,6 +53,10 @@ public class Aws2SqsResource {
@Inject
ConsumerTemplate consumerTemplate;
+ public Aws2SqsResource() {
+ super("sqs");
+ }
+
@Path("send")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@@ -80,7 +85,7 @@ public class Aws2SqsResource {
@DELETE
@Produces(MediaType.TEXT_PLAIN)
public Response purgeQueue(@PathParam("queueName") String queueName)
throws Exception {
- producerTemplate.sendBody(componentUri(queueName) +
"?operation=purgeQueue",
+ producerTemplate.sendBody(componentUri(queueName) +
"&operation=purgeQueue",
null);
return Response.ok().build();
}
@@ -91,7 +96,7 @@ public class Aws2SqsResource {
public String sqsReceive(@PathParam("queueName") String queueName,
@PathParam("deleteMessage") String deleteMessage)
throws Exception {
return consumerTemplate.receiveBody(componentUri(queueName)
- + "?deleteAfterRead=" + deleteMessage + "&deleteIfFiltered=" +
deleteMessage + "&defaultVisibilityTimeout=0",
+ + "&deleteAfterRead=" + deleteMessage + "&deleteIfFiltered=" +
deleteMessage + "&defaultVisibilityTimeout=0",
10000,
String.class);
}
@@ -110,7 +115,7 @@ public class Aws2SqsResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<String> listQueues() throws Exception {
- return producerTemplate.requestBody(componentUri() +
"?operation=listQueues", null, ListQueuesResponse.class)
+ return producerTemplate.requestBody(componentUri() +
"&operation=listQueues", null, ListQueuesResponse.class)
.queueUrls();
}
@@ -120,7 +125,7 @@ public class Aws2SqsResource {
@Produces(MediaType.TEXT_PLAIN)
public Response sendBatchMessage(List<String> messages) throws Exception {
final SendMessageBatchResponse response = producerTemplate.requestBody(
- componentUri() + "?operation=sendBatchMessage",
+ componentUri() + "&operation=sendBatchMessage",
messages,
SendMessageBatchResponse.class);
return Response
@@ -134,7 +139,7 @@ public class Aws2SqsResource {
@Produces(MediaType.TEXT_PLAIN)
public Response deleteMessage(@PathParam("queueName") String queueName,
@PathParam("receipt") String receipt)
throws Exception {
- producerTemplate.sendBodyAndHeader(componentUri(queueName) +
"?operation=deleteMessage",
+ producerTemplate.sendBodyAndHeader(componentUri(queueName) +
"&operation=deleteMessage",
null,
Sqs2Constants.RECEIPT_HANDLE,
URLDecoder.decode(receipt, StandardCharsets.UTF_8));
@@ -145,7 +150,7 @@ public class Aws2SqsResource {
@DELETE
@Produces(MediaType.TEXT_PLAIN)
public Response deleteQueue(@PathParam("queueName") String queueName)
throws Exception {
- producerTemplate.sendBody(componentUri(queueName) +
"?operation=deleteQueue",
+ producerTemplate.sendBody(componentUri(queueName) +
"&operation=deleteQueue",
null);
return Response.ok().build();
}
@@ -165,11 +170,11 @@ public class Aws2SqsResource {
}
private String componentUri() {
- return "aws2-sqs://" + queueName;
+ return componentUri(queueName);
}
private String componentUri(String queueName) {
- return "aws2-sqs://" + queueName;
+ return "aws2-sqs://" + queueName + "?useDefaultCredentialsProvider=" +
isUseDefaultCredentials();
}
}
diff --git
a/integration-test-groups/aws2/aws2-sqs/src/test/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsTest.java
b/integration-test-groups/aws2/aws2-sqs/src/test/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsTest.java
index b485452a09..004d8fc9e8 100644
---
a/integration-test-groups/aws2/aws2-sqs/src/test/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsTest.java
+++
b/integration-test-groups/aws2/aws2-sqs/src/test/java/org/apache/camel/quarkus/component/aws2/sqs/it/Aws2SqsTest.java
@@ -35,6 +35,7 @@ import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import org.apache.camel.quarkus.test.support.aws2.Aws2LocalStack;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestResource;
+import org.apache.camel.quarkus.test.support.aws2.BaseAWs2TestSupport;
import org.awaitility.Awaitility;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
@@ -48,13 +49,17 @@ import static org.hamcrest.Matchers.is;
@QuarkusTest
@QuarkusTestResource(Aws2TestResource.class)
-class Aws2SqsTest {
+class Aws2SqsTest extends BaseAWs2TestSupport {
private static final Logger LOG = Logger.getLogger(Aws2SqsTest.class);
@Aws2LocalStack
private boolean localStack;
+ public Aws2SqsTest() {
+ super("/aws2-sqs");
+ }
+
private String getPredefinedQueueName() {
return ConfigProvider.getConfig().getValue("aws-sqs.queue-name",
String.class);
}
@@ -255,4 +260,8 @@ class Aws2SqsTest {
.asString());
}
+ @Override
+ public void testMethodForDefaultCredentialsProvider() {
+ listQueues();
+ }
}
diff --git a/integration-tests-jvm/aws-secrets-manager/pom.xml
b/integration-tests-jvm/aws-secrets-manager/pom.xml
index 0dbf27814d..a0d411bdf3 100644
--- a/integration-tests-jvm/aws-secrets-manager/pom.xml
+++ b/integration-tests-jvm/aws-secrets-manager/pom.xml
@@ -58,6 +58,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/integration-tests-support/aws2/pom.xml
b/integration-tests-support/aws2/pom.xml
index b915cf8c8b..77ebeea2a2 100644
--- a/integration-tests-support/aws2/pom.xml
+++ b/integration-tests-support/aws2/pom.xml
@@ -29,18 +29,59 @@
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
<name>Camel Quarkus :: Integration Tests :: Support :: AWS 2</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
<dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>software.amazon.awssdk</groupId>
+ <artifactId>aws-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>sdk-core</artifactId>
+ <groupId>software.amazon.awssdk</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>software.amazon.awssdk</groupId>
+ <artifactId>sdk-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>software.amazon.awssdk</groupId>
+ <artifactId>auth</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-support</artifactId>
+ <!-- Dependency should be excluded when this module us used a
compile dependency and a test-jar dependency os also present.-->
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-support-mock-backend</artifactId>
+ <!-- Dependency should be excluded when this module us used a
compile dependency and a test-jar dependency os also present.-->
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>localstack</artifactId>
+ <!-- Dependency should be excluded when this module us used a
compile dependency and a test-jar dependency os also present.-->
<exclusions>
<exclusion>
<groupId>junit</groupId>
@@ -51,22 +92,17 @@
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit4-mock</artifactId>
+ <!-- Dependency should be excluded when this module us used a
compile dependency and a test-jar dependency os also present.-->
</dependency>
<dependency>
- <groupId>software.amazon.awssdk</groupId>
- <artifactId>auth</artifactId>
- </dependency>
- <dependency>
- <groupId>software.amazon.awssdk</groupId>
- <artifactId>aws-core</artifactId>
- </dependency>
- <dependency>
- <groupId>software.amazon.awssdk</groupId>
- <artifactId>sdk-core</artifactId>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <!-- Dependency should be excluded when this module us used a
compile dependency and a test-jar dependency os also present.-->
</dependency>
<dependency><!-- Workaround for
https://github.com/testcontainers/testcontainers-java/issues/1442 -->
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
+ <!-- Dependency should be excluded when this module us used a
compile dependency and a test-jar dependency os also present.-->
<exclusions>
<exclusion>
<groupId>*</groupId>
@@ -74,5 +110,6 @@
</exclusion>
</exclusions>
</dependency>
+
</dependencies>
-</project>
+</project>
\ No newline at end of file
diff --git
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2DefaultCredentialsProviderAvailabilityCondition.java
b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2Helper.java
similarity index 62%
copy from
integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2DefaultCredentialsProviderAvailabilityCondition.java
copy to
integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2Helper.java
index 6b2787ecc2..d61b900209 100644
---
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2DefaultCredentialsProviderAvailabilityCondition.java
+++
b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2Helper.java
@@ -16,33 +16,36 @@
*/
package org.apache.camel.quarkus.test.support.aws2;
-import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
-import org.junit.jupiter.api.extension.ConditionEvaluationResult;
-import org.junit.jupiter.api.extension.ExecutionCondition;
-import org.junit.jupiter.api.extension.ExtensionContext;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.core.exception.SdkClientException;
-public class Aws2DefaultCredentialsProviderAvailabilityCondition implements
ExecutionCondition {
+public class Aws2Helper {
public static final String UNABLE_TO_LOAD_CREDENTIALS_MSG = "Unable to
load credentials";
- @Override
- public ConditionEvaluationResult
evaluateExecutionCondition(ExtensionContext context) {
- if (!MockBackendUtils.startMockBackend(false)) {
- return ConditionEvaluationResult.disabled("Test can be executed
only with mock backend.");
- }
+ public static boolean isDefaultCredentialsProviderDefinedOnSystem() {
try {
DefaultCredentialsProvider.create().resolveCredentials();
} catch (Exception e) {
//if message starts with "Unable to load credentials", allow
testing
if (e instanceof SdkClientException && e.getMessage() != null
&&
e.getMessage().startsWith(UNABLE_TO_LOAD_CREDENTIALS_MSG)) {
- return ConditionEvaluationResult
- .enabled("DefaultCredentialsProvider is NOT defined in
the system, Testing can proceed.");
+ return false;
}
}
- return ConditionEvaluationResult.disabled("DefaultCredentialsProvider
is already defined in the system.");
+ return true;
+ }
+
+ public static void setAwsSystemCredentials(String accessKey, String
secretKey) {
+ System.setProperty("aws.accessKeyId", accessKey);
+ System.setProperty("aws.secretAccessKey", secretKey);
+
+ }
+
+ public static void clearAwsSystemCredentials() {
+ //system properties has to be cleared after the test
+ System.clearProperty("aws.accessKeyId");
+ System.clearProperty("aws.secretAccessKey");
}
}
diff --git
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/BaseAws2Resource.java
b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/BaseAws2Resource.java
new file mode 100644
index 0000000000..2108ab27f9
--- /dev/null
+++
b/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/BaseAws2Resource.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.test.support.aws2;
+
+import io.quarkus.runtime.ShutdownEvent;
+import jakarta.enterprise.event.Observes;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.jboss.logging.Logger;
+
+/**
+ * Parent for testing resources for aws2 extensions.
+ *
+ * This class adds endpoints to force default credentials to be used +
provides variable useDefaultCredentials
+ * to be used in inherited classes.
+ *
+ * Rest endpoints are expected by test classes.
+ */
+public class BaseAws2Resource {
+
+ private static final Logger LOG = Logger.getLogger(BaseAws2Resource.class);
+
+ private boolean useDefaultCredentials;
+
+ private final String serviceName;
+
+ private boolean clearAwsredentials;
+
+ public BaseAws2Resource(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ @Path("/setUseDefaultCredentialsProvider")
+ @POST
+ public Response setUseDefaultCredentials(boolean
useDefaultCredentialsProvider) throws Exception {
+ this.useDefaultCredentials = useDefaultCredentialsProvider;
+ return Response.ok().build();
+ }
+
+ @Path("/initializeDefaultCredentials")
+ @POST
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response initializeDefaultCredentials(boolean initialize) throws
Exception {
+ if (initialize) {
+ //set flag to clear at the end
+ clearAwsredentials = true;
+ LOG.debug(
+ "Setting both System.properties `aws.secretAccessKey` and
`aws.accessKeyId` to cover defaultCredentialsProviderTest.");
+ //defaultCredentials provider gets the credentials from fixed
location. One of them is system.properties,
+ //therefore to succeed the test, system.properties has to be
initialized with the values from the configuration
+ Aws2Helper.setAwsSystemCredentials(
+
ConfigProvider.getConfig().getValue("camel.component.aws2-" + serviceName +
".access-key", String.class),
+
ConfigProvider.getConfig().getValue("camel.component.aws2-" + serviceName +
".secret-key", String.class));
+
+ } else {
+ LOG.debug("Clearing both System.properties `aws.secretAccessKey`
and `aws.accessKeyId`.");
+ Aws2Helper.clearAwsSystemCredentials();
+ clearAwsredentials = false;
+ }
+
+ return Response.ok().build();
+ }
+
+ /**
+ * Listeners ensures, that system credentials are cleared at the end of
the lifecycle.
+ * Tests are clearing them by itself, this is just a precaution.
+ */
+ void onStop(@Observes ShutdownEvent ev) {
+ if (clearAwsredentials) {
+ Aws2Helper.clearAwsSystemCredentials();
+ }
+ }
+
+ public boolean isUseDefaultCredentials() {
+ return useDefaultCredentials;
+ }
+}
diff --git
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2Client.java
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2Client.java
similarity index 100%
rename from
integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2Client.java
rename to
integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2Client.java
diff --git
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2DefaultCredentialsProviderAvailabilityCondition.java
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2DefaultCredentialsProviderAvailabilityCondition.java
similarity index 62%
rename from
integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2DefaultCredentialsProviderAvailabilityCondition.java
rename to
integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2DefaultCredentialsProviderAvailabilityCondition.java
index 6b2787ecc2..b96d22b978 100644
---
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2DefaultCredentialsProviderAvailabilityCondition.java
+++
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2DefaultCredentialsProviderAvailabilityCondition.java
@@ -16,33 +16,35 @@
*/
package org.apache.camel.quarkus.test.support.aws2;
+import java.util.stream.StreamSupport;
+
import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils;
+import org.eclipse.microprofile.config.ConfigProvider;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtensionContext;
-import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
-import software.amazon.awssdk.core.exception.SdkClientException;
public class Aws2DefaultCredentialsProviderAvailabilityCondition implements
ExecutionCondition {
- public static final String UNABLE_TO_LOAD_CREDENTIALS_MSG = "Unable to
load credentials";
-
@Override
public ConditionEvaluationResult
evaluateExecutionCondition(ExtensionContext context) {
if (!MockBackendUtils.startMockBackend(false)) {
return ConditionEvaluationResult.disabled("Test can be executed
only with mock backend.");
}
- try {
- DefaultCredentialsProvider.create().resolveCredentials();
- } catch (Exception e) {
- //if message starts with "Unable to load credentials", allow
testing
- if (e instanceof SdkClientException && e.getMessage() != null
- &&
e.getMessage().startsWith(UNABLE_TO_LOAD_CREDENTIALS_MSG)) {
- return ConditionEvaluationResult
- .enabled("DefaultCredentialsProvider is NOT defined in
the system, Testing can proceed.");
- }
+
+ //test can not be used with quarkus-client (it is not possible to
change configuration of quarkus client)
+ if (StreamSupport.stream(
+ ConfigProvider.getConfig().getPropertyNames().spliterator(),
false)
+ .anyMatch(n ->
n.matches("quarkus.(dynamodb|s3|ses|sqs|sns).sync-client.type"))) {
+ return ConditionEvaluationResult.disabled("Test can not be
executed quarkus aws client configuration detected.");
+ }
+
+ if (Aws2Helper.isDefaultCredentialsProviderDefinedOnSystem()) {
+ return
ConditionEvaluationResult.disabled("DefaultCredentialsProvider is already
defined in the system.");
}
- return ConditionEvaluationResult.disabled("DefaultCredentialsProvider
is already defined in the system.");
+
+ return ConditionEvaluationResult
+ .enabled("DefaultCredentialsProvider is NOT defined in the
system, Testing can proceed.");
}
}
diff --git
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2LocalStack.java
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2LocalStack.java
similarity index 100%
rename from
integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2LocalStack.java
rename to
integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2LocalStack.java
diff --git
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvContext.java
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvContext.java
similarity index 100%
rename from
integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvContext.java
rename to
integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvContext.java
diff --git
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvCustomizer.java
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvCustomizer.java
similarity index 100%
rename from
integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvCustomizer.java
rename to
integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestEnvCustomizer.java
diff --git
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java
similarity index 99%
rename from
integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java
rename to
integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java
index e345718fe2..43b9582022 100644
---
a/integration-tests-support/aws2/src/main/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java
+++
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/Aws2TestResource.java
@@ -137,7 +137,6 @@ public final class Aws2TestResource implements
QuarkusTestResourceLifecycleManag
}
c = c.getSuperclass();
}
-
}
}
diff --git
a/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/BaseAWs2TestSupport.java
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/BaseAWs2TestSupport.java
new file mode 100644
index 0000000000..67ee53f28b
--- /dev/null
+++
b/integration-tests-support/aws2/src/test/java/org/apache/camel/quarkus/test/support/aws2/BaseAWs2TestSupport.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.test.support.aws2;
+
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+/**
+ * Parent for aws test classes which should cover default credentials test
case.
+ * Parent adds two test methods {@link
#successfulDefaultCredentialsProviderTest()} and
+ * {@link #failingDefaultCredentialsProviderTest()}
+ *
+ * Test expects that test resource extends {@link BaseAws2Resource}.
+ *
+ */
+public abstract class BaseAWs2TestSupport {
+
+ //Rest path to connect to rest resource. Path differs for different aws2
extensions (like "/aws2-ddb" or "/aws2-s3")
+ private final String restPath;
+
+ public BaseAWs2TestSupport(String restPath) {
+ this.restPath = restPath;
+ }
+
+ /**
+ * Testing method used for {@link
#successfulDefaultCredentialsProviderTest()} and
+ * {@link #failingDefaultCredentialsProviderTest()}.
+ *
+ * This method is called twice.
+ * 1 - Credentials are not set, therefore this method should fail.
+ * 2 - Credentials are set, there this method should succeed.
+ *
+ * Returns true if test passes, fa;se otherwise.
+ */
+ public abstract void testMethodForDefaultCredentialsProvider();
+
+ //test can be executed only if mock backend is used and no
defaultCredentialsProvider is defined in the system
+ @ExtendWith(Aws2DefaultCredentialsProviderAvailabilityCondition.class)
+ @Test
+ public void successfulDefaultCredentialsProviderTest() {
+ try {
+ RestAssured.given()
+ .body(true)
+ .post(restPath + "/setUseDefaultCredentialsProvider")
+ .then()
+ .statusCode(200);
+
+ RestAssured.given()
+ .body(true)
+ .post(restPath + "/initializeDefaultCredentials")
+ .then()
+ .statusCode(200);
+
+ //should succeed
+ testMethodForDefaultCredentialsProvider();
+
+ } finally {
+ RestAssured.given()
+ .body(false)
+ .post(restPath + "/initializeDefaultCredentials")
+ .then()
+ .statusCode(200);
+
+ RestAssured.given()
+ .body(false)
+ .post(restPath + "/setUseDefaultCredentialsProvider")
+ .then()
+ .statusCode(200);
+ }
+ }
+
+ //test can be executed only if mock backend is used and no
defaultCredentialsprovider is defined in the system
+ @ExtendWith(Aws2DefaultCredentialsProviderAvailabilityCondition.class)
+ @Test
+ public void failingDefaultCredentialsProviderTest() {
+ RestAssured.given()
+ .body(true)
+ .post(restPath + "/setUseDefaultCredentialsProvider")
+ .then()
+ .statusCode(200);
+
+ // should fail without credentials for aws
+ Assertions.assertThrows(AssertionError.class, () ->
testMethodForDefaultCredentialsProvider());
+
+ RestAssured.given()
+ .body(false)
+ .post(restPath + "/setUseDefaultCredentialsProvider")
+ .then()
+ .statusCode(200);
+ }
+
+}
diff --git a/integration-tests/aws2-grouped/pom.xml
b/integration-tests/aws2-grouped/pom.xml
index 6363068d0f..16ba72fd6d 100644
--- a/integration-tests/aws2-grouped/pom.xml
+++ b/integration-tests/aws2-grouped/pom.xml
@@ -97,6 +97,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/integration-tests/aws2-quarkus-client-grouped/pom.xml
b/integration-tests/aws2-quarkus-client-grouped/pom.xml
index be41b3929a..e22c0440ea 100644
--- a/integration-tests/aws2-quarkus-client-grouped/pom.xml
+++ b/integration-tests/aws2-quarkus-client-grouped/pom.xml
@@ -97,6 +97,11 @@
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml
index 9579e44c0f..5c50eaa325 100644
--- a/poms/bom-test/pom.xml
+++ b/poms/bom-test/pom.xml
@@ -83,6 +83,38 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
<version>${camel-quarkus.version}</version>
+ <exclusions>
+ <exclusion>
+
<artifactId>camel-quarkus-integration-test-support</artifactId>
+ <groupId>org.apache.camel.quarkus</groupId>
+ </exclusion>
+ <exclusion>
+
<artifactId>camel-quarkus-integration-test-support-mock-backend</artifactId>
+ <groupId>org.apache.camel.quarkus</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>localstack</artifactId>
+ <groupId>org.testcontainers</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>quarkus-junit4-mock</artifactId>
+ <groupId>io.quarkus</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>rest-assured</artifactId>
+ <groupId>io.rest-assured</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>aws-java-sdk-core</artifactId>
+ <groupId>com.amazonaws</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
+ <version>${camel-quarkus.version}</version>
+ <type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>