use of com.google.api.gax.rpc.testing.FakeMtlsProvider in project gax-java by googleapis.
the class AbstractMtlsTransportChannelTest method testNoClientCertificate.
@Test
public void testNoClientCertificate() throws IOException, GeneralSecurityException {
MtlsProvider provider = new FakeMtlsProvider(true, MtlsEndpointUsagePolicy.AUTO, null, "", false);
assertNull(getMtlsObjectFromTransportChannel(provider));
}
use of com.google.api.gax.rpc.testing.FakeMtlsProvider in project gax-java by googleapis.
the class ClientContextTest method testNoClientCertificate.
@Test
public void testNoClientCertificate() throws IOException {
// Test the case that client certificates doesn't exists so the original endpoint is selected.
boolean switchToMtlsEndpointAllowed = true;
MtlsProvider provider = new FakeMtlsProvider(true, MtlsEndpointUsagePolicy.AUTO, null, "", false);
String endpointSelected = ClientContext.getEndpoint(endpoint, mtlsEndpoint, switchToMtlsEndpointAllowed, provider);
assertEquals(endpoint, endpointSelected);
}
use of com.google.api.gax.rpc.testing.FakeMtlsProvider 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.testing.FakeMtlsProvider 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);
}
use of com.google.api.gax.rpc.testing.FakeMtlsProvider in project gax-java by googleapis.
the class AbstractMtlsTransportChannelTest method testNotUseClientCertificate.
@Test
public void testNotUseClientCertificate() throws IOException, GeneralSecurityException {
MtlsProvider provider = new FakeMtlsProvider(false, MtlsEndpointUsagePolicy.AUTO, null, "", false);
assertNull(getMtlsObjectFromTransportChannel(provider));
}
Aggregations