use of org.apache.qpid.server.model.AccessControlProvider in project qpid-broker-j by apache.
the class AclFileAccessControlProviderFactoryTest method testCreateInstanceWhenAclFileIsSpecified.
public void testCreateInstanceWhenAclFileIsSpecified() {
File aclFile = TestFileUtils.createTempFile(this, ".acl", "ACL ALLOW all all");
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(AccessControlProvider.ID, UUID.randomUUID());
attributes.put(AccessControlProvider.NAME, "acl");
attributes.put(AccessControlProvider.TYPE, AclFileAccessControlProvider.ACL_FILE_PROVIDER_TYPE);
attributes.put(AclFileAccessControlProvider.PATH, aclFile.getAbsolutePath());
AccessControlProvider acl = _objectFactory.create(AccessControlProvider.class, attributes, _broker);
assertNotNull("ACL was not created from acl file: " + aclFile.getAbsolutePath(), acl);
}
use of org.apache.qpid.server.model.AccessControlProvider in project qpid-broker-j by apache.
the class AclFileAccessControlProviderFactoryTest method testCreateInstanceWhenAclFileIsSpecifiedButDoesNotExist.
public void testCreateInstanceWhenAclFileIsSpecifiedButDoesNotExist() {
File aclFile = new File(TMP_FOLDER, "my-non-existing-acl-" + System.currentTimeMillis());
assertFalse("ACL file " + aclFile.getAbsolutePath() + " actually exists but should not", aclFile.exists());
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(AccessControlProvider.ID, UUID.randomUUID());
attributes.put(AccessControlProvider.NAME, "acl");
attributes.put(AccessControlProvider.TYPE, AclFileAccessControlProvider.ACL_FILE_PROVIDER_TYPE);
attributes.put(AclFileAccessControlProvider.PATH, aclFile.getAbsolutePath());
try {
AccessControlProvider control = _objectFactory.create(AccessControlProvider.class, attributes, _broker);
fail("It should not be possible to create and initialise ACL with non existing file");
} catch (IllegalConfigurationException e) {
assertTrue("Unexpected exception message: " + e.getMessage(), Pattern.matches("Cannot convert .* to a readable resource", e.getMessage()));
}
}
use of org.apache.qpid.server.model.AccessControlProvider in project qpid-broker-j by apache.
the class AclFileAccessControlProviderFactoryTest method testCreateInstanceWhenAclFileIsNotPresent.
public void testCreateInstanceWhenAclFileIsNotPresent() {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(AccessControlProvider.ID, UUID.randomUUID());
attributes.put(AccessControlProvider.NAME, "acl");
attributes.put(AccessControlProvider.TYPE, AclFileAccessControlProvider.ACL_FILE_PROVIDER_TYPE);
try {
AccessControlProvider acl = _objectFactory.create(AccessControlProvider.class, attributes, _broker);
fail("ACL was created without a configuration file path specified");
} catch (IllegalArgumentException e) {
// pass
}
}
Aggregations