use of io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CertificateValidationContext in project grpc-java by grpc.
the class CertProviderClientSslContextProviderTest method testProviderForClient_sslContextException_onError.
@Test
public void testProviderForClient_sslContextException_onError() throws Exception {
CertificateValidationContext staticCertValidationContext = CertificateValidationContext.newBuilder().setTrustedCa(DataSource.newBuilder().setInlineString("foo")).build();
final CertificateProvider.DistributorWatcher[] watcherCaptor = new CertificateProvider.DistributorWatcher[1];
TestCertificateProvider.createAndRegisterProviderProvider(certificateProviderRegistry, watcherCaptor, "testca", 0);
CertProviderClientSslContextProvider provider = getSslContextProvider(/* certInstanceName= */
null, "gcp_id", CommonBootstrapperTestUtils.getTestBootstrapInfo(), /* alpnProtocols= */
null, staticCertValidationContext);
TestCallback testCallback = new TestCallback(MoreExecutors.directExecutor());
provider.addCallback(testCallback);
try {
watcherCaptor[0].updateTrustedRoots(ImmutableList.of(getCertFromResourceName(CA_PEM_FILE)));
fail("exception expected");
} catch (RuntimeException expected) {
assertThat(expected).hasMessageThat().contains("only static certificateValidationContext expected");
}
assertThat(testCallback.updatedThrowable).isNotNull();
assertThat(testCallback.updatedThrowable).hasCauseThat().hasMessageThat().contains("only static certificateValidationContext expected");
}
Aggregations