use of com.google.api.gax.rpc.testing.FakeMtlsProvider in project gax-java by googleapis.
the class ClientContextTest method testAlwaysUseMtlsEndpoint.
@Test
public void testAlwaysUseMtlsEndpoint() throws IOException {
// Test the case that mTLS endpoint is always used.
boolean switchToMtlsEndpointAllowed = true;
MtlsProvider provider = new FakeMtlsProvider(false, MtlsEndpointUsagePolicy.ALWAYS, null, "", false);
String endpointSelected = ClientContext.getEndpoint(endpoint, mtlsEndpoint, switchToMtlsEndpointAllowed, provider);
assertEquals(mtlsEndpoint, endpointSelected);
}
use of com.google.api.gax.rpc.testing.FakeMtlsProvider in project gax-java by googleapis.
the class ClientContextTest method testAutoUseMtlsEndpoint.
@Test
public void testAutoUseMtlsEndpoint() throws IOException {
// Test the case client certificate exists and mTLS endpoint is selected.
boolean switchToMtlsEndpointAllowed = true;
MtlsProvider provider = new FakeMtlsProvider(true, MtlsEndpointUsagePolicy.AUTO, FakeMtlsProvider.createTestMtlsKeyStore(), "", false);
String endpointSelected = ClientContext.getEndpoint(endpoint, mtlsEndpoint, switchToMtlsEndpointAllowed, provider);
assertEquals(mtlsEndpoint, endpointSelected);
}
use of com.google.api.gax.rpc.testing.FakeMtlsProvider in project gax-java by googleapis.
the class ClientContextTest method testNeverUseMtlsEndpoint.
@Test
public void testNeverUseMtlsEndpoint() throws IOException {
// Test the case that mTLS endpoint is never used.
boolean switchToMtlsEndpointAllowed = true;
MtlsProvider provider = new FakeMtlsProvider(true, MtlsEndpointUsagePolicy.NEVER, 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 testUseClientCertificate.
@Test
public void testUseClientCertificate() throws IOException, GeneralSecurityException {
MtlsProvider provider = new FakeMtlsProvider(true, MtlsEndpointUsagePolicy.AUTO, FakeMtlsProvider.createTestMtlsKeyStore(), "", false);
assertNotNull(getMtlsObjectFromTransportChannel(provider));
}
use of com.google.api.gax.rpc.testing.FakeMtlsProvider in project gax-java by googleapis.
the class AbstractMtlsTransportChannelTest method testGetKeyStoreThrows.
@Test
public void testGetKeyStoreThrows() throws GeneralSecurityException {
// Test the case where provider.getKeyStore() throws.
MtlsProvider provider = new FakeMtlsProvider(true, MtlsEndpointUsagePolicy.AUTO, null, "", true);
try {
getMtlsObjectFromTransportChannel(provider);
fail("should throw an exception");
} catch (IOException e) {
assertTrue("expected getKeyStore to throw an exception", e.getMessage().contains("getKeyStore throws exception"));
}
}
Aggregations