use of org.apache.qpid.server.model.AuthenticationProvider in project qpid-broker-j by apache.
the class RedirectingVirtualHostNodeTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
_broker = BrokerTestHelper.createBrokerMock();
SystemConfig<?> systemConfig = (SystemConfig<?>) _broker.getParent();
when(systemConfig.getObjectFactory()).thenReturn(new ConfiguredObjectFactoryImpl(mock(Model.class)));
_taskExecutor = new CurrentThreadTaskExecutor();
_taskExecutor.start();
when(_broker.getTaskExecutor()).thenReturn(_taskExecutor);
when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
AuthenticationProvider dummyAuthProvider = mock(AuthenticationProvider.class);
when(dummyAuthProvider.getName()).thenReturn("dummy");
when(dummyAuthProvider.getId()).thenReturn(UUID.randomUUID());
when(dummyAuthProvider.getMechanisms()).thenReturn(Arrays.asList("PLAIN"));
when(_broker.getChildren(eq(AuthenticationProvider.class))).thenReturn(Collections.singleton(dummyAuthProvider));
final Map<String, Object> attributes = new HashMap<>();
attributes.put(Port.NAME, getTestName());
attributes.put(Port.PORT, 0);
attributes.put(Port.AUTHENTICATION_PROVIDER, "dummy");
attributes.put(Port.TYPE, "AMQP");
_port = (AmqpPort) _broker.getObjectFactory().create(Port.class, attributes, _broker);
}
use of org.apache.qpid.server.model.AuthenticationProvider in project qpid-broker-j by apache.
the class PlainPasswordDatabaseAuthenticationManagerTest method testRemoveUser.
public void testRemoveUser() {
_passwordFile = TestFileUtils.createTempFile(this, ".user.password", "user:password");
Map<String, Object> providerAttrs = new HashMap<>();
providerAttrs.put(PlainPasswordDatabaseAuthenticationManager.TYPE, PROVIDER_TYPE);
providerAttrs.put(PlainPasswordDatabaseAuthenticationManager.PATH, _passwordFile.getAbsolutePath());
providerAttrs.put(PlainPasswordDatabaseAuthenticationManager.NAME, getTestName());
AuthenticationProvider provider = _objectFactory.create(AuthenticationProvider.class, providerAttrs, _broker);
assertThat(provider.getChildren(User.class).size(), is(equalTo(1)));
User user = (User) provider.getChildByName(User.class, "user");
user.delete();
assertThat(provider.getChildren(User.class).size(), is(equalTo(0)));
}
use of org.apache.qpid.server.model.AuthenticationProvider 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.model.AuthenticationProvider 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