Use TLS for Netty integration tests
diff --git a/integration-testing/build.gradle b/integration-testing/build.gradle
index 882af47..8067178 100644
--- a/integration-testing/build.gradle
+++ b/integration-testing/build.gradle
@@ -29,6 +29,10 @@
alpnboot alpnboot_package_name
}
+test {
+ jvmArgs "-Xbootclasspath/p:" + configurations.alpnboot.asPath
+}
+
// Allow execution of test client and server.
task execute(dependsOn: classes, type:JavaExec) {
main = project.hasProperty('mainClass') ? project.mainClass : ''
diff --git a/integration-testing/src/test/java/io/grpc/testing/integration/Http2NettyTest.java b/integration-testing/src/test/java/io/grpc/testing/integration/Http2NettyTest.java
index 755532b..c669d36 100644
--- a/integration-testing/src/test/java/io/grpc/testing/integration/Http2NettyTest.java
+++ b/integration-testing/src/test/java/io/grpc/testing/integration/Http2NettyTest.java
@@ -35,12 +35,17 @@
import io.grpc.transport.netty.NegotiationType;
import io.grpc.transport.netty.NettyChannelBuilder;
import io.grpc.transport.netty.NettyServerBuilder;
+import io.netty.handler.ssl.SslContext;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+
/**
* Integration tests for GRPC over HTTP2 using the Netty framework.
*/
@@ -48,9 +53,16 @@
public class Http2NettyTest extends AbstractTransportTest {
private static int serverPort = Util.pickUnusedPort();
+ /** Starts the server with HTTPS. */
@BeforeClass
public static void startServer() {
- startStaticServer(NettyServerBuilder.forPort(serverPort));
+ try {
+ startStaticServer(NettyServerBuilder.forPort(serverPort)
+ .sslContext(SslContext.newServerContext(
+ Util.loadCert("server1.pem"), Util.loadCert("server1.key"))));
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
}
@AfterClass
@@ -60,7 +72,15 @@
@Override
protected ChannelImpl createChannel() {
- return NettyChannelBuilder.forAddress("127.0.0.1", serverPort)
- .negotiationType(NegotiationType.PLAINTEXT).build();
+ try {
+ InetAddress address
+ = InetAddress.getByAddress("foo.test.google.fr", new byte[] {127, 0, 0, 1});
+ return NettyChannelBuilder
+ .forAddress(new InetSocketAddress(address, serverPort))
+ .sslContext(SslContext.newClientContext(Util.loadCert("ca.pem")))
+ .build();
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
}
}