use of org.apache.qpid.server.security.AccessControl in project qpid-broker-j by apache.
the class BrokerTestHelper method createAccessControlMock.
public static AccessControl createAccessControlMock() {
AccessControl mock = mock(AccessControl.class);
when(mock.authorise(any(SecurityToken.class), any(Operation.class), any(ConfiguredObject.class))).thenReturn(Result.DEFER);
when(mock.authorise(any(SecurityToken.class), any(Operation.class), any(ConfiguredObject.class), any(Map.class))).thenReturn(Result.DEFER);
when(mock.getDefault()).thenReturn(Result.ALLOWED);
return mock;
}
use of org.apache.qpid.server.security.AccessControl in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testUpdateVHNDeniedByACL.
// *************** VHN Access Control Tests ***************
public void testUpdateVHNDeniedByACL() throws Exception {
AccessControl mockAccessControl = mock(AccessControl.class);
DurableConfigurationStore configStore = configStoreThatProducesNoRecords();
Map<String, Object> nodeAttributes = new HashMap<>();
nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME);
nodeAttributes.put(VirtualHostNode.ID, _nodeId);
TestVirtualHostNode node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
node.setAccessControl(mockAccessControl);
node.open();
node.start();
when(mockAccessControl.authorise(eq(null), eq(Operation.UPDATE), same(node), any())).thenReturn(Result.DENIED);
assertNull(node.getDescription());
try {
node.setAttributes(Collections.<String, Object>singletonMap(VirtualHostNode.DESCRIPTION, "My virtualhost node"));
fail("Exception not throws");
} catch (AccessControlException ace) {
// PASS
}
assertNull("Description unexpected updated", node.getDescription());
node.close();
}
use of org.apache.qpid.server.security.AccessControl in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testStopVHNDeniedByACL.
public void testStopVHNDeniedByACL() throws Exception {
AccessControl mockAccessControl = mock(AccessControl.class);
DurableConfigurationStore configStore = configStoreThatProducesNoRecords();
Map<String, Object> nodeAttributes = new HashMap<>();
nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME);
nodeAttributes.put(VirtualHostNode.ID, _nodeId);
TestVirtualHostNode node = new TestVirtualHostNode(_broker, nodeAttributes, configStore);
node.setAccessControl(mockAccessControl);
node.open();
node.start();
when(mockAccessControl.authorise(eq(null), eq(Operation.UPDATE), same(node), any())).thenReturn(Result.DENIED);
try {
node.stop();
fail("Exception not throws");
} catch (AccessControlException ace) {
// PASS
}
assertEquals("Virtual host node state changed unexpectedly", State.ACTIVE, node.getState());
node.close();
}
Aggregations