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());
}
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());
}
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());
}
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;
}
Aggregations