Skip to content

Commit fb909e3

Browse files
committed
Adapt TLS file to new tls-gen paths
See rabbitmq/tls-gen#37.
1 parent 8ccbee7 commit fb909e3

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/test/java/com/rabbitmq/stream/impl/MetadataTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class MetadataTest {
4040

4141
@ValueSource(ints = {1, 2, 3, 4, 5})
4242
@ParameterizedTest
43-
void metadataExistingStreams(int streamCount, TestInfo info) throws Exception {
43+
void metadataExistingStreams(int streamCount, TestInfo info) {
4444
Client streamClient = cf.get();
4545
String[] streams =
4646
IntStream.range(0, streamCount)

src/test/java/com/rabbitmq/stream/impl/TlsTest.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.rabbitmq.stream.ChannelCustomizer;
2525
import com.rabbitmq.stream.ConfirmationHandler;
2626
import com.rabbitmq.stream.Environment;
27+
import com.rabbitmq.stream.Host;
2728
import com.rabbitmq.stream.OffsetSpecification;
2829
import com.rabbitmq.stream.Producer;
2930
import com.rabbitmq.stream.StreamException;
@@ -34,6 +35,9 @@
3435
import io.netty.handler.ssl.SslHandler;
3536
import java.io.File;
3637
import java.io.FileInputStream;
38+
import java.io.IOException;
39+
import java.net.InetAddress;
40+
import java.net.UnknownHostException;
3741
import java.nio.charset.Charset;
3842
import java.nio.charset.StandardCharsets;
3943
import java.nio.file.Files;
@@ -106,7 +110,8 @@ static X509Certificate clientCertificate() throws Exception {
106110

107111
static String clientCertificateFile() {
108112
return System.getProperty(
109-
"client.certificate", "/tmp/tls-gen/basic/result/client_certificate.pem");
113+
"client.certificate",
114+
"/tmp/tls-gen/basic/result/client_" + hostname() + "_certificate.pem");
110115
}
111116

112117
static PrivateKey clientKey() throws Exception {
@@ -131,7 +136,8 @@ static PrivateKey loadPrivateKey(String filename) throws Exception {
131136
}
132137

133138
static String clientKeyFile() {
134-
return System.getProperty("client.key", "/tmp/tls-gen/basic/result/client_key.pem");
139+
return System.getProperty(
140+
"client.key", "/tmp/tls-gen/basic/result/client_" + hostname() + "_key.pem");
135141
}
136142

137143
static X509Certificate loadCertificate(String file) throws Exception {
@@ -315,4 +321,16 @@ void clientShouldContainServerAdvertisedTlsPort() {
315321
Client client = cf.get(new ClientParameters().sslContext(alwaysTrustSslContext()));
316322
assertThat(client.serverAdvertisedPort()).isEqualTo(Client.DEFAULT_TLS_PORT);
317323
}
324+
325+
private static String hostname() {
326+
try {
327+
return InetAddress.getLocalHost().getHostName();
328+
} catch (UnknownHostException e) {
329+
try {
330+
return Host.hostname();
331+
} catch (IOException ex) {
332+
throw new RuntimeException(ex);
333+
}
334+
}
335+
}
318336
}

0 commit comments

Comments
 (0)