use of com.google.api.gax.rpc.mtls.MtlsProvider in project gax-java by googleapis.
the class ClientContextTest method testGetKeyStoreThrows.
@Test
public void testGetKeyStoreThrows() throws IOException {
// Test the case that getKeyStore throws exceptions.
try {
boolean switchToMtlsEndpointAllowed = true;
MtlsProvider provider = new FakeMtlsProvider(true, MtlsEndpointUsagePolicy.AUTO, null, "", true);
ClientContext.getEndpoint(endpoint, mtlsEndpoint, switchToMtlsEndpointAllowed, provider);
fail("should throw an exception");
} catch (IOException e) {
assertTrue("expected getKeyStore to throw an exception", e.getMessage().contains("getKeyStore throws exception"));
}
}
use of com.google.api.gax.rpc.mtls.MtlsProvider in project gax-java by googleapis.
the class ClientContextTest method testEndpointNotOverridable.
@Test
public void testEndpointNotOverridable() throws IOException {
// Test the case that switching to mTLS endpoint is not allowed so the original endpoint is
// selected.
boolean switchToMtlsEndpointAllowed = false;
MtlsProvider provider = new FakeMtlsProvider(true, MtlsEndpointUsagePolicy.AUTO, FakeMtlsProvider.createTestMtlsKeyStore(), "", false);
String endpointSelected = ClientContext.getEndpoint(endpoint, mtlsEndpoint, switchToMtlsEndpointAllowed, provider);
assertEquals(endpoint, endpointSelected);
}
Aggregations