activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [activemq-artemis] branch main updated: ARTEMIS-3339 Fix management role match key comparator
Date Tue, 15 Jun 2021 19:07:05 GMT
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new b1d326b  ARTEMIS-3339 Fix management role match key comparator
b1d326b is described below

commit b1d326ba8be43db3fe4724872d2871d2efb05294
Author: Domenico Francesco Bruscino <brusdev@apache.org>
AuthorDate: Tue Jun 15 15:07:58 2021 +0200

    ARTEMIS-3339 Fix management role match key comparator
---
 .../artemis/core/server/management/JMXAccessControlList.java       | 7 ++++---
 .../artemis/core/server/management/JMXAccessControlListTest.java   | 7 +++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/JMXAccessControlList.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/JMXAccessControlList.java
index f09e91a..956726c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/JMXAccessControlList.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/JMXAccessControlList.java
@@ -41,10 +41,11 @@ public class JMXAccessControlList {
          return +1;
       } else if (!key1ContainsWildCard && key2ContainsWildcard) {
          return -1;
-      } else if (key1ContainsWildCard && key2ContainsWildcard) {
-         return key2.length() - key1.length();
+      } else if (key1.length() == key2.length()) {
+         return key1.compareTo(key2);
       }
-      return key1.length() - key2.length();
+
+      return key2.length() - key1.length();
    };
 
    public void addToWhiteList(String domain, String key) {
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/management/JMXAccessControlListTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/management/JMXAccessControlListTest.java
index e0b0233..9fe549c 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/management/JMXAccessControlListTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/management/JMXAccessControlListTest.java
@@ -99,10 +99,13 @@ public class JMXAccessControlListTest {
    public void testBasicRoleWithWildcardInKey() throws MalformedObjectNameException {
       JMXAccessControlList controlList = new JMXAccessControlList();
       controlList.addToRoleAccess("org.myDomain", "type=foo*","listSomething", "update");
+      controlList.addToRoleAccess("org.myDomain", "type=bar*","listSomething", "browse");
       controlList.addToRoleAccess("org.myDomain", "type=foo.bar*","listSomething", "admin");
       controlList.addToRoleAccess("org.myDomain", null,"listSomething", "view");
-      List<String> roles = controlList.getRolesForObject(new ObjectName("org.myDomain:type=foo.bar.test"),
"listSomething");
-      Assert.assertArrayEquals(roles.toArray(), new String[]{"admin"});
+      Assert.assertArrayEquals(controlList.getRolesForObject(new ObjectName("org.myDomain:type=foo.bar.test"),
+         "listSomething").toArray(), new String[]{"admin"});
+      Assert.assertArrayEquals(controlList.getRolesForObject(new ObjectName("org.myDomain:type=bar.test"),
+         "listSomething").toArray(), new String[]{"browse"});
    }
 
    @Test

Mime
View raw message