Search in sources :

Example 6 with FakeMtlsProvider

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));
}
Also used : FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) Test(org.junit.Test)

Example 7 with FakeMtlsProvider

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);
}
Also used : FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) MtlsProvider(com.google.api.gax.rpc.mtls.MtlsProvider) FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) Test(org.junit.Test)

Example 8 with FakeMtlsProvider

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"));
    }
}
Also used : FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) MtlsProvider(com.google.api.gax.rpc.mtls.MtlsProvider) FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) IOException(java.io.IOException) Test(org.junit.Test)

Example 9 with FakeMtlsProvider

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);
}
Also used : FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) MtlsProvider(com.google.api.gax.rpc.mtls.MtlsProvider) FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) Test(org.junit.Test)

Example 10 with FakeMtlsProvider

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));
}
Also used : FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) FakeMtlsProvider(com.google.api.gax.rpc.testing.FakeMtlsProvider) Test(org.junit.Test)

Aggregations

FakeMtlsProvider (com.google.api.gax.rpc.testing.FakeMtlsProvider)10 Test (org.junit.Test)10 MtlsProvider (com.google.api.gax.rpc.mtls.MtlsProvider)6 IOException (java.io.IOException)2