Skip to content

Commit 0319b14

Browse files
committed
fix client config test to handle different develeoper environments
1 parent bce65f0 commit 0319b14

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
target
1+
.git/
2+
target/

src/test/java/com/github/dockerjava/core/DockerClientConfigTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ public void environmentDockerHostWithInvalidTlsVerify() throws Exception {
8484
// given docker host in env
8585
Map<String, String> env = new HashMap<String, String>(System.getenv());
8686
env.put("DOCKER_HOST", "tcp://bar:8768");
87-
// and it looks to be SSL enabled
87+
// and it looks to be SSL disabled
88+
env.remove("DOCKER_CERT_PATH");
89+
// and it has an invalid TLS_VERIFY value
8890
env.put("DOCKER_TLS_VERIFY", "any value different from '1'");
8991

9092
// when you build a config
@@ -94,6 +96,24 @@ public void environmentDockerHostWithInvalidTlsVerify() throws Exception {
9496
assertEquals(config.getUri(), URI.create("http://bar:8768"));
9597
}
9698

99+
@Test
100+
public void environmentDockerHostWithInvalidTlsVerifyButWithCertPath() throws Exception {
101+
102+
// given docker host in env
103+
Map<String, String> env = new HashMap<String, String>(System.getenv());
104+
env.put("DOCKER_HOST", "tcp://bar:8768");
105+
// and it looks to be SSL enabled
106+
env.put("DOCKER_CERT_PATH", "any value");
107+
// and it has an invalid TLS_VERIFY value
108+
env.put("DOCKER_TLS_VERIFY", "any value different from '1'");
109+
110+
// when you build a config
111+
DockerClientConfig config = buildConfig(env, new Properties());
112+
113+
// then the URL is that value with "tcp" changed to "https"
114+
assertEquals(config.getUri(), URI.create("https://bar:8768"));
115+
}
116+
97117
@Test
98118
public void environment() throws Exception {
99119

0 commit comments

Comments
 (0)