Search in sources :

Example 6 with CredentialsProvider

use of org.apache.drill.common.logical.security.CredentialsProvider 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 7 with CredentialsProvider

use of org.apache.drill.common.logical.security.CredentialsProvider in project drill by apache.

the class CredentialsProviderSerDeTest method testEnvCredentialsProviderSerDe.

@Test
public void testEnvCredentialsProviderSerDe() throws JsonProcessingException {
    ObjectMapper mapper = cluster.drillbit().getContext().getLpPersistence().getMapper();
    CredentialsProvider envCredentialsProvider = new EnvCredentialsProvider(ImmutableMap.of(UsernamePasswordCredentials.USERNAME, "myLoginVar", UsernamePasswordCredentials.PASSWORD, "myPassVar"));
    String serialized = mapper.writerFor(CredentialsProvider.class).writeValueAsString(envCredentialsProvider);
    String expected = "{\n" + "  \"credentialsProviderType\" : \"EnvCredentialsProvider\",\n" + "  \"envVariables\" : {\n" + "    \"username\" : \"myLoginVar\",\n" + "    \"password\" : \"myPassVar\"\n" + "  }\n" + "}";
    assertEquals(expected, serialized);
    CredentialsProvider deserialized = mapper.readerFor(CredentialsProvider.class).readValue(serialized);
    assertEquals(envCredentialsProvider, deserialized);
}
Also used : EnvCredentialsProvider(org.apache.drill.exec.store.security.EnvCredentialsProvider) 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)

Example 8 with CredentialsProvider

use of org.apache.drill.common.logical.security.CredentialsProvider 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)

Example 9 with CredentialsProvider

use of org.apache.drill.common.logical.security.CredentialsProvider in project drill by apache.

the class CredentialsProviderSerDeTest method testPlainCredentialsProviderWithNoType.

@Test
public void testPlainCredentialsProviderWithNoType() throws JsonProcessingException {
    ObjectMapper mapper = cluster.drillbit().getContext().getLpPersistence().getMapper();
    CredentialsProvider expected = new PlainCredentialsProvider(ImmutableMap.of(UsernamePasswordCredentials.USERNAME, "myLogin", UsernamePasswordCredentials.PASSWORD, "myPass"));
    String serialized = "{\n" + "  \"credentials\" : {\n" + "    \"username\" : \"myLogin\",\n" + "    \"password\" : \"myPass\"\n" + "  }\n" + "}";
    CredentialsProvider deserialized = mapper.readerFor(CredentialsProvider.class).readValue(serialized);
    assertEquals(expected, deserialized);
}
Also used : PlainCredentialsProvider(org.apache.drill.common.logical.security.PlainCredentialsProvider) 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)

Example 10 with CredentialsProvider

use of org.apache.drill.common.logical.security.CredentialsProvider 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)11 EnvCredentialsProvider (org.apache.drill.exec.store.security.EnvCredentialsProvider)8 HadoopCredentialsProvider (org.apache.drill.exec.store.security.HadoopCredentialsProvider)8 VaultCredentialsProvider (org.apache.drill.exec.store.security.vault.VaultCredentialsProvider)8 ClusterTest (org.apache.drill.test.ClusterTest)8 Test (org.junit.Test)8 PlainCredentialsProvider (org.apache.drill.common.logical.security.PlainCredentialsProvider)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 DrillConfig (org.apache.drill.common.config.DrillConfig)2 AbstractSecuredStoragePluginConfig (org.apache.drill.common.logical.AbstractSecuredStoragePluginConfig)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 HashMap (java.util.HashMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1