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