use of org.apache.qpid.server.logging.EventLoggerProvider in project qpid-broker-j by apache.
the class RuleBasedAccessControlTest method createGroupRuleSet.
private RuleSet createGroupRuleSet() {
final EventLoggerProvider provider = mock(EventLoggerProvider.class);
when(provider.getEventLogger()).thenReturn(_eventLogger);
RuleCollector rsc = new RuleCollector();
// Rule expressed with username
rsc.addRule(0, new Rule.Builder().withIdentity("user1").withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).build());
// Rules expressed with groups
rsc.addRule(1, new Rule.Builder().withIdentity(ALLOWED_GROUP).withOutcome(RuleOutcome.ALLOW).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).build());
rsc.addRule(2, new Rule.Builder().withIdentity(DENIED_GROUP).withOutcome(RuleOutcome.DENY).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).build());
// Catch all rule
rsc.addRule(3, new Rule.Builder().withIdentity(Rule.ALL).withOutcome(RuleOutcome.DENY_LOG).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).build());
return rsc.createRuleSet(provider);
}
use of org.apache.qpid.server.logging.EventLoggerProvider in project qpid-broker-j by apache.
the class RuleSetTest method testGetDefault.
@Test
public void testGetDefault() {
final Rule rule = new Builder().withIdentity(TEST_USER).withOperation(LegacyOperation.ACCESS).withObject(ObjectType.VIRTUALHOST).withOutcome(RuleOutcome.ALLOW).build();
final EventLoggerProvider logger = mock(EventLoggerProvider.class);
final RuleSet ruleSet = RuleSet.newInstance(logger, Collections.singletonList(rule), Result.ALLOWED);
assertNotNull(ruleSet);
assertEquals(Result.ALLOWED, ruleSet.getDefault());
}
use of org.apache.qpid.server.logging.EventLoggerProvider in project qpid-broker-j by apache.
the class AcceptRegistrationTest method setUp.
@Before
public void setUp() {
_eventLogger = Mockito.mock(org.apache.qpid.server.logging.EventLogger.class);
final EventLoggerProvider provider = () -> _eventLogger;
_logger = new FullConnectionLimitEventLogger("AllLogger", provider);
_rejectLogger = new ConnectionLimitEventLogger("RejectLogger", provider);
_slot = Mockito.mock(ConnectionSlot.class);
}
use of org.apache.qpid.server.logging.EventLoggerProvider in project qpid-broker-j by apache.
the class LoginLogoutReporterTest method setUp.
@Before
public void setUp() throws Exception {
_subject.getPrincipals().add(new AuthenticatedPrincipal(new UsernamePrincipal("mockusername", null)));
when(_logger.isEnabled()).thenReturn(true);
when(_logger.isMessageEnabled(anyString())).thenReturn(true);
EventLogger eventLogger = new EventLogger(_logger);
EventLoggerProvider provider = mock(EventLoggerProvider.class);
when(provider.getEventLogger()).thenReturn(eventLogger);
_loginLogoutReport = new LoginLogoutReporter(_subject, provider);
}
use of org.apache.qpid.server.logging.EventLoggerProvider in project qpid-broker-j by apache.
the class MessagingACLTest method configureACL.
private void configureACL(String... rules) throws Exception {
EventLoggerProvider eventLoggerProvider = mock(EventLoggerProvider.class);
EventLogger eventLogger = mock(EventLogger.class);
when(eventLoggerProvider.getEventLogger()).thenReturn(eventLogger);
List<AclRule> aclRules = new ArrayList<>();
try (StringReader stringReader = new StringReader(Arrays.stream(rules).collect(Collectors.joining(LINE_SEPARATOR)))) {
RuleSet ruleSet = AclFileParser.parse(stringReader, eventLoggerProvider);
for (final Rule rule : ruleSet) {
aclRules.add(rule.asAclRule());
}
}
configureACL(aclRules.toArray(new AclRule[aclRules.size()]));
}
Aggregations