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