From 1c36c991bb3212563b4d0a3887ef9a255f16243b Mon Sep 17 00:00:00 2001 From: Hu Zongtang Date: Mon, 18 Feb 2019 14:28:21 +0800 Subject: [PATCH] [issue#790]fix defaultTopicPerm and defaultGroupPerm values which are in yaml config file dosen't work. (#798) * [issue#790]fix defaultTopicPerm and defaultGroupPerm values which are in the yaml config file doesn't work. * [issue#790]fix defaultTopicPerm and defaultGroupPerm doesn't work,fix the unit test. --- .../org/apache/rocketmq/acl/plain/PlainPermissionLoader.java | 4 ++-- .../apache/rocketmq/acl/plain/PlainPermissionLoaderTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java index 1da7380b..9148422f 100644 --- a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java +++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java @@ -130,8 +130,8 @@ public class PlainPermissionLoader { if (!ownedPermMap.containsKey(resource)) { // Check the default perm - byte ownedPerm = isGroup ? needCheckedAccess.getDefaultGroupPerm() : - needCheckedAccess.getDefaultTopicPerm(); + byte ownedPerm = isGroup ? ownedAccess.getDefaultGroupPerm() : + ownedAccess.getDefaultTopicPerm(); if (!Permission.checkPermission(neededPerm, ownedPerm)) { throw new AclException(String.format("No default permission for %s", PlainAccessResource.printStr(resource, isGroup))); } diff --git a/acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionLoaderTest.java b/acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionLoaderTest.java index ebbc4fd2..575c9018 100644 --- a/acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionLoaderTest.java +++ b/acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionLoaderTest.java @@ -158,10 +158,10 @@ public class PlainPermissionLoaderTest { } @Test(expected = AclException.class) - public void checkErrorPerm() { + public void checkErrorPermDefaultValueNotMatch() { plainAccessResource = new PlainAccessResource(); - plainAccessResource.addResourceAndPerm("topicF", Permission.SUB); + plainAccessResource.addResourceAndPerm("topicF", Permission.PUB); plainPermissionLoader.checkPerm(plainAccessResource, SUBPlainAccessResource); } @Test(expected = AclException.class) -- GitLab