use of org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManagerTest method testInitialiseWhenPasswordFileNotFound.
public void testInitialiseWhenPasswordFileNotFound() throws Exception {
PasswordCredentialManagingAuthenticationProvider mockAuthProvider = mock(PasswordCredentialManagingAuthenticationProvider.class);
when(mockAuthProvider.getContextValue(Integer.class, AbstractScramAuthenticationManager.QPID_AUTHMANAGER_SCRAM_ITERATION_COUNT)).thenReturn(4096);
_principalDatabase = new PlainPasswordFilePrincipalDatabase(mockAuthProvider);
setupManager(true);
try {
_manager.initialise();
fail("Initialisiation should fail when users file does not exist");
} catch (IllegalConfigurationException e) {
assertTrue(e.getCause() instanceof FileNotFoundException);
}
}
use of org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManagerTest method testInitialiseWhenPasswordFileExists.
public void testInitialiseWhenPasswordFileExists() throws Exception {
PasswordCredentialManagingAuthenticationProvider mockAuthProvider = mock(PasswordCredentialManagingAuthenticationProvider.class);
when(mockAuthProvider.getContextValue(Integer.class, AbstractScramAuthenticationManager.QPID_AUTHMANAGER_SCRAM_ITERATION_COUNT)).thenReturn(4096);
_principalDatabase = new PlainPasswordFilePrincipalDatabase(mockAuthProvider);
setupManager(true);
File f = new File(_passwordFileLocation);
f.createNewFile();
FileOutputStream fos = null;
try {
fos = new FileOutputStream(f);
fos.write("admin:admin".getBytes());
} finally {
if (fos != null) {
fos.close();
}
}
_manager.initialise();
List<Principal> users = _principalDatabase.getUsers();
assertEquals("Unexpected uses size", 1, users.size());
Principal p = _principalDatabase.getUser("admin");
assertEquals("Unexpected principal name", "admin", p.getName());
}
use of org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase in project qpid-broker-j by apache.
the class PlainPasswordFileAuthenticationManagerFactoryTest method testPlainInstanceCreated.
public void testPlainInstanceCreated() throws Exception {
_configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE);
_configuration.put("path", _emptyPasswordFile.getAbsolutePath());
AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
assertNotNull(manager);
assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager);
assertTrue(((PrincipalDatabaseAuthenticationManager) manager).getPrincipalDatabase() instanceof PlainPasswordFilePrincipalDatabase);
}
use of org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase in project qpid-broker-j by apache.
the class PlainPasswordFileAuthenticationManagerFactoryTest method testPasswordFileNotFound.
public void testPasswordFileNotFound() throws Exception {
// delete the file
_emptyPasswordFile.delete();
_configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE);
_configuration.put("path", _emptyPasswordFile.getAbsolutePath());
AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
assertNotNull(manager);
assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager);
assertTrue(((PrincipalDatabaseAuthenticationManager) manager).getPrincipalDatabase() instanceof PlainPasswordFilePrincipalDatabase);
}
Aggregations