use of org.apache.qpid.server.security.Result in project qpid-broker-j by apache.
the class RuleBasedAccessControlTest method testAccessIsDeniedIfRuleThrowsException.
public void testAccessIsDeniedIfRuleThrowsException() throws Exception {
final Subject subject = TestPrincipalUtils.createTestSubject("user1");
final InetAddress inetAddress = InetAddress.getLocalHost();
final InetSocketAddress inetSocketAddress = new InetSocketAddress(inetAddress, 1);
AMQPConnection connectionModel = mock(AMQPConnection.class);
when(connectionModel.getRemoteSocketAddress()).thenReturn(inetSocketAddress);
subject.getPrincipals().add(new ConnectionPrincipal(connectionModel));
Subject.doAs(subject, new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
RuleSet mockRuleSet = mock(RuleSet.class);
when(mockRuleSet.check(subject, LegacyOperation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY, inetAddress)).thenThrow(new RuntimeException());
RuleBasedAccessControl accessControl = new RuleBasedAccessControl(mockRuleSet, BrokerModel.getInstance());
Result result = accessControl.authorise(LegacyOperation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
assertEquals(Result.DENIED, result);
return null;
}
});
}
use of org.apache.qpid.server.security.Result in project qpid-broker-j by apache.
the class RuleBasedAccessControlTest method testNoSubjectAlwaysDefers.
/**
* ACL plugin must always defer if there is no subject attached to the thread.
*/
public void testNoSubjectAlwaysDefers() {
setUpGroupAccessControl();
final Result result = _plugin.authorise(LegacyOperation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
assertEquals(Result.DEFER, result);
}
Aggregations