gtully commented on a change in pull request #3849:
URL: https://github.com/apache/activemq-artemis/pull/3849#discussion_r752095660
##########
File path:
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/balancing/TargetKeyTest.java
##########
@@ -174,6 +194,43 @@ public void testUserNameKey() throws Exception {
Assert.assertEquals("admin", keys.get(0));
}
+ @Test
+ public void testRoleNameKeyLocalTarget() throws Exception {
+
+ ActiveMQJAASSecurityManager securityManager = new
ActiveMQJAASSecurityManager("PropertiesLogin");
+ servers[0] =
addServer(ActiveMQServers.newActiveMQServer(createDefaultConfig(true).setSecurityEnabled(true),
ManagementFactory.getPlatformMBeanServer(), securityManager, false));
+ setupBalancerServerWithLocalTarget(0, TargetKey.ROLE_NAME, "b", "b");
+
+ // ensure advisory permission is present for openwire connection
creation by 'b'
+ HierarchicalRepository<Set<Role>> securityRepository =
servers[0].getSecurityRepository();
+ Role role = new Role("b", true, true, true, true, true, true, false,
false, true, true);
+ Set<Role> roles = new HashSet<>();
+ roles.add(role);
+ securityRepository.addMatch("ActiveMQ.Advisory.#", roles);
+
+ startServers(0);
+
+ final int noRetriesSuchThatWeGetAnErrorOnRejection = 0;
+ ConnectionFactory connectionFactory = createFactory(protocol, false,
TransportConstants.DEFAULT_HOST,
+
TransportConstants.DEFAULT_PORT + 0, null, "a", "a",
noRetriesSuchThatWeGetAnErrorOnRejection);
+
+ // expect disconnect/reject as not role b
+ try (Connection connection = connectionFactory.createConnection()) {
+ connection.start();
+ fail("Expect to be rejected as not in role0");
+ } catch (Exception rejected) {
+ rejected.printStackTrace();
Review comment:
good catch, thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]