Add SSL support to Docker Compose and Testcontainers infrastructure
See gh-41137 Co-authored-by: Phillip Webb <phil.webb@broadcom.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,7 +59,7 @@ class ConnectionDetailsRegistrarTests {
|
||||
this.container = mock(PostgreSQLContainer.class);
|
||||
this.annotation = MergedAnnotation.of(ServiceConnection.class, Map.of("name", "", "type", new Class<?>[0]));
|
||||
this.source = new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, null,
|
||||
this.annotation, () -> this.container);
|
||||
this.annotation, () -> this.container, null, null);
|
||||
this.factories = mock(ConnectionDetailsFactories.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ class ContainerConnectionDetailsFactoryTests {
|
||||
this.annotation = MergedAnnotation.of(ServiceConnection.class,
|
||||
Map.of("name", "myname", "type", new Class<?>[0]));
|
||||
this.source = new ContainerConnectionSource<>(this.beanNameSuffix, this.origin, PostgreSQLContainer.class,
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container);
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container, null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,7 +109,8 @@ class ContainerConnectionDetailsFactoryTests {
|
||||
void getConnectionDetailsWhenContainerTypeDoesNotMatchReturnsNull() {
|
||||
ElasticsearchContainer container = mock(ElasticsearchContainer.class);
|
||||
ContainerConnectionSource<?> source = new ContainerConnectionSource<>(this.beanNameSuffix, this.origin,
|
||||
ElasticsearchContainer.class, container.getDockerImageName(), this.annotation, () -> container);
|
||||
ElasticsearchContainer.class, container.getDockerImageName(), this.annotation, () -> container, null,
|
||||
null);
|
||||
TestContainerConnectionDetailsFactory factory = new TestContainerConnectionDetailsFactory();
|
||||
ConnectionDetails connectionDetails = getConnectionDetails(factory, source);
|
||||
assertThat(connectionDetails).isNull();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,7 +60,7 @@ class ContainerConnectionSourceTests {
|
||||
given(this.container.getDockerImageName()).willReturn("postgres");
|
||||
this.annotation = MergedAnnotation.of(ServiceConnection.class, Map.of("name", "", "type", new Class<?>[0]));
|
||||
this.source = new ContainerConnectionSource<>(this.beanNameSuffix, this.origin, PostgreSQLContainer.class,
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container);
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container, null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -180,14 +180,14 @@ class ContainerConnectionSourceTests {
|
||||
private void setupSourceAnnotatedWithName(String name) {
|
||||
this.annotation = MergedAnnotation.of(ServiceConnection.class, Map.of("name", name, "type", new Class<?>[0]));
|
||||
this.source = new ContainerConnectionSource<>(this.beanNameSuffix, this.origin, PostgreSQLContainer.class,
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container);
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container, null, null);
|
||||
}
|
||||
|
||||
private void setupSourceAnnotatedWithType(Class<?> type) {
|
||||
this.annotation = MergedAnnotation.of(ServiceConnection.class,
|
||||
Map.of("name", "", "type", new Class<?>[] { type }));
|
||||
this.source = new ContainerConnectionSource<>(this.beanNameSuffix, this.origin, PostgreSQLContainer.class,
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container);
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container, null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,7 +66,7 @@ class ServiceConnectionContextCustomizerTests {
|
||||
this.annotation = MergedAnnotation.of(ServiceConnection.class,
|
||||
Map.of("name", "myname", "type", new Class<?>[0]));
|
||||
this.source = new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class,
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container);
|
||||
this.container.getDockerImageName(), this.annotation, () -> this.container, null, null);
|
||||
this.factories = mock(ConnectionDetailsFactories.class);
|
||||
}
|
||||
|
||||
@@ -103,37 +103,37 @@ class ServiceConnectionContextCustomizerTests {
|
||||
// Connection Names
|
||||
ServiceConnectionContextCustomizer n1 = new ServiceConnectionContextCustomizer(
|
||||
List.of(new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, "name",
|
||||
annotation1, () -> container1)));
|
||||
annotation1, () -> container1, null, null)));
|
||||
ServiceConnectionContextCustomizer n2 = new ServiceConnectionContextCustomizer(
|
||||
List.of(new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, "name",
|
||||
annotation1, () -> container1)));
|
||||
annotation1, () -> container1, null, null)));
|
||||
ServiceConnectionContextCustomizer n3 = new ServiceConnectionContextCustomizer(
|
||||
List.of(new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, "namex",
|
||||
annotation1, () -> container1)));
|
||||
annotation1, () -> container1, null, null)));
|
||||
assertThat(n1.hashCode()).isEqualTo(n2.hashCode()).isNotEqualTo(n3.hashCode());
|
||||
assertThat(n1).isEqualTo(n2).isNotEqualTo(n3);
|
||||
// Connection Details Types
|
||||
ServiceConnectionContextCustomizer t1 = new ServiceConnectionContextCustomizer(
|
||||
List.of(new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, "name",
|
||||
annotation1, () -> container1)));
|
||||
annotation1, () -> container1, null, null)));
|
||||
ServiceConnectionContextCustomizer t2 = new ServiceConnectionContextCustomizer(
|
||||
List.of(new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, "name",
|
||||
annotation2, () -> container1)));
|
||||
annotation2, () -> container1, null, null)));
|
||||
ServiceConnectionContextCustomizer t3 = new ServiceConnectionContextCustomizer(
|
||||
List.of(new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, "name",
|
||||
annotation3, () -> container1)));
|
||||
annotation3, () -> container1, null, null)));
|
||||
assertThat(t1.hashCode()).isEqualTo(t2.hashCode()).isNotEqualTo(t3.hashCode());
|
||||
assertThat(t1).isEqualTo(t2).isNotEqualTo(t3);
|
||||
// Container
|
||||
ServiceConnectionContextCustomizer c1 = new ServiceConnectionContextCustomizer(
|
||||
List.of(new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, "name",
|
||||
annotation1, () -> container1)));
|
||||
annotation1, () -> container1, null, null)));
|
||||
ServiceConnectionContextCustomizer c2 = new ServiceConnectionContextCustomizer(
|
||||
List.of(new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, "name",
|
||||
annotation1, () -> container1)));
|
||||
annotation1, () -> container1, null, null)));
|
||||
ServiceConnectionContextCustomizer c3 = new ServiceConnectionContextCustomizer(
|
||||
List.of(new ContainerConnectionSource<>("test", this.origin, PostgreSQLContainer.class, "name",
|
||||
annotation1, () -> container2)));
|
||||
annotation1, () -> container2, null, null)));
|
||||
assertThat(c1.hashCode()).isEqualTo(c2.hashCode()).isNotEqualTo(c3.hashCode());
|
||||
assertThat(c1).isEqualTo(c2).isNotEqualTo(c3);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ public final class TestContainerConnectionSource {
|
||||
Class<C> containerType, String containerImageName, MergedAnnotation<ServiceConnection> annotation,
|
||||
Supplier<C> containerSupplier) {
|
||||
return new ContainerConnectionSource<>(beanNameSuffix, origin, containerType, containerImageName, annotation,
|
||||
containerSupplier);
|
||||
containerSupplier, null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user