Search in sources :

Example 11 with Credentials

use of io.pravega.shared.security.auth.Credentials in project pravega by pravega.

the class CredentialsExtractorTest method testLoadsCredentialsObjOfAGenericTypeFromEnvVariablesIfLoadDynamicIsFalse.

@Test
public void testLoadsCredentialsObjOfAGenericTypeFromEnvVariablesIfLoadDynamicIsFalse() {
    Map<String, String> authEnvVariables = new HashMap<>();
    authEnvVariables.put("pravega_client_auth_loadDynamic", "false");
    authEnvVariables.put("pravega_client_auth_method", "amethod");
    authEnvVariables.put("pravega_client_auth_token", "atoken");
    ClientConfig clientConfig = ClientConfig.builder().extractCredentials(null, authEnvVariables).build();
    Credentials credentials = clientConfig.getCredentials();
    assertNotNull(credentials);
    assertNotNull("io.pravega.client.ClientConfig$ClientConfigBuilder$1", credentials.getClass());
    assertEquals("amethod", credentials.getAuthenticationType());
    assertEquals("atoken", credentials.getAuthenticationToken());
}
Also used : HashMap(java.util.HashMap) Credentials(io.pravega.shared.security.auth.Credentials) Test(org.junit.Test)

Example 12 with Credentials

use of io.pravega.shared.security.auth.Credentials in project pravega by pravega.

the class CredentialsExtractorTest method testExtractsCredentialsFromProperties.

@Test
public void testExtractsCredentialsFromProperties() {
    Properties properties = new Properties();
    properties.setProperty("pravega.client.auth.method", "amethod");
    properties.setProperty("pravega.client.auth.token", "atoken");
    ClientConfig clientConfig = ClientConfig.builder().extractCredentials(properties, null).build();
    Credentials credentials = clientConfig.getCredentials();
    assertNotNull(credentials);
    assertNotNull("io.pravega.client.ClientConfig$ClientConfigBuilder$1", credentials.getClass());
    assertEquals("amethod", credentials.getAuthenticationType());
    assertEquals("atoken", credentials.getAuthenticationToken());
}
Also used : Properties(java.util.Properties) Credentials(io.pravega.shared.security.auth.Credentials) Test(org.junit.Test)

Example 13 with Credentials

use of io.pravega.shared.security.auth.Credentials in project pravega by pravega.

the class CredentialsExtractorTest method testLoadsCredentialsObjOfAGenericTypeFromPropertiesIfLoadDynamicIsFalse.

@Test
public void testLoadsCredentialsObjOfAGenericTypeFromPropertiesIfLoadDynamicIsFalse() {
    Properties properties = new Properties();
    properties.setProperty("pravega.client.auth.loadDynamic", "false");
    properties.setProperty("pravega.client.auth.method", "amethod");
    properties.setProperty("pravega.client.auth.token", "atoken");
    ClientConfig clientConfig = ClientConfig.builder().extractCredentials(properties, null).build();
    Credentials credentials = clientConfig.getCredentials();
    assertNotNull(credentials);
    assertNotNull("io.pravega.client.ClientConfig$ClientConfigBuilder$1", credentials.getClass());
    assertEquals("amethod", credentials.getAuthenticationType());
    assertEquals("atoken", credentials.getAuthenticationToken());
}
Also used : Properties(java.util.Properties) Credentials(io.pravega.shared.security.auth.Credentials) Test(org.junit.Test)

Example 14 with Credentials

use of io.pravega.shared.security.auth.Credentials in project pravega by pravega.

the class ControllerGrpcAuthFocusedTest method prepareNonBlockingCallStub.

private ControllerServiceStub prepareNonBlockingCallStub(String username, String password) {
    Exceptions.checkNotNullOrEmpty(username, "username");
    Exceptions.checkNotNullOrEmpty(password, "password");
    ControllerServiceGrpc.ControllerServiceStub stub = ControllerServiceGrpc.newStub(inProcessChannel);
    // Set call credentials
    Credentials credentials = new DefaultCredentials(password, username);
    if (credentials != null) {
        PravegaCredentialsWrapper wrapper = new PravegaCredentialsWrapper(credentials);
        stub = stub.withCallCredentials(MoreCallCredentials.from(wrapper));
    }
    return stub;
}
Also used : DefaultCredentials(io.pravega.shared.security.auth.DefaultCredentials) ControllerServiceStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub) PravegaCredentialsWrapper(io.pravega.client.control.impl.PravegaCredentialsWrapper) ControllerServiceGrpc(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc) MoreCallCredentials(io.grpc.auth.MoreCallCredentials) DefaultCredentials(io.pravega.shared.security.auth.DefaultCredentials) Credentials(io.pravega.shared.security.auth.Credentials)

Aggregations

Credentials (io.pravega.shared.security.auth.Credentials)14 Test (org.junit.Test)9 HashMap (java.util.HashMap)6 MoreCallCredentials (io.grpc.auth.MoreCallCredentials)4 DefaultCredentials (io.pravega.shared.security.auth.DefaultCredentials)4 Properties (java.util.Properties)4 PravegaCredentialsWrapper (io.pravega.client.control.impl.PravegaCredentialsWrapper)3 ControllerServiceBlockingStub (io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub)2 ControllerServiceStub (io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub)2 StatusRuntimeException (io.grpc.StatusRuntimeException)1 InvalidStreamException (io.pravega.client.stream.InvalidStreamException)1 NoSuchScopeException (io.pravega.client.stream.NoSuchScopeException)1 PingFailedException (io.pravega.client.stream.PingFailedException)1 ReaderGroupNotFoundException (io.pravega.client.stream.ReaderGroupNotFoundException)1 TxnFailedException (io.pravega.client.stream.TxnFailedException)1 ControllerServiceGrpc (io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc)1 CompletionException (java.util.concurrent.CompletionException)1 SSLException (javax.net.ssl.SSLException)1