Skip to content

Commit

Permalink
Revert "Enable Aws2TestEnvContext to handle setting up Quarkus AWS co…
Browse files Browse the repository at this point in the history
…nfiguration properties"

This reverts commit cb4f00f.
  • Loading branch information
aldettinger authored and ppalaga committed Oct 6, 2021
1 parent e8affab commit 3e01890
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.stream.Stream;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.ResourceArg;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
Expand All @@ -41,9 +40,7 @@
import static org.hamcrest.CoreMatchers.is;

@QuarkusTest
@QuarkusTestResource(value = Aws2TestResource.class, initArgs = {
@ResourceArg(name = "awsQuarkusClientTest", value = "true")
})
@QuarkusTestResource(Aws2TestResource.class)
class Aws2DdbQuarkusClientTest {

private static final Logger LOG = Logger.getLogger(Aws2DdbQuarkusClientTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -42,7 +44,7 @@ public class Aws2DdbTestEnvCustomizer implements Aws2TestEnvCustomizer {

@Override
public Service[] localstackServices() {
return new Service[] { Service.DYNAMODB };
return new Service[] { Service.DYNAMODB, Service.DYNAMODB_STREAMS };
}

@Override
Expand Down Expand Up @@ -81,6 +83,28 @@ public void customize(Aws2TestEnvContext envContext) {
envContext.closeable(() -> client.deleteTable(DeleteTableRequest.builder().tableName(table).build()));
}
}

Map<String, String> envContextProperties = envContext.getProperies();
String accessKey = envContextProperties.get("camel.component.aws2-ddb.access-key");
String secretKey = envContextProperties.get("camel.component.aws2-ddb.secret-key");
String region = envContextProperties.get("camel.component.aws2-ddb.region");

envContext.property("quarkus.dynamodb.aws.credentials.static-provider.access-key-id", accessKey);
envContext.property("quarkus.dynamodb.aws.credentials.static-provider.secret-access-key", secretKey);
envContext.property("quarkus.dynamodb.aws.region", region);
envContext.property("quarkus.dynamodb.aws.credentials.type", "static");

// Propagate localstack environment config to Quarkus AWS if required
Optional<String> overrideEndpoint = envContextProperties
.keySet()
.stream()
.filter(key -> key.endsWith("uri-endpoint-override"))
.findFirst();

if (overrideEndpoint.isPresent()) {
String endpoint = envContextProperties.get(overrideEndpoint.get());
envContext.property("quarkus.dynamodb.endpoint-override", endpoint);
}
}

private CreateTableRequest.Builder createTableRequest(String tableName, String keyColumn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
Expand All @@ -49,20 +48,13 @@
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.aws2.s3.AWS2S3Constants;
import org.apache.camel.component.aws2.s3.AWS2S3Operations;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.core.ResponseInputStream;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.S3ClientBuilder;
import software.amazon.awssdk.services.s3.model.Bucket;
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
import software.amazon.awssdk.services.s3.model.NoSuchBucketException;
import software.amazon.awssdk.services.s3.model.S3Object;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;

@Path("/aws2")
@ApplicationScoped
Expand All @@ -80,22 +72,6 @@ public class Aws2S3Resource {
@ConfigProperty(name = "aws-s3.bucket-name")
String bucketName;

@javax.enterprise.inject.Produces
@Named
public S3Presigner s3Presigner(S3ClientBuilder clientBuilder) {
// createDownloadLink operations require the presigner
// This could be simplified via https://github.com/quarkusio/quarkus/issues/13611
Config config = ConfigProvider.getConfig();
String accessKey = config.getValue("quarkus.s3.aws.credentials.static-provider.access-key-id", String.class);
String secretKey = config.getValue("quarkus.s3.aws.credentials.static-provider.secret-access-key", String.class);
String region = config.getValue("quarkus.s3.aws.region", String.class);

return S3Presigner.builder().credentialsProvider(StaticCredentialsProvider.create(
AwsBasicCredentials.create(accessKey, secretKey)))
.region(Region.of(region))
.build();
}

@Path("s3/object/{key}")
@POST
@Consumes(MediaType.TEXT_PLAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
## limitations under the License.
## ---------------------------------------------------------------------------
#
# Camel :: AWS2 options
#
camel.component.aws2-s3.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-s3.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-s3.region=${AWS_REGION:us-east-1}
#
# Quarkus :: S3 Client options
#
quarkus.s3.sync-client.type=apache
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.stream.Stream;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.ResourceArg;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
Expand All @@ -33,9 +32,7 @@
import static org.junit.Assert.assertEquals;

@QuarkusTest
@QuarkusTestResource(value = Aws2TestResource.class, initArgs = {
@ResourceArg(name = "awsQuarkusClientTest", value = "true")
})
@QuarkusTestResource(Aws2TestResource.class)
class Aws2S3QuarkusClientTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.apache.camel.quarkus.component.aws2.s3.it;

import java.util.Locale;
import java.util.Map;
import java.util.Optional;

import org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvContext;
import org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer;
Expand All @@ -41,5 +43,27 @@ public void customize(Aws2TestEnvContext envContext) {
s3Client.createBucket(CreateBucketRequest.builder().bucket(bucketName).build());
envContext.property("aws-s3.bucket-name", bucketName);
envContext.closeable(() -> s3Client.deleteBucket(DeleteBucketRequest.builder().bucket(bucketName).build()));

Map<String, String> envContextProperties = envContext.getProperies();
String accessKey = envContextProperties.get("camel.component.aws2-s3.access-key");
String secretKey = envContextProperties.get("camel.component.aws2-s3.secret-key");
String region = envContextProperties.get("camel.component.aws2-s3.region");

envContext.property("quarkus.s3.aws.credentials.static-provider.access-key-id", accessKey);
envContext.property("quarkus.s3.aws.credentials.static-provider.secret-access-key", secretKey);
envContext.property("quarkus.s3.aws.region", region);
envContext.property("quarkus.s3.aws.credentials.type", "static");

// Propagate localstack environment config to Quarkus AWS if required
Optional<String> overrideEndpoint = envContextProperties
.keySet()
.stream()
.filter(key -> key.endsWith("uri-endpoint-override"))
.findFirst();

if (overrideEndpoint.isPresent()) {
String endpoint = envContextProperties.get(overrideEndpoint.get());
envContext.property("quarkus.s3.endpoint-override", endpoint);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------

camel.component.aws2-cw.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-cw.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-cw.region=${AWS_REGION:us-east-1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------

camel.component.aws2-ddb.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-ddb.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-ddb.region=${AWS_REGION:us-east-1}

camel.component.aws2-ddbstream.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-ddbstream.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-ddbstream.region=${AWS_REGION:us-east-1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------

camel.component.aws2-kinesis.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-kinesis.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-kinesis.region=${AWS_REGION:us-east-1}

camel.component.aws2-kinesis-firehose.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-kinesis-firehose.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-kinesis-firehose.region=${AWS_REGION:us-east-1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------

camel.component.aws2-lambda.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-lambda.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-lambda.region=${AWS_REGION:us-east-1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------
#
# Camel :: AWS2 options
#
camel.component.aws2-s3.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-s3.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-s3.region=${AWS_REGION:us-east-1}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------

camel.component.aws2-ses.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-ses.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-ses.region=${AWS_REGION:us-east-1}

mailslurp.api.key=${MAILSLURP_API_KEY}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------

camel.component.aws2-sns.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-sns.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-sns.region=${AWS_REGION:us-east-1}

camel.component.aws2-sqs.access-key=${AWS_ACCESS_KEY}
camel.component.aws2-sqs.secret-key=${AWS_SECRET_KEY}
camel.component.aws2-sqs.region=${AWS_REGION:us-east-1}

This file was deleted.

Loading

0 comments on commit 3e01890

Please sign in to comment.