You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/07/20 05:56:17 UTC

[GitHub] [rocketmq] Oliverwqcwrw opened a new pull request, #4637: [Issue #4585] PlainPermissionManagerTest add unit test

Oliverwqcwrw opened a new pull request, #4637:
URL: https://github.com/apache/rocketmq/pull/4637

   **Make sure set the target branch to `develop`**
   
   ## What is the purpose of the change
   
   Close #4585 
   
   ## Brief changelog
   
   XX
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1192091735

   Thanks for your remind, I have solve it


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] coveralls commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
coveralls commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1192115384

   
   [![Coverage Status](https://coveralls.io/builds/51073494/badge)](https://coveralls.io/builds/51073494)
   
   Coverage increased (+0.8%) to 48.958% when pulling **163be58847774a3515f77452453a7e67b2ef754a on Oliverwqcwrw:develop-PlainPermissionManager-ut-30** into **e6b4e15ebf2d7542ad9d1246c047fc70fadc90a4 on apache:develop**.
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
lizhanhui commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r961230135


##########
common/src/main/java/org/apache/rocketmq/common/PlainAccessConfig.java:
##########
@@ -99,4 +99,18 @@ public List<String> getGroupPerms() {
     public void setGroupPerms(List<String> groupPerms) {
         this.groupPerms = groupPerms;
     }
+
+    @Override
+    public String toString() {
+        return "PlainAccessConfig{" +

Review Comment:
   It is awkward and error-prone to manually concatenate strings. Why not use JSON.toJsonString(this)?



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r961251538


##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -247,7 +259,7 @@ public void multiFilePathTest() {
 
     @Test
     public void testWatch() throws IOException, IllegalAccessException, InterruptedException {
-        File file = new File("src/test/resources");
+        File file = new File(PATH);
         System.setProperty("rocketmq.home.dir", file.getAbsolutePath());
 
         String fileName = System.getProperty("rocketmq.home.dir") + File.separator + "/conf/acl/plain_acl_test.yml";

Review Comment:
   Thank you for your advice
   
   I have changed to it as follows
   
   `private static final String PATH = PlainPermissionManagerTest.class.getResource(File.separator).getFile();`



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1214150150

   > Please modify this pr as others' suggestion, we will merge this pr, thanks! @Oliverwqcwrw
   
   Thanks for your review, I have solved it


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
caigy commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1217451742

   @Oliverwqcwrw Please fix test errors:
   
   ```
   Tests run: 25, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 27.275 sec <<< FAILURE! - in org.apache.rocketmq.client.consumer.DefaultLitePullConsumerTest
   unnecessary Mockito stubbings(org.apache.rocketmq.client.consumer.DefaultLitePullConsumerTest)  Time elapsed: 0.039 sec  <<< ERROR!
   org.mockito.exceptions.misusing.UnnecessaryStubbingException: 
   Unnecessary stubbings detected in test class: DefaultLitePullConsumerTest
   Clean & maintainable test code requires zero unnecessary code.
   Following stubbings are unnecessary (click to navigate to relevant line of code):
     1. -> at org.apache.rocketmq.client.consumer.DefaultLitePullConsumerTest.testPullTaskImpl_ProcessQueueNull(DefaultLitePullConsumerTest.java:356)
   Please remove unnecessary stubbings or use 'lenient' strictness. More info: javadoc for UnnecessaryStubbingException class.
   ```


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1212952699

   Hello @caigy 
   Thanks for your review, I have solved it


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
lizhanhui commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r943097563


##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -45,6 +54,8 @@ public class PlainPermissionManagerTest {
     PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
     Set<Integer> adminCode = new HashSet<>();
 
+    private static final String PATH = "src/test/resources";

Review Comment:
   Why not load test resources from classpath? It is a much more idiomatic



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] zongtanghu commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
zongtanghu commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r945125572


##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -45,6 +54,8 @@ public class PlainPermissionManagerTest {
     PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
     Set<Integer> adminCode = new HashSet<>();
 
+    private static final String PATH = "src/test/resources";

Review Comment:
   I also think so!It is a much more idiomatic!



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui merged pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
lizhanhui merged PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
caigy commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r944062306


##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -325,4 +336,77 @@ public void updateAccessConfigTest() {
         plainAccessConfig.setTopicPerms(Lists.newArrayList("topicA=SUB"));
         plainPermissionManager.updateAccessConfig(plainAccessConfig);
     }
+
+    @Test
+    public void getAllAclFilesTest() {
+        final List<String> notExistList = plainPermissionManager.getAllAclFiles("aa/bb");
+        Assertions.assertThat(notExistList).isEmpty();
+        final List<String> files = plainPermissionManager.getAllAclFiles(PATH);
+        Assertions.assertThat(files).isNotEmpty();
+    }
+
+    @Test
+    public void loadTest() {
+        plainPermissionManager.load();
+        final Map<String, DataVersion> map = plainPermissionManager.getDataVersionMap();
+        Assertions.assertThat(map).isNotEmpty();
+    }
+
+    @Test
+    public void updateAclConfigFileVersionTest() {
+        String aclFileName = "test_plain_acl";
+        Map<String, Object> updateAclConfigMap  = new HashMap<>();
+        List<Map<String, Object>> versionElement = new ArrayList<>();
+        Map<String, Object> accountsMap = new LinkedHashMap<>();
+        accountsMap.put(AclConstants.CONFIG_COUNTER, 1);
+        accountsMap.put(AclConstants.CONFIG_TIME_STAMP, System.currentTimeMillis());
+        versionElement.add(accountsMap);
+
+        updateAclConfigMap.put(AclConstants.CONFIG_DATA_VERSION, versionElement);
+        final Map<String, Object> map = plainPermissionManager.updateAclConfigFileVersion(aclFileName, updateAclConfigMap);
+        Assertions.assertThat(map).isNotEmpty();

Review Comment:
   It would be better to check actual data version is correct or not.



##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -20,20 +20,29 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.apache.commons.lang3.reflect.FieldUtils;
+import org.apache.rocketmq.acl.common.AclConstants;
 import org.apache.rocketmq.acl.common.AclException;
 import org.apache.rocketmq.acl.common.AclUtils;
 import org.apache.rocketmq.acl.common.Permission;
+import org.apache.rocketmq.common.AclConfig;
+import org.apache.rocketmq.common.DataVersion;
 import org.apache.rocketmq.common.PlainAccessConfig;
+import org.assertj.core.api.Assertions;
 import org.assertj.core.util.Lists;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.rocketmq.acl.plain.PlainAccessControlFlowTest.DEFAULT_TOPIC;

Review Comment:
   IMO this test is independent of `PlainAccessControlFlowTest`, you can maintain default topic of this test.



##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -325,4 +336,77 @@ public void updateAccessConfigTest() {
         plainAccessConfig.setTopicPerms(Lists.newArrayList("topicA=SUB"));
         plainPermissionManager.updateAccessConfig(plainAccessConfig);
     }
+
+    @Test
+    public void getAllAclFilesTest() {
+        final List<String> notExistList = plainPermissionManager.getAllAclFiles("aa/bb");
+        Assertions.assertThat(notExistList).isEmpty();
+        final List<String> files = plainPermissionManager.getAllAclFiles(PATH);
+        Assertions.assertThat(files).isNotEmpty();
+    }
+
+    @Test
+    public void loadTest() {
+        plainPermissionManager.load();
+        final Map<String, DataVersion> map = plainPermissionManager.getDataVersionMap();
+        Assertions.assertThat(map).isNotEmpty();
+    }
+
+    @Test
+    public void updateAclConfigFileVersionTest() {
+        String aclFileName = "test_plain_acl";
+        Map<String, Object> updateAclConfigMap  = new HashMap<>();
+        List<Map<String, Object>> versionElement = new ArrayList<>();
+        Map<String, Object> accountsMap = new LinkedHashMap<>();
+        accountsMap.put(AclConstants.CONFIG_COUNTER, 1);
+        accountsMap.put(AclConstants.CONFIG_TIME_STAMP, System.currentTimeMillis());
+        versionElement.add(accountsMap);
+
+        updateAclConfigMap.put(AclConstants.CONFIG_DATA_VERSION, versionElement);
+        final Map<String, Object> map = plainPermissionManager.updateAclConfigFileVersion(aclFileName, updateAclConfigMap);
+        Assertions.assertThat(map).isNotEmpty();
+    }
+
+    @Test
+    public void createAclAccessConfigMapTest() {
+        Map<String, Object> existedAccountMap =  new HashMap<>();
+        plainAccessConfig.setAccessKey("admin123");
+        plainAccessConfig.setSecretKey("12345678");
+        plainAccessConfig.setWhiteRemoteAddress("192.168.1.1");
+        plainAccessConfig.setAdmin(false);
+        plainAccessConfig.setDefaultGroupPerm(AclConstants.SUB_PUB);
+        plainAccessConfig.setTopicPerms(Arrays.asList(DEFAULT_TOPIC + "=" + AclConstants.PUB));
+        plainAccessConfig.setGroupPerms(Lists.newArrayList("groupA=SUB"));
+
+        final Map<String, Object> map = plainPermissionManager.createAclAccessConfigMap(existedAccountMap, plainAccessConfig);
+        Assertions.assertThat(map).isNotEmpty();
+    }
+
+    @Test
+    public void deleteAccessConfigTest() {
+        // delete not exist accessConfig
+        final boolean flag1 = plainPermissionManager.deleteAccessConfig("admin123");
+        assert flag1 == false;
+        //delete existed accessConfig
+        final AclConfig config = plainPermissionManager.getAllAclConfig();
+        final List<PlainAccessConfig> configs = config.getPlainAccessConfigs();
+        final PlainAccessConfig config1 = configs.get(0);
+        final String accessKey = config1.getAccessKey();
+        final boolean flag2 = plainPermissionManager.deleteAccessConfig(accessKey);

Review Comment:
   It may cause side effects if `PlainAccessConfig` is changed but not restored.



##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -325,4 +336,77 @@ public void updateAccessConfigTest() {
         plainAccessConfig.setTopicPerms(Lists.newArrayList("topicA=SUB"));
         plainPermissionManager.updateAccessConfig(plainAccessConfig);
     }
+
+    @Test
+    public void getAllAclFilesTest() {
+        final List<String> notExistList = plainPermissionManager.getAllAclFiles("aa/bb");
+        Assertions.assertThat(notExistList).isEmpty();
+        final List<String> files = plainPermissionManager.getAllAclFiles(PATH);
+        Assertions.assertThat(files).isNotEmpty();
+    }
+
+    @Test
+    public void loadTest() {
+        plainPermissionManager.load();
+        final Map<String, DataVersion> map = plainPermissionManager.getDataVersionMap();
+        Assertions.assertThat(map).isNotEmpty();
+    }
+
+    @Test
+    public void updateAclConfigFileVersionTest() {
+        String aclFileName = "test_plain_acl";
+        Map<String, Object> updateAclConfigMap  = new HashMap<>();
+        List<Map<String, Object>> versionElement = new ArrayList<>();
+        Map<String, Object> accountsMap = new LinkedHashMap<>();
+        accountsMap.put(AclConstants.CONFIG_COUNTER, 1);
+        accountsMap.put(AclConstants.CONFIG_TIME_STAMP, System.currentTimeMillis());
+        versionElement.add(accountsMap);
+
+        updateAclConfigMap.put(AclConstants.CONFIG_DATA_VERSION, versionElement);
+        final Map<String, Object> map = plainPermissionManager.updateAclConfigFileVersion(aclFileName, updateAclConfigMap);
+        Assertions.assertThat(map).isNotEmpty();
+    }
+
+    @Test
+    public void createAclAccessConfigMapTest() {
+        Map<String, Object> existedAccountMap =  new HashMap<>();
+        plainAccessConfig.setAccessKey("admin123");
+        plainAccessConfig.setSecretKey("12345678");
+        plainAccessConfig.setWhiteRemoteAddress("192.168.1.1");
+        plainAccessConfig.setAdmin(false);
+        plainAccessConfig.setDefaultGroupPerm(AclConstants.SUB_PUB);
+        plainAccessConfig.setTopicPerms(Arrays.asList(DEFAULT_TOPIC + "=" + AclConstants.PUB));
+        plainAccessConfig.setGroupPerms(Lists.newArrayList("groupA=SUB"));
+
+        final Map<String, Object> map = plainPermissionManager.createAclAccessConfigMap(existedAccountMap, plainAccessConfig);
+        Assertions.assertThat(map).isNotEmpty();
+    }
+
+    @Test
+    public void deleteAccessConfigTest() {
+        // delete not exist accessConfig
+        final boolean flag1 = plainPermissionManager.deleteAccessConfig("admin123");
+        assert flag1 == false;
+        //delete existed accessConfig
+        final AclConfig config = plainPermissionManager.getAllAclConfig();
+        final List<PlainAccessConfig> configs = config.getPlainAccessConfigs();
+        final PlainAccessConfig config1 = configs.get(0);
+        final String accessKey = config1.getAccessKey();
+        final boolean flag2 = plainPermissionManager.deleteAccessConfig(accessKey);
+        assert flag2 == true;
+
+    }
+
+    @Test
+    public void updateGlobalWhiteAddrsConfigTest() {
+        final boolean flag = plainPermissionManager.updateGlobalWhiteAddrsConfig(Lists.newArrayList("192.168.1.2"));
+        assert flag == true;

Review Comment:
   You may check the actual content of global white lists.



##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -325,4 +336,77 @@ public void updateAccessConfigTest() {
         plainAccessConfig.setTopicPerms(Lists.newArrayList("topicA=SUB"));
         plainPermissionManager.updateAccessConfig(plainAccessConfig);
     }
+
+    @Test
+    public void getAllAclFilesTest() {
+        final List<String> notExistList = plainPermissionManager.getAllAclFiles("aa/bb");
+        Assertions.assertThat(notExistList).isEmpty();
+        final List<String> files = plainPermissionManager.getAllAclFiles(PATH);
+        Assertions.assertThat(files).isNotEmpty();
+    }
+
+    @Test
+    public void loadTest() {
+        plainPermissionManager.load();
+        final Map<String, DataVersion> map = plainPermissionManager.getDataVersionMap();
+        Assertions.assertThat(map).isNotEmpty();
+    }
+
+    @Test
+    public void updateAclConfigFileVersionTest() {
+        String aclFileName = "test_plain_acl";
+        Map<String, Object> updateAclConfigMap  = new HashMap<>();
+        List<Map<String, Object>> versionElement = new ArrayList<>();
+        Map<String, Object> accountsMap = new LinkedHashMap<>();
+        accountsMap.put(AclConstants.CONFIG_COUNTER, 1);
+        accountsMap.put(AclConstants.CONFIG_TIME_STAMP, System.currentTimeMillis());
+        versionElement.add(accountsMap);
+
+        updateAclConfigMap.put(AclConstants.CONFIG_DATA_VERSION, versionElement);
+        final Map<String, Object> map = plainPermissionManager.updateAclConfigFileVersion(aclFileName, updateAclConfigMap);
+        Assertions.assertThat(map).isNotEmpty();
+    }
+
+    @Test
+    public void createAclAccessConfigMapTest() {
+        Map<String, Object> existedAccountMap =  new HashMap<>();
+        plainAccessConfig.setAccessKey("admin123");
+        plainAccessConfig.setSecretKey("12345678");
+        plainAccessConfig.setWhiteRemoteAddress("192.168.1.1");
+        plainAccessConfig.setAdmin(false);
+        plainAccessConfig.setDefaultGroupPerm(AclConstants.SUB_PUB);
+        plainAccessConfig.setTopicPerms(Arrays.asList(DEFAULT_TOPIC + "=" + AclConstants.PUB));
+        plainAccessConfig.setGroupPerms(Lists.newArrayList("groupA=SUB"));
+
+        final Map<String, Object> map = plainPermissionManager.createAclAccessConfigMap(existedAccountMap, plainAccessConfig);
+        Assertions.assertThat(map).isNotEmpty();

Review Comment:
   You'd better add more checks on `map`.



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r945134811


##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -45,6 +54,8 @@ public class PlainPermissionManagerTest {
     PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
     Set<Integer> adminCode = new HashSet<>();
 
+    private static final String PATH = "src/test/resources";

Review Comment:
   Thanks  for your review, I have  solved it



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
lizhanhui commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r961230135


##########
common/src/main/java/org/apache/rocketmq/common/PlainAccessConfig.java:
##########
@@ -99,4 +99,18 @@ public List<String> getGroupPerms() {
     public void setGroupPerms(List<String> groupPerms) {
         this.groupPerms = groupPerms;
     }
+
+    @Override
+    public String toString() {
+        return "PlainAccessConfig{" +

Review Comment:
   It is awkward and error-prone to manually concatenate strings



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1217767670

   > @Oliverwqcwrw Please fix test errors:
   > 
   > ```
   > Tests run: 25, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 27.275 sec <<< FAILURE! - in org.apache.rocketmq.client.consumer.DefaultLitePullConsumerTest
   > unnecessary Mockito stubbings(org.apache.rocketmq.client.consumer.DefaultLitePullConsumerTest)  Time elapsed: 0.039 sec  <<< ERROR!
   > org.mockito.exceptions.misusing.UnnecessaryStubbingException: 
   > Unnecessary stubbings detected in test class: DefaultLitePullConsumerTest
   > Clean & maintainable test code requires zero unnecessary code.
   > Following stubbings are unnecessary (click to navigate to relevant line of code):
   >   1. -> at org.apache.rocketmq.client.consumer.DefaultLitePullConsumerTest.testPullTaskImpl_ProcessQueueNull(DefaultLitePullConsumerTest.java:356)
   > Please remove unnecessary stubbings or use 'lenient' strictness. More info: javadoc for UnnecessaryStubbingException class.
   > ```
   
   Thanks for your review
   Which branch is your code? This branch of mine does not have this problem
   <img width="1087" alt="image" src="https://user-images.githubusercontent.com/31796988/185086083-bc5cbaf6-51dd-41a6-99f3-f898346b1d89.png">
   
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
caigy commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1217979383

   @Oliverwqcwrw Please refer to the result of Travis Ci: https://github.com/apache/rocketmq/pull/4637/checks?check_run_id=7819279185


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
lizhanhui commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r961229311


##########
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java:
##########
@@ -247,7 +259,7 @@ public void multiFilePathTest() {
 
     @Test
     public void testWatch() throws IOException, IllegalAccessException, InterruptedException {
-        File file = new File("src/test/resources");
+        File file = new File(PATH);
         System.setProperty("rocketmq.home.dir", file.getAbsolutePath());
 
         String fileName = System.getProperty("rocketmq.home.dir") + File.separator + "/conf/acl/plain_acl_test.yml";

Review Comment:
   This line will not be compatible with Windows



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] caigy commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
caigy commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1220250822

   @Oliverwqcwrw Actually your branch is checked out.
   ![image](https://user-images.githubusercontent.com/17410645/185545814-9728aa1b-c38a-42fd-9836-13f5d3ef235d.png)
   
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r961252626


##########
common/src/main/java/org/apache/rocketmq/common/PlainAccessConfig.java:
##########
@@ -99,4 +99,18 @@ public List<String> getGroupPerms() {
     public void setGroupPerms(List<String> groupPerms) {
         this.groupPerms = groupPerms;
     }
+
+    @Override
+    public String toString() {
+        return "PlainAccessConfig{" +

Review Comment:
   This toString is generated automatically by the editor I'm using, but for security reasons I've omitted the printing of SecretKey
   



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] lizhanhui commented on a diff in pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
lizhanhui commented on code in PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#discussion_r961230135


##########
common/src/main/java/org/apache/rocketmq/common/PlainAccessConfig.java:
##########
@@ -99,4 +99,18 @@ public List<String> getGroupPerms() {
     public void setGroupPerms(List<String> groupPerms) {
         this.groupPerms = groupPerms;
     }
+
+    @Override
+    public String toString() {
+        return "PlainAccessConfig{" +

Review Comment:
   It is awkward and error-prone to manually concatenate strings. Why not use JSON.toJsonString(this)?
   
   Another thing, it would be better to omit the access secret part for safety reasons.



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] codecov-commenter commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1198875422

   # [Codecov](https://codecov.io/gh/apache/rocketmq/pull/4637?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#4637](https://codecov.io/gh/apache/rocketmq/pull/4637?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5af2e4e) into [develop](https://codecov.io/gh/apache/rocketmq/commit/96fb142569b3e3a5560ec57c84e351363841cf94?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (96fb142) will **decrease** coverage by `0.15%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@              Coverage Diff              @@
   ##             develop    #4637      +/-   ##
   =============================================
   - Coverage      44.74%   44.59%   -0.16%     
   + Complexity      7537     7523      -14     
   =============================================
     Files            977      977              
     Lines          67601    67611      +10     
     Branches        8929     8930       +1     
   =============================================
   - Hits           30250    30152      -98     
   - Misses         33606    33711     +105     
   - Partials        3745     3748       +3     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/rocketmq/pull/4637?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ain/java/org/apache/rocketmq/common/AclConfig.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vQWNsQ29uZmlnLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../org/apache/rocketmq/common/PlainAccessConfig.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vUGxhaW5BY2Nlc3NDb25maWcuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [.../broker/subscription/SubscriptionGroupManager.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvc3Vic2NyaXB0aW9uL1N1YnNjcmlwdGlvbkdyb3VwTWFuYWdlci5qYXZh) | `68.79% <0.00%> (-14.19%)` | :arrow_down: |
   | [...n/java/org/apache/rocketmq/test/util/StatUtil.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvdGVzdC91dGlsL1N0YXRVdGlsLmphdmE=) | `16.19% <0.00%> (-14.09%)` | :arrow_down: |
   | [...va/org/apache/rocketmq/logging/inner/Appender.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bG9nZ2luZy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvbG9nZ2luZy9pbm5lci9BcHBlbmRlci5qYXZh) | `29.21% <0.00%> (-7.87%)` | :arrow_down: |
   | [...ache/rocketmq/broker/topic/TopicConfigManager.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvdG9waWMvVG9waWNDb25maWdNYW5hZ2VyLmphdmE=) | `59.03% <0.00%> (-3.06%)` | :arrow_down: |
   | [...ava/org/apache/rocketmq/test/util/VerifyUtils.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-dGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvdGVzdC91dGlsL1ZlcmlmeVV0aWxzLmphdmE=) | `46.26% <0.00%> (-2.99%)` | :arrow_down: |
   | [...ava/org/apache/rocketmq/filter/util/BitsArray.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmlsdGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9maWx0ZXIvdXRpbC9CaXRzQXJyYXkuamF2YQ==) | `59.82% <0.00%> (-2.57%)` | :arrow_down: |
   | [...tmq/namesrv/processor/DefaultRequestProcessor.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bmFtZXNydi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvbmFtZXNydi9wcm9jZXNzb3IvRGVmYXVsdFJlcXVlc3RQcm9jZXNzb3IuamF2YQ==) | `60.33% <0.00%> (-1.99%)` | :arrow_down: |
   | [...java/org/apache/rocketmq/logging/inner/Logger.java](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bG9nZ2luZy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvbG9nZ2luZy9pbm5lci9Mb2dnZXIuamF2YQ==) | `54.06% <0.00%> (-1.92%)` | :arrow_down: |
   | ... and [16 more](https://codecov.io/gh/apache/rocketmq/pull/4637/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] Oliverwqcwrw commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1218005703

   Hello @caigy ,
   I noticed that the code is compiling the develop branch code, so help trigger the compilation of my branch code
   <img width="931" alt="image" src="https://user-images.githubusercontent.com/31796988/185144937-90b1912d-1292-4b6c-be98-8d98579b125a.png">
   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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq] zongtanghu commented on pull request #4637: [ISSUE #4585] PlainPermissionManagerTest add unit test

Posted by GitBox <gi...@apache.org>.
zongtanghu commented on PR #4637:
URL: https://github.com/apache/rocketmq/pull/4637#issuecomment-1214137811

   Please modify this pr as others' suggestion, we will merge this pr, thanks! @Oliverwqcwrw 


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org