Skip to content

Commit 16daff1

Browse files
michaelklishinacogoluegnes
authored andcommitted
One more test
(cherry picked from commit 4abef12)
1 parent ad47e5b commit 16daff1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/test/java/com/rabbitmq/client/test/ssl/HostnameVerification.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
package com.rabbitmq.client.test.ssl;
1717

1818
import com.rabbitmq.client.Address;
19+
import com.rabbitmq.client.Connection;
1920
import com.rabbitmq.client.ConnectionFactory;
2021
import com.rabbitmq.client.test.TestUtils;
22+
import com.rabbitmq.tools.Host;
2123
import org.junit.BeforeClass;
2224
import org.junit.Test;
2325
import org.junit.runner.RunWith;
@@ -34,6 +36,7 @@
3436
import static com.rabbitmq.client.test.TestUtils.getSSLContext;
3537
import static java.util.Collections.singletonList;
3638
import static org.junit.Assert.assertNotNull;
39+
import static org.junit.Assert.assertTrue;
3740
import static org.junit.Assert.fail;
3841

3942
@RunWith(Parameterized.class)
@@ -107,4 +110,14 @@ public void hostnameVerificationFailsBecauseCertificateNotIssuedForLoopbackInter
107110
() -> singletonList(new Address("127.0.0.1", ConnectionFactory.DEFAULT_AMQP_OVER_SSL_PORT)));
108111
fail("The server certificate isn't issued for 127.0.0.1, the TLS handshake should have failed");
109112
}
113+
114+
public void hostnameVerificationSucceeds() throws Exception {
115+
ConnectionFactory connectionFactory = TestUtils.connectionFactory();
116+
connectionFactory.useSslProtocol(sslContext);
117+
customizer.accept(connectionFactory);
118+
Connection conn = connectionFactory.newConnection(
119+
() -> singletonList(new Address(Host.systemHostname(), ConnectionFactory.DEFAULT_AMQP_OVER_SSL_PORT)));
120+
assertTrue(conn.isOpen());
121+
conn.close();
122+
}
110123
}

src/test/java/com/rabbitmq/tools/Host.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ public static Process invokeMakeTarget(String command) throws IOException {
120120
" " + command);
121121
}
122122

123+
public static String systemHostname() throws IOException {
124+
Process process = executeCommandIgnoringErrors("hostname");
125+
return capture(process.getInputStream());
126+
}
127+
123128
public static String makeCommand()
124129
{
125130
return System.getProperty("make.bin", "make");

0 commit comments

Comments
 (0)