File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
TLS-Server-Scanner/src/test/java/de/rub/nds/tlsscanner/serverscanner/test Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 88 */
99package de .rub .nds .tlsscanner .serverscanner .test ;
1010
11+ import com .github .dockerjava .api .command .InspectContainerCmd ;
12+ import com .github .dockerjava .api .command .InspectContainerResponse ;
1113import com .github .dockerjava .api .exception .DockerException ;
12- import com .github .dockerjava .api .model .Image ;
14+ import com .github .dockerjava .api .model .* ;
1315import de .rub .nds .tls .subject .ConnectionRole ;
1416import de .rub .nds .tls .subject .TlsImplementationType ;
1517import de .rub .nds .tls .subject .constants .TransportType ;
@@ -106,6 +108,20 @@ protected void killContainer() {
106108 }
107109
108110 protected String getServerAddress () {
109- return "localhost:" + dockerInstance .getPort ();
111+ InspectContainerCmd cmd =
112+ DockerClientManager .getDockerClient ()
113+ .inspectContainerCmd (this .dockerInstance .getId ());
114+ InspectContainerResponse response = cmd .exec ();
115+ Ports .Binding serverPortBinding =
116+ response .getNetworkSettings ().getPorts ().getBindings ().values ().stream ()
117+ .findFirst ()
118+ .orElseThrow (IllegalArgumentException ::new )[0 ];
119+
120+ int serverPort = Integer .parseInt (serverPortBinding .getHostPortSpec ());
121+ String serverName =
122+ serverPortBinding .getHostIp ().equals ("0.0.0.0" )
123+ ? "127.0.0.1"
124+ : serverPortBinding .getHostIp ();
125+ return serverName + ":" + serverPort ;
110126 }
111127}
You can’t perform that action at this time.
0 commit comments