use of io.grpc.netty.ProtocolNegotiators.TlsNegotiator in project grpc-java by grpc.
the class NettyChannelBuilderTest method createProtocolNegotiator_tlsWithClientContext.
@Test
public void createProtocolNegotiator_tlsWithClientContext() throws SSLException {
ProtocolNegotiator negotiator = NettyChannelBuilder.createProtocolNegotiator("authority:1234", NegotiationType.TLS, GrpcSslContexts.forClient().build());
assertTrue(negotiator instanceof ProtocolNegotiators.TlsNegotiator);
ProtocolNegotiators.TlsNegotiator n = (TlsNegotiator) negotiator;
assertEquals("authority", n.getHost());
assertEquals(1234, n.getPort());
}
use of io.grpc.netty.ProtocolNegotiators.TlsNegotiator in project grpc-java by grpc.
the class NettyChannelBuilderTest method createProtocolNegotiator_tlsWithNoContext.
@Test
public void createProtocolNegotiator_tlsWithNoContext() {
ProtocolNegotiator negotiator = NettyChannelBuilder.createProtocolNegotiator("authority:1234", NegotiationType.TLS, noSslContext);
assertTrue(negotiator instanceof ProtocolNegotiators.TlsNegotiator);
ProtocolNegotiators.TlsNegotiator n = (TlsNegotiator) negotiator;
assertEquals("authority", n.getHost());
assertEquals(1234, n.getPort());
}
use of io.grpc.netty.ProtocolNegotiators.TlsNegotiator in project grpc-java by grpc.
the class ProtocolNegotiatorsTest method tls_hostAndPort.
@Test
public void tls_hostAndPort() throws SSLException {
SslContext ctx = GrpcSslContexts.forClient().build();
TlsNegotiator negotiator = (TlsNegotiator) ProtocolNegotiators.tls(ctx, "authority:1234");
assertEquals("authority", negotiator.getHost());
assertEquals(1234, negotiator.getPort());
}
use of io.grpc.netty.ProtocolNegotiators.TlsNegotiator in project grpc-java by grpc.
the class ProtocolNegotiatorsTest method tls_invalidHost.
@Test
public void tls_invalidHost() throws SSLException {
SslContext ctx = GrpcSslContexts.forClient().build();
TlsNegotiator negotiator = (TlsNegotiator) ProtocolNegotiators.tls(ctx, "bad_host:1234");
// Even though it looks like a port, we treat it as part of the authority, since the host is
// invalid.
assertEquals("bad_host:1234", negotiator.getHost());
assertEquals(-1, negotiator.getPort());
}
use of io.grpc.netty.ProtocolNegotiators.TlsNegotiator in project grpc-java by grpc.
the class NettyChannelBuilderTest method createProtocolNegotiator_tlsWithAuthorityFallback.
@Test
public void createProtocolNegotiator_tlsWithAuthorityFallback() {
ProtocolNegotiator negotiator = NettyChannelBuilder.createProtocolNegotiator("bad_authority", NegotiationType.TLS, noSslContext);
assertTrue(negotiator instanceof ProtocolNegotiators.TlsNegotiator);
ProtocolNegotiators.TlsNegotiator n = (TlsNegotiator) negotiator;
assertEquals("bad_authority", n.getHost());
assertEquals(-1, n.getPort());
}
Aggregations