This is an automated email from the ASF dual-hosted git repository.

duhengforever pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 8cb34fb7e Add unit test
     new 29713cb22 Merge pull request #4586 from Oliverwqcwrw/develop-add-ut-20
8cb34fb7e is described below

commit 8cb34fb7e7d512dc146c3a49579bcaf37f86f092
Author: Oliver <[email protected]>
AuthorDate: Tue Jul 12 16:36:12 2022 +0800

    Add unit test
---
 .../acl/plain/PlainPermissionManagerTest.java      | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git 
a/acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java
 
b/acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java
index 0706b850c..eafc62345 100644
--- 
a/acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java
+++ 
b/acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionManagerTest.java
@@ -29,6 +29,7 @@ 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.PlainAccessConfig;
+import org.assertj.core.util.Lists;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -300,4 +301,28 @@ public class PlainPermissionManagerTest {
         transport.delete();
         System.setProperty("rocketmq.home.dir", "src/test/resources");
     }
+    
+    @Test
+    public void updateAccessConfigTest() {
+        Assert.assertThrows(AclException.class, () -> 
plainPermissionManager.updateAccessConfig(null));
+        
+        plainAccessConfig.setAccessKey("admin_test");
+        // Invalid parameter
+        plainAccessConfig.setSecretKey("123456");
+        plainAccessConfig.setAdmin(true);
+        Assert.assertThrows(AclException.class, () -> 
plainPermissionManager.updateAccessConfig(plainAccessConfig));
+        
+        plainAccessConfig.setSecretKey("12345678");
+        // Invalid parameter
+        plainAccessConfig.setGroupPerms(Lists.newArrayList("groupA!SUB"));
+        Assert.assertThrows(AclException.class, () -> 
plainPermissionManager.updateAccessConfig(plainAccessConfig));
+        
+        // first update
+        plainAccessConfig.setGroupPerms(Lists.newArrayList("groupA=SUB"));
+        plainPermissionManager.updateAccessConfig(plainAccessConfig);
+        
+        // second update
+        plainAccessConfig.setTopicPerms(Lists.newArrayList("topicA=SUB"));
+        plainPermissionManager.updateAccessConfig(plainAccessConfig);
+    }
 }

Reply via email to