Search in sources :

Example 1 with VaultCredentialsProvider

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

the class CredentialsProviderImplementationsTest method testVaultCredentialsProvider.

@Test
public void testVaultCredentialsProvider() throws VaultException {
    DrillConfig config = cluster.drillbit().getContext().getConfig();
    CredentialsProvider envCredentialsProvider = new VaultCredentialsProvider(SECRET_PATH, ImmutableMap.of(UsernamePasswordCredentials.USERNAME, "top_secret", UsernamePasswordCredentials.PASSWORD, "db_password"), config);
    Map<String, String> actualCredentials = envCredentialsProvider.getCredentials();
    assertEquals(ImmutableMap.of(UsernamePasswordCredentials.USERNAME, "password1", UsernamePasswordCredentials.PASSWORD, "dbpassword1"), actualCredentials);
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) VaultCredentialsProvider(org.apache.drill.exec.store.security.vault.VaultCredentialsProvider) 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 VaultCredentialsProvider

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

the class CredentialsProviderSerDeTest method testVaultCredentialsProviderSerDe.

@Test
public void testVaultCredentialsProviderSerDe() throws JsonProcessingException, VaultException {
    ObjectMapper mapper = cluster.drillbit().getContext().getLpPersistence().getMapper();
    DrillConfig config = cluster.drillbit().getContext().getConfig();
    CredentialsProvider credentialsProvider = new VaultCredentialsProvider(SECRET_PATH, ImmutableMap.of(UsernamePasswordCredentials.USERNAME, "myLoginProp", UsernamePasswordCredentials.PASSWORD, "myPassProp"), config);
    String serialized = mapper.writerFor(CredentialsProvider.class).writeValueAsString(credentialsProvider);
    String expected = "{\n" + "  \"credentialsProviderType\" : \"VaultCredentialsProvider\",\n" + "  \"secretPath\" : \"secret/testing\",\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 : DrillConfig(org.apache.drill.common.config.DrillConfig) VaultCredentialsProvider(org.apache.drill.exec.store.security.vault.VaultCredentialsProvider) 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

DrillConfig (org.apache.drill.common.config.DrillConfig)2 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