Merge "Add test case for issue 18428603" into lmp-mr1-dev
diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java
index ff055b2..95ccaaa 100644
--- a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java
+++ b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java
@@ -26,6 +26,7 @@
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.SocketAddress;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.security.Principal;
@@ -1570,6 +1571,28 @@
}
}
+ // http://b/18428603
+ public void test_SSLSocket_getPortWithSNI() throws Exception {
+ TestSSLContext context = TestSSLContext.create();
+
+ SSLSocket client = null;
+ try {
+ client = (SSLSocket) context.clientContext.getSocketFactory().createSocket();
+ client.connect(new InetSocketAddress(context.host, context.port));
+ try {
+ // This is crucial to reproducing issue 18428603.
+ Method setHostname = client.getClass().getMethod("setHostname", String.class);
+ setHostname.invoke(client, "sslsockettest.androidcts.google.com");
+ } catch (NoSuchMethodException ignored) {
+ }
+
+ assertTrue(client.getPort() > 0);
+ } finally {
+ client.close();
+ context.close();
+ }
+ }
+
public void test_SSLSocket_sendsTlsFallbackScsv_Fallback_Success() throws Exception {
TestSSLContext context = TestSSLContext.create();