interop-testing,okhttp,testing: update tests to pass with ipv6

This commit is contained in:
Eric Gribkoff 2017-05-16 17:01:05 -07:00 committed by GitHub
parent 7be1720fce
commit 5dc8a124bf
4 changed files with 7 additions and 7 deletions

View File

@ -99,7 +99,7 @@ public class Http2NettyTest extends AbstractInteropTest {
@Test(timeout = 10000) @Test(timeout = 10000)
public void remoteAddr() { public void remoteAddr() {
assertRemoteAddr("/127.0.0.1"); assertRemoteAddr("/0:0:0:0:0:0:0:1");
} }
@Test(timeout = 10000) @Test(timeout = 10000)

View File

@ -97,7 +97,7 @@ public class Http2OkHttpTest extends AbstractInteropTest {
@Override @Override
protected ManagedChannel createChannel() { protected ManagedChannel createChannel() {
OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("127.0.0.1", getPort()) OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("::1", getPort())
.maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE) .maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE)
.connectionSpec(new ConnectionSpec.Builder(OkHttpChannelBuilder.DEFAULT_CONNECTION_SPEC) .connectionSpec(new ConnectionSpec.Builder(OkHttpChannelBuilder.DEFAULT_CONNECTION_SPEC)
.cipherSuites(TestUtils.preferredTestCiphers().toArray(new String[0])) .cipherSuites(TestUtils.preferredTestCiphers().toArray(new String[0]))
@ -142,7 +142,7 @@ public class Http2OkHttpTest extends AbstractInteropTest {
@Test(timeout = 10000) @Test(timeout = 10000)
public void wrongHostNameFailHostnameVerification() throws Exception { public void wrongHostNameFailHostnameVerification() throws Exception {
OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("127.0.0.1", getPort()) OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("::1", getPort())
.connectionSpec(new ConnectionSpec.Builder(OkHttpChannelBuilder.DEFAULT_CONNECTION_SPEC) .connectionSpec(new ConnectionSpec.Builder(OkHttpChannelBuilder.DEFAULT_CONNECTION_SPEC)
.cipherSuites(TestUtils.preferredTestCiphers().toArray(new String[0])) .cipherSuites(TestUtils.preferredTestCiphers().toArray(new String[0]))
.tlsVersions(ConnectionSpec.MODERN_TLS.tlsVersions().toArray(new TlsVersion[0])) .tlsVersions(ConnectionSpec.MODERN_TLS.tlsVersions().toArray(new TlsVersion[0]))

View File

@ -51,7 +51,7 @@ import org.junit.runners.JUnit4;
public class OkHttpTransportTest extends AbstractTransportTest { public class OkHttpTransportTest extends AbstractTransportTest {
private ClientTransportFactory clientFactory = OkHttpChannelBuilder private ClientTransportFactory clientFactory = OkHttpChannelBuilder
// Although specified here, address is ignored because we never call build. // Although specified here, address is ignored because we never call build.
.forAddress("127.0.0.1", 0) .forAddress("::1", 0)
.negotiationType(NegotiationType.PLAINTEXT) .negotiationType(NegotiationType.PLAINTEXT)
.buildTransportFactory(); .buildTransportFactory();
@ -82,14 +82,14 @@ public class OkHttpTransportTest extends AbstractTransportTest {
@Override @Override
protected String testAuthority(InternalServer server) { protected String testAuthority(InternalServer server) {
return "127.0.0.1:" + server.getPort(); return "[::1]:" + server.getPort();
} }
@Override @Override
protected ManagedClientTransport newClientTransport(InternalServer server) { protected ManagedClientTransport newClientTransport(InternalServer server) {
int port = server.getPort(); int port = server.getPort();
return clientFactory.newClientTransport( return clientFactory.newClientTransport(
new InetSocketAddress("127.0.0.1", port), new InetSocketAddress("::1", port),
testAuthority(server), testAuthority(server),
null /* agent */); null /* agent */);
} }

View File

@ -124,7 +124,7 @@ public class TestUtils {
*/ */
public static InetSocketAddress testServerAddress(int port) { public static InetSocketAddress testServerAddress(int port) {
try { try {
InetAddress inetAddress = InetAddress.getByName("localhost"); InetAddress inetAddress = InetAddress.getByName("::1");
inetAddress = InetAddress.getByAddress(TEST_SERVER_HOST, inetAddress.getAddress()); inetAddress = InetAddress.getByAddress(TEST_SERVER_HOST, inetAddress.getAddress());
return new InetSocketAddress(inetAddress, port); return new InetSocketAddress(inetAddress, port);
} catch (UnknownHostException e) { } catch (UnknownHostException e) {