diff --git a/src/main/java/com/github/dockerjava/core/DockerClientConfig.java b/src/main/java/com/github/dockerjava/core/DockerClientConfig.java index 038c43cae..a03d6e086 100644 --- a/src/main/java/com/github/dockerjava/core/DockerClientConfig.java +++ b/src/main/java/com/github/dockerjava/core/DockerClientConfig.java @@ -13,7 +13,6 @@ import java.util.Properties; import java.util.Set; -import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; @@ -418,8 +417,8 @@ public final DockerClientConfigBuilder withDockerConfig(String dockerConfig) { } public final DockerClientConfigBuilder withDockerTlsVerify(String dockerTlsVerify) { - this.dockerTlsVerify = BooleanUtils.toBoolean(dockerTlsVerify.trim()) - || BooleanUtils.toBoolean(dockerTlsVerify.trim(), "1", "0"); + String trimmed = dockerTlsVerify.trim(); + this.dockerTlsVerify = "true".equalsIgnoreCase(trimmed) || "1".equals(trimmed); return this; } diff --git a/src/test/java/com/github/dockerjava/core/DockerClientConfigTest.java b/src/test/java/com/github/dockerjava/core/DockerClientConfigTest.java index e87254b88..a363e12ec 100644 --- a/src/test/java/com/github/dockerjava/core/DockerClientConfigTest.java +++ b/src/test/java/com/github/dockerjava/core/DockerClientConfigTest.java @@ -2,8 +2,12 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.core.Is.is; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import java.lang.reflect.Field; import java.net.URI; import java.util.Collections; import java.util.HashMap; @@ -176,4 +180,33 @@ public void testUnixHostScheme() throws Exception { new DockerClientConfig(URI.create("unix://foo"), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", null, false); } + + @Test + public void withDockerTlsVerify() throws Exception { + DockerClientConfig.DockerClientConfigBuilder builder = new DockerClientConfig.DockerClientConfigBuilder(); + Field field = builder.getClass().getDeclaredField("dockerTlsVerify"); + field.setAccessible(true); + + builder.withDockerTlsVerify(""); + assertThat(field.getBoolean(builder), is(false)); + + builder.withDockerTlsVerify("false"); + assertThat(field.getBoolean(builder), is(false)); + + builder.withDockerTlsVerify("FALSE"); + assertThat(field.getBoolean(builder), is(false)); + + builder.withDockerTlsVerify("true"); + assertThat(field.getBoolean(builder), is(true)); + + builder.withDockerTlsVerify("TRUE"); + assertThat(field.getBoolean(builder), is(true)); + + builder.withDockerTlsVerify("0"); + assertThat(field.getBoolean(builder), is(false)); + + builder.withDockerTlsVerify("1"); + assertThat(field.getBoolean(builder), is(true)); + } + }