GeezerVison is showing github.com — Relax protocol check in `DefaultDockerClientConfig` (#1818) · ConnorLinfoot/docker-java@ddfaf56
File treeExpand file treeCollapse file tree Open diff view settings docker-java-core/src/main/java/com/github/dockerjava/core docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5 docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp docker-java/src/test/java/com/github/dockerjava/core
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java +1-9Lines changed: 1 addition & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | import java.net.URI; | 23 | 23 | import java.util.HashSet; | 24 | 24 | import java.util.Map; | 25 | | -import java.util.Objects; | 26 | 25 | import java.util.Properties; | 27 | 26 | import java.util.Set; | 28 | 27 |
| @@ -106,14 +105,7 @@ private URI checkDockerHostScheme(URI dockerHost) { | 106 | 105 | if (dockerHost == null) { | 107 | 106 | throw new DockerClientException("'dockerHost' is null"); | 108 | 107 | } | 109 | | - switch (Objects.toString(dockerHost.getScheme())) { | 110 | | - case "tcp": | 111 | | - case "unix": | 112 | | - case "npipe": | 113 | | - return dockerHost; | 114 | | - default: | 115 | | - throw new DockerClientException("Unsupported protocol scheme found: '" + dockerHost); | 116 | | - } | | 108 | + return dockerHost; | 117 | 109 | } | 118 | 110 |
| 119 | 111 | private static Properties loadIncludedDockerProperties(Properties systemProperties) { | |
Collapse file Copy file name to clipboardExpand all lines: docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -80,8 +80,7 @@ protected ApacheDockerHttpClientImpl( | 80 | 80 | ); | 81 | 81 | break; | 82 | 82 | default: | 83 | | - pathPrefix = ""; | 84 | | - host = HttpHost.create(dockerHost); | | 83 | + throw new IllegalArgumentException("Unsupported protocol scheme: " + dockerHost); | 85 | 84 | } | 86 | 85 |
| 87 | 86 | PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager( | |
Collapse file Copy file name to clipboardExpand all lines: docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp/OkDockerHttpClient.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -175,7 +175,7 @@ private OkDockerHttpClient( | 175 | 175 | } | 176 | 176 | break; | 177 | 177 | default: | 178 | | - baseUrlBuilder = HttpUrl.get(dockerHost.toString()).newBuilder(); | | 178 | + throw new IllegalArgumentException("Unsupported protocol scheme: " + dockerHost); | 179 | 179 | } | 180 | 180 | baseUrl = baseUrlBuilder.build(); | 181 | 181 | } | |
Collapse file Copy file name to clipboardExpand all lines: docker-java/src/test/java/com/github/dockerjava/core/DefaultDockerClientConfigTest.java +5-21Lines changed: 5 additions & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | import java.util.HashMap; | 16 | 16 | import java.util.Map; | 17 | 17 | import java.util.Properties; | | 18 | +import java.util.UUID; | 18 | 19 |
| 19 | 20 | import static org.hamcrest.MatcherAssert.assertThat; | 20 | 21 | import static org.hamcrest.Matchers.equalTo; | @@ -172,28 +173,11 @@ public void testTlsVerifyAndCertPath() throws Exception { | 172 | 173 | new LocalDirectorySSLConfig(dockerCertPath())); | 173 | 174 | } | 174 | 175 |
| 175 | | - @Test(expected = DockerClientException.class) | 176 | | - public void testWrongHostScheme() throws Exception { | 177 | | - new DefaultDockerClientConfig(URI.create("http://foo"), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | 178 | | - null); | 179 | | - } | 180 | | - | 181 | 176 | @Test() | 182 | | - public void testTcpHostScheme() throws Exception { | 183 | | - new DefaultDockerClientConfig(URI.create("tcp://foo"), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | 184 | | - null); | 185 | | - } | 186 | | - | 187 | | - @Test() | 188 | | - public void testUnixHostScheme() throws Exception { | 189 | | - new DefaultDockerClientConfig(URI.create("unix://foo"), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | 190 | | - null); | 191 | | - } | 192 | | - | 193 | | - @Test() | 194 | | - public void testNpipeHostScheme() throws Exception { | 195 | | - new DefaultDockerClientConfig(URI.create("npipe://foo"), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | 196 | | - null); | | 177 | + public void testAnyHostScheme() throws Exception { | | 178 | + URI dockerHost = URI.create(UUID.randomUUID().toString().replace("-", "") + "://foo"); | | 179 | + new DefaultDockerClientConfig(dockerHost, "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | | 180 | + null); | 197 | 181 | } | 198 | 182 |
| 199 | 183 | @Test | |
|