use of io.servicetalk.grpc.api.GrpcStatusException in project servicetalk by apple.
the class GrpcLifecycleObserverTest method runTest.
private void runTest(Callable<String> executeRequest, boolean error, boolean aggregated) throws Exception {
setUp(error);
if (error) {
GrpcStatusException e = assertThrows(GrpcStatusException.class, executeRequest::call);
assertThat(e.status().code(), is(UNKNOWN));
} else {
assertThat(executeRequest.call(), equalTo(CONTENT));
}
bothTerminate.await();
verifyObservers(true, error, aggregated, clientLifecycleObserver, clientExchangeObserver, clientRequestObserver, clientResponseObserver, clientInOrder, clientRequestInOrder);
verifyObservers(false, error, aggregated, serverLifecycleObserver, serverExchangeObserver, serverRequestObserver, serverResponseObserver, serverInOrder, serverRequestInOrder);
}
use of io.servicetalk.grpc.api.GrpcStatusException in project servicetalk by apple.
the class GrpcSslAndNonSslConnectionsTest method nonSecureClientToSecureServerClosesConnection.
@Test
void nonSecureClientToSecureServerClosesConnection() throws Exception {
try (ServerContext serverContext = secureGrpcServer();
BlockingTesterClient client = nonSecureGrpcClient(serverContext)) {
GrpcStatusException e = assertThrows(GrpcStatusException.class, () -> client.test(REQUEST));
assertThat(e.getCause(), instanceOf(StacklessClosedChannelException.class));
}
}
use of io.servicetalk.grpc.api.GrpcStatusException in project servicetalk by apple.
the class SingleRequestOrResponseApiTest method serverResponseStreamingRouteFailsWithInvalidArgument.
private void serverResponseStreamingRouteFailsWithInvalidArgument(Iterable<TestRequest> requestItems, String expectedMsg) throws Exception {
// No need to run the test with different client-side, always use blocking client
assumeFalse(streamingClient);
try (BlockingTesterClient client = newBlockingClient()) {
GrpcStatusException e = assertThrows(GrpcStatusException.class, () -> client.testBiDiStream(requestItems).forEach(response -> {
/* noop */
}));
assertThat(e.status().code(), is(INVALID_ARGUMENT));
assertThat(e.status().description(), equalTo(expectedMsg));
}
}
use of io.servicetalk.grpc.api.GrpcStatusException in project servicetalk by apple.
the class GrpcSslAndNonSslConnectionsTest method noSniClientDefaultServerFallbackFailExpected.
@Test
void noSniClientDefaultServerFallbackFailExpected() throws Exception {
try (ServerContext serverContext = GrpcServers.forAddress(localAddress(0)).initializeHttp(builder -> builder.sslConfig(untrustedServerConfig(), singletonMap(getLoopbackAddress().getHostName(), trustedServerConfig()))).listenAndAwait(serviceFactory());
BlockingTesterClient client = GrpcClients.forAddress(getLoopbackAddress().getHostName(), serverHostAndPort(serverContext).port()).initializeHttp(builder -> builder.sslConfig(new ClientSslConfigBuilder(DefaultTestCerts::loadServerCAPem).build()).inferPeerHost(false).inferSniHostname(false)).buildBlocking(clientFactory())) {
GrpcStatusException e = assertThrows(GrpcStatusException.class, () -> client.test(REQUEST));
assertThat(e.getCause(), instanceOf(SSLHandshakeException.class));
}
}
use of io.servicetalk.grpc.api.GrpcStatusException in project servicetalk by apple.
the class GrpcSslAndNonSslConnectionsTest method secureClientToNonSecureServerClosesConnection.
@Test
void secureClientToNonSecureServerClosesConnection() throws Exception {
try (ServerContext serverContext = nonSecureGrpcServer();
BlockingTesterClient client = secureGrpcClient(serverContext, new ClientSslConfigBuilder(DefaultTestCerts::loadServerCAPem).peerHost(serverPemHostname())).buildBlocking(clientFactory())) {
GrpcStatusException e = assertThrows(GrpcStatusException.class, () -> client.test(REQUEST));
assertThat(e.getCause(), instanceOf(SSLHandshakeException.class));
}
}
Aggregations