use of org.apache.qpid.server.security.limit.ConnectionLimitException in project qpid-broker-j by apache.
the class RuleSetTest method testBlocked.
private void testBlocked(RuleSet ruleSet) {
assertNotNull(ruleSet);
ConnectionSlot connection = null;
try {
connection = ruleSet.register(newConnection());
fail("An exception is expected");
} catch (ConnectionLimitException e) {
assertEquals("User user is blocked on port amqp", e.getMessage());
}
assertNull(connection);
}
use of org.apache.qpid.server.security.limit.ConnectionLimitException in project qpid-broker-j by apache.
the class RuleSetTest method testRegisterNullUser.
private void testRegisterNullUser(Duration duration) {
final Builder builder = RuleSet.newBuilder(LIMITER_NAME, duration);
builder.addRule(Rule.newBlockingRule(RulePredicates.ALL_PORTS, RulePredicates.ALL_USERS));
final RuleSet ruleSet = builder.build();
assertNotNull(ruleSet);
final AMQPConnection<?> connection = Mockito.mock(AMQPConnection.class);
Mockito.doReturn(_port).when(connection).getPort();
Mockito.doReturn(_subject).when(connection).getSubject();
Mockito.doReturn(_eventLogger).when(connection).getEventLogger();
try {
ruleSet.register(connection);
fail("An exception is expected");
} catch (ConnectionLimitException e) {
assertEquals("Unauthorized connection is forbidden", e.getMessage());
}
}
Aggregations