Search in sources :

Example 1 with HadoopCredentialsProvider

use of org.apache.drill.exec.store.security.HadoopCredentialsProvider in project drill by apache.

the class CredentialsProviderImplementationsTest method testHadoopCredentialsProvider.

@Test
public void testHadoopCredentialsProvider() {
    Configuration configuration = new Configuration();
    String expectedUsernameValue = "user1";
    String expectedPassValue = "pass123!@#";
    String usernamePropertyName = "username_key";
    String passwordPropertyName = "password_key";
    configuration.set(usernamePropertyName, expectedUsernameValue);
    configuration.set(passwordPropertyName, expectedPassValue);
    CredentialsProvider envCredentialsProvider = new HadoopCredentialsProvider(configuration, ImmutableMap.of(UsernamePasswordCredentials.USERNAME, usernamePropertyName, UsernamePasswordCredentials.PASSWORD, passwordPropertyName));
    Map<String, String> actualCredentials = envCredentialsProvider.getCredentials();
    assertEquals(ImmutableMap.of(UsernamePasswordCredentials.USERNAME, expectedUsernameValue, UsernamePasswordCredentials.PASSWORD, expectedPassValue), actualCredentials);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HadoopCredentialsProvider(org.apache.drill.exec.store.security.HadoopCredentialsProvider) EnvCredentialsProvider(org.apache.drill.exec.store.security.EnvCredentialsProvider) CredentialsProvider(org.apache.drill.common.logical.security.CredentialsProvider) HadoopCredentialsProvider(org.apache.drill.exec.store.security.HadoopCredentialsProvider) VaultCredentialsProvider(org.apache.drill.exec.store.security.vault.VaultCredentialsProvider) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 2 with HadoopCredentialsProvider

use of org.apache.drill.exec.store.security.HadoopCredentialsProvider in project drill by apache.

the class CredentialsProviderSerDeTest method testHadoopCredentialsProviderSerDe.

@Test
public void testHadoopCredentialsProviderSerDe() throws JsonProcessingException {
    ObjectMapper mapper = cluster.drillbit().getContext().getLpPersistence().getMapper();
    CredentialsProvider credentialsProvider = new HadoopCredentialsProvider(ImmutableMap.of(UsernamePasswordCredentials.USERNAME, "myLoginProp", UsernamePasswordCredentials.PASSWORD, "myPassProp"));
    String serialized = mapper.writerFor(CredentialsProvider.class).writeValueAsString(credentialsProvider);
    String expected = "{\n" + "  \"credentialsProviderType\" : \"HadoopCredentialsProvider\",\n" + "  \"propertyNames\" : {\n" + "    \"username\" : \"myLoginProp\",\n" + "    \"password\" : \"myPassProp\"\n" + "  }\n" + "}";
    assertEquals(expected, serialized);
    CredentialsProvider deserialized = mapper.readerFor(CredentialsProvider.class).readValue(serialized);
    assertEquals(credentialsProvider, deserialized);
}
Also used : HadoopCredentialsProvider(org.apache.drill.exec.store.security.HadoopCredentialsProvider) EnvCredentialsProvider(org.apache.drill.exec.store.security.EnvCredentialsProvider) PlainCredentialsProvider(org.apache.drill.common.logical.security.PlainCredentialsProvider) CredentialsProvider(org.apache.drill.common.logical.security.CredentialsProvider) HadoopCredentialsProvider(org.apache.drill.exec.store.security.HadoopCredentialsProvider) VaultCredentialsProvider(org.apache.drill.exec.store.security.vault.VaultCredentialsProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

CredentialsProvider (org.apache.drill.common.logical.security.CredentialsProvider)2 EnvCredentialsProvider (org.apache.drill.exec.store.security.EnvCredentialsProvider)2 HadoopCredentialsProvider (org.apache.drill.exec.store.security.HadoopCredentialsProvider)2 VaultCredentialsProvider (org.apache.drill.exec.store.security.vault.VaultCredentialsProvider)2 ClusterTest (org.apache.drill.test.ClusterTest)2 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 PlainCredentialsProvider (org.apache.drill.common.logical.security.PlainCredentialsProvider)1 Configuration (org.apache.hadoop.conf.Configuration)1