use of io.pravega.auth.ServerConfig in project pravega by pravega.
the class PasswordAuthHandlerTest method initializeFailsIfAccountFileConfigMissing.
@Test(expected = CompletionException.class)
public void initializeFailsIfAccountFileConfigMissing() {
PasswordAuthHandler authHandler = new PasswordAuthHandler();
ServerConfig serverConfig = new ServerConfig() {
@Override
public Properties toAuthHandlerProperties() {
Properties props = new Properties();
props.setProperty(AuthPluginConfig.BASIC_AUTHPLUGIN_DATABASE, "/random/file");
return props;
}
};
authHandler.initialize(serverConfig);
}
use of io.pravega.auth.ServerConfig in project pravega by pravega.
the class PasswordAuthHandlerTest method initializeFailsIfPropertiesIsNull.
// region Tests verifying authentication
@Test
public void initializeFailsIfPropertiesIsNull() {
PasswordAuthHandler objectUnderTest = new PasswordAuthHandler();
AssertExtensions.assertThrows(NullPointerException.class, () -> {
// Declaration is necessary to avoid ambiguity of the following call.
Properties props = null;
objectUnderTest.initialize(props);
});
AssertExtensions.assertThrows(NullPointerException.class, () -> {
// Declaration is necessary to avoid ambiguity of the following call.
ServerConfig serverConfig = null;
objectUnderTest.initialize(serverConfig);
});
}
use of io.pravega.auth.ServerConfig in project pravega by pravega.
the class PasswordAuthHandlerTest method initializeWorksWithValidAclsAndComments.
@SneakyThrows
@Test
public void initializeWorksWithValidAclsAndComments() {
PasswordAuthHandler authHandler = new PasswordAuthHandler();
try (PasswordAuthHandlerInput pwdInputFile = new PasswordAuthHandlerInput("PasswordAuthHandlerTest.init", ".txt")) {
String encryptedPassword = StrongPasswordProcessor.builder().build().encryptPassword("some_password");
List<PasswordAuthHandlerInput.Entry> entries = Arrays.asList(PasswordAuthHandlerInput.Entry.of("admin", encryptedPassword, "prn::*,READ_UPDATE;"), PasswordAuthHandlerInput.Entry.of("appaccount", encryptedPassword, "prn::/scope:scope1,READ_UPDATE;"), PasswordAuthHandlerInput.Entry.of("#commented", encryptedPassword, "prn::"));
pwdInputFile.postEntries(entries);
authHandler.initialize(new ServerConfig() {
@Override
public Properties toAuthHandlerProperties() {
Properties props = new Properties();
props.setProperty(AuthPluginConfig.BASIC_AUTHPLUGIN_DATABASE, pwdInputFile.getFile().getAbsolutePath());
return props;
}
});
ConcurrentHashMap<String, AccessControlList> aclsByUser = authHandler.getAclsByUser();
assertEquals(2, aclsByUser.size());
assertTrue(aclsByUser.containsKey("admin"));
assertEquals("prn::/scope:scope1", aclsByUser.get("appaccount").getEntries().get(0).getResourcePattern());
assertFalse(aclsByUser.containsKey("unauthorizeduser"));
}
}
Aggregations