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 8
8
*/
9
9
package de .rub .nds .tlsscanner .serverscanner .test ;
10
10
11
+ import com .github .dockerjava .api .command .InspectContainerCmd ;
12
+ import com .github .dockerjava .api .command .InspectContainerResponse ;
11
13
import com .github .dockerjava .api .exception .DockerException ;
12
- import com .github .dockerjava .api .model .Image ;
14
+ import com .github .dockerjava .api .model .* ;
13
15
import de .rub .nds .tls .subject .ConnectionRole ;
14
16
import de .rub .nds .tls .subject .TlsImplementationType ;
15
17
import de .rub .nds .tls .subject .constants .TransportType ;
@@ -106,6 +108,20 @@ protected void killContainer() {
106
108
}
107
109
108
110
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 ;
110
126
}
111
127
}
You can’t perform that action at this time.
0 commit comments