Update integration tests for main branch
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -32,6 +32,7 @@
|
||||
<google-api-services-iam.version>v1-rev20201112-1.30.10</google-api-services-iam.version>
|
||||
<testcontainers.version>1.17.3</testcontainers.version>
|
||||
<wiremock.version>2.31.0</wiremock.version>
|
||||
<spring-cloud-aws.version>3.0.0-SNAPSHOT</spring-cloud-aws.version>
|
||||
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError>
|
||||
<maven-checkstyle-plugin.failsOnViolation>true
|
||||
</maven-checkstyle-plugin.failsOnViolation>
|
||||
@@ -109,6 +110,13 @@
|
||||
<artifactId>wiremock-jre8-standalone</artifactId>
|
||||
<version>${wiremock.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.awspring.cloud</groupId>
|
||||
<artifactId>spring-cloud-aws-dependencies</artifactId>
|
||||
<version>${spring-cloud-aws.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<profiles>
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
<jgit.version>6.4.0.202211300538-r</jgit.version>
|
||||
<spring-vault.version>3.0.0</spring-vault.version>
|
||||
<spring-credhub.version>2.1.1.RELEASE</spring-credhub.version>
|
||||
<spring-cloud-aws.version>2.4.4</spring-cloud-aws.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
@@ -72,11 +71,6 @@
|
||||
<artifactId>org.eclipse.jgit.ssh.apache</artifactId>
|
||||
<version>${jgit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.awspring.cloud</groupId>
|
||||
<artifactId>spring-cloud-aws-context</artifactId>
|
||||
<version>${spring-cloud-aws.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.tmatesoft.svnkit</groupId>
|
||||
<artifactId>svnkit</artifactId>
|
||||
|
||||
@@ -18,10 +18,7 @@ package org.springframework.cloud.config.server;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.amazonaws.client.builder.AwsClientBuilder;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
||||
import io.awspring.cloud.context.config.annotation.ContextResourceLoaderConfiguration;
|
||||
import io.awspring.cloud.autoconfigure.s3.S3AutoConfiguration;
|
||||
import org.json.JSONException;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -30,13 +27,15 @@ import org.testcontainers.containers.localstack.LocalStackContainer;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
import org.testcontainers.utility.DockerImageName;
|
||||
import software.amazon.awssdk.core.sync.RequestBody;
|
||||
import software.amazon.awssdk.services.s3.S3Client;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.test.TestConfigServerApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.util.SocketUtils;
|
||||
import org.springframework.test.util.TestSocketUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -47,9 +46,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@Testcontainers
|
||||
public class AwsS3IntegrationTests {
|
||||
|
||||
private static final int configServerPort = SocketUtils.findAvailableTcpPort();
|
||||
private static final int configServerPort = TestSocketUtils.findAvailableTcpPort();
|
||||
|
||||
private static AmazonS3 s3Client;
|
||||
private static S3Client s3Client;
|
||||
|
||||
private static ConfigurableApplicationContext server;
|
||||
|
||||
@@ -60,29 +59,27 @@ public class AwsS3IntegrationTests {
|
||||
|
||||
@BeforeAll
|
||||
public static void startConfigServer() throws IOException, InterruptedException, JSONException {
|
||||
server = SpringApplication.run(
|
||||
new Class[] { TestConfigServerApplication.class, ContextResourceLoaderConfiguration.class },
|
||||
server = SpringApplication.run(new Class[] { TestConfigServerApplication.class, S3AutoConfiguration.class },
|
||||
new String[] { "--spring.config.name=server", "--spring.profiles.active=awss3",
|
||||
"--server.port=" + configServerPort,
|
||||
"--spring.cloud.config.server.awss3.endpoint="
|
||||
+ localstack.getEndpointOverride(LocalStackContainer.Service.S3).toString(),
|
||||
"--spring.cloud.config.server.awss3.bucket=test-bucket",
|
||||
"--spring.cloud.config.server.awss3.region=" + localstack.getRegion(),
|
||||
"--cloud.aws.s3.endpoint="
|
||||
"--spring.cloud.aws.endpoint="
|
||||
+ localstack.getEndpointOverride(LocalStackContainer.Service.S3).toString(),
|
||||
"--cloud.aws.credentials.access-key=" + localstack.getAccessKey(),
|
||||
"--cloud.aws.credentials.secret-key=" + localstack.getSecretKey(),
|
||||
"--cloud.aws.region.static=" + localstack.getRegion() });
|
||||
"--spring.cloud.aws.credentials.access-key=" + localstack.getAccessKey(),
|
||||
"--spring.cloud.aws.credentials.secret-key=" + localstack.getSecretKey(),
|
||||
"--spring.cloud.aws.region.static=" + localstack.getRegion() });
|
||||
|
||||
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
|
||||
AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(
|
||||
localstack.getEndpointOverride(LocalStackContainer.Service.S3).toString(), "us-east-1");
|
||||
builder.withEndpointConfiguration(endpointConfiguration);
|
||||
s3Client = builder.build();
|
||||
s3Client.createBucket("test-bucket");
|
||||
s3Client.putObject("test-bucket", "data.txt", "this is a test");
|
||||
s3Client.putObject("test-bucket", "main/data.txt", "this is a test in main");
|
||||
s3Client.putObject("test-bucket", "application.properties", "foo=1");
|
||||
s3Client = server.getBean(S3Client.class);
|
||||
s3Client.createBucket((request) -> request.bucket("test-bucket"));
|
||||
s3Client.putObject((request) -> request.bucket("test-bucket").key("data.txt"),
|
||||
RequestBody.fromString("this is a test"));
|
||||
s3Client.putObject((request) -> request.bucket("test-bucket").key("main/data.txt"),
|
||||
RequestBody.fromString("this is a test in main"));
|
||||
s3Client.putObject((request) -> request.bucket("test-bucket").key("application.properties"),
|
||||
RequestBody.fromString("foo=1"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class AwsParameterStoreEnvironmentRepositoryTests {
|
||||
|
||||
@Container
|
||||
private static final LocalStackContainer localstack = new LocalStackContainer(
|
||||
DockerImageName.parse("localstack/localstack:0.14.2")).withServices(SSM);
|
||||
DockerImageName.parse("localstack/localstack:1.3.1")).withServices(SSM);
|
||||
|
||||
private final StaticCredentialsProvider staticCredentialsProvider = StaticCredentialsProvider
|
||||
.create(AwsBasicCredentials.create(localstack.getAccessKey(), localstack.getSecretKey()));
|
||||
|
||||
@@ -58,7 +58,7 @@ public class AwsS3EnvironmentRepositoryTests {
|
||||
|
||||
@Container
|
||||
private static final LocalStackContainer localstack = new LocalStackContainer(
|
||||
DockerImageName.parse("localstack/localstack:0.14.2")).withServices(S3);
|
||||
DockerImageName.parse("localstack/localstack:1.3.1")).withServices(S3);
|
||||
|
||||
private final ConfigServerProperties server = new ConfigServerProperties();
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class AwsSecretsManagerEnvironmentRepositoryTests {
|
||||
|
||||
@Container
|
||||
private static final LocalStackContainer localstack = new LocalStackContainer(
|
||||
DockerImageName.parse("localstack/localstack:0.14.2")).withServices(SECRETSMANAGER);
|
||||
DockerImageName.parse("localstack/localstack:1.3.1")).withServices(SECRETSMANAGER);
|
||||
|
||||
private static final Log log = LogFactory.getLog(AwsSecretsManagerEnvironmentRepository.class);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user