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

yukon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-e2e.git


The following commit(s) were added to refs/heads/master by this push:
     new b035dd0  fix: initAcl (#45)
b035dd0 is described below

commit b035dd07bb7dceb536a4a2015c03076d6fe2073b
Author: Gezi-lzq <[email protected]>
AuthorDate: Wed Jul 12 15:22:07 2023 +0800

    fix: initAcl (#45)
    
    Signed-off-by: Gezi-lzq <[email protected]>
---
 .../java/org/apache/rocketmq/account/Account.java  | 108 ++-------------------
 .../factory/ClientConfigurationFactory.java        |  22 +++--
 .../org/apache/rocketmq/frame/ResourceInit.java    |   8 +-
 3 files changed, 27 insertions(+), 111 deletions(-)

diff --git a/java/e2e/src/main/java/org/apache/rocketmq/account/Account.java 
b/java/e2e/src/main/java/org/apache/rocketmq/account/Account.java
index 5f0866d..2bbe196 100644
--- a/java/e2e/src/main/java/org/apache/rocketmq/account/Account.java
+++ b/java/e2e/src/main/java/org/apache/rocketmq/account/Account.java
@@ -18,6 +18,7 @@
 package org.apache.rocketmq.account;
 
 public class Account {
+    protected Boolean aclEnable = false;
     /**
      * aliyun AccessKey
      */
@@ -26,66 +27,29 @@ public class Account {
      * aliyun SecretKey
      */
     protected String secretKey;
-    /**
-     * instanceUserName
-     */
-    protected String instanceUserName;
-    /**
-     * instancePassword
-     */
-    protected String instancePassword;
     /**
      * endpoint
      */
     protected String endpoint;
-    /**
-     * instanceId
-     */
-    protected String instanceId;
-    /**
-     * consoleEndpoint
-     */
-    protected String consoleEndpoint;
-    /**
-     * region
-     */
-    protected String regionId;
-    /**
-     * Account User ID
-     */
-    protected String userId;
-    /**
-     * Account User Name
-     */
-    protected String accountName;
-
-    public Account() {
-    }
 
     public Account(String endpoint) {
         this.endpoint = endpoint;
     }
 
-    public Account(String instanceUserName, String instancePassword) {
-        this.instanceUserName = instanceUserName;
-        this.instancePassword = instancePassword;
-    }
 
     public Account(String accessKey, String secretKey, String endpoint) {
         this.accessKey = accessKey;
         this.secretKey = secretKey;
         this.endpoint = endpoint;
+        this.aclEnable = true;
     }
 
-    public Account(String accessKey, String secretKey, String endpoint, String 
instanceId, String consoleEndpoint,
-        String regionId, String userId) {
-        this.accessKey = accessKey;
-        this.secretKey = secretKey;
-        this.endpoint = endpoint;
-        this.instanceId = instanceId;
-        this.consoleEndpoint = consoleEndpoint;
-        this.regionId = regionId;
-        this.userId = userId;
+    public Boolean getAclEnable() {
+        return aclEnable;
+    }
+
+    public void setAclEnable(Boolean aclEnable) {
+        this.aclEnable = aclEnable;
     }
 
     public String getAccessKey() {
@@ -104,22 +68,6 @@ public class Account {
         this.secretKey = secretKey;
     }
 
-    public String getInstanceUserName() {
-        return instanceUserName;
-    }
-
-    public void setInstanceUserName(String instanceUserName) {
-        this.instanceUserName = instanceUserName;
-    }
-
-    public String getInstancePassword() {
-        return instancePassword;
-    }
-
-    public void setInstancePassword(String instancePassword) {
-        this.instancePassword = instancePassword;
-    }
-
     public String getEndpoint() {
         return endpoint;
     }
@@ -127,44 +75,4 @@ public class Account {
     public void setEndpoint(String endpoint) {
         this.endpoint = endpoint;
     }
-
-    public String getInstanceId() {
-        return instanceId;
-    }
-
-    public void setInstanceId(String instanceId) {
-        this.instanceId = instanceId;
-    }
-
-    public String getConsoleEndpoint() {
-        return consoleEndpoint;
-    }
-
-    public void setConsoleEndpoint(String consoleEndpoint) {
-        this.consoleEndpoint = consoleEndpoint;
-    }
-
-    public String getRegionId() {
-        return regionId;
-    }
-
-    public void setRegionId(String regionId) {
-        this.regionId = regionId;
-    }
-
-    public String getUserId() {
-        return userId;
-    }
-
-    public void setUserId(String userId) {
-        this.userId = userId;
-    }
-
-    public String getAccountName() {
-        return accountName;
-    }
-
-    public void setAccountName(String accountName) {
-        this.accountName = accountName;
-    }
 }
diff --git 
a/java/e2e/src/main/java/org/apache/rocketmq/factory/ClientConfigurationFactory.java
 
b/java/e2e/src/main/java/org/apache/rocketmq/factory/ClientConfigurationFactory.java
index 45f43d1..be69114 100644
--- 
a/java/e2e/src/main/java/org/apache/rocketmq/factory/ClientConfigurationFactory.java
+++ 
b/java/e2e/src/main/java/org/apache/rocketmq/factory/ClientConfigurationFactory.java
@@ -20,16 +20,24 @@ package org.apache.rocketmq.factory;
 import java.time.Duration;
 import org.apache.rocketmq.account.Account;
 import org.apache.rocketmq.client.apis.ClientConfiguration;
+import org.apache.rocketmq.client.apis.StaticSessionCredentialsProvider;
 
 public class ClientConfigurationFactory {
-
     public static ClientConfiguration build(Account account) {
-//        StaticSessionCredentialsProvider staticSessionCredentialsProvider = 
new StaticSessionCredentialsProvider(account.getInstanceUserName(), 
account.getInstancePassword());
-        ClientConfiguration clientConfiguration = 
ClientConfiguration.newBuilder()
-            .setEndpoints(account.getEndpoint())
-            .setRequestTimeout(Duration.ofSeconds(10))
-//                .setCredentialProvider(staticSessionCredentialsProvider)
-            .build();
+        ClientConfiguration clientConfiguration;
+        if(account.getAclEnable()) {
+            StaticSessionCredentialsProvider staticSessionCredentialsProvider 
= new StaticSessionCredentialsProvider(account.getAccessKey(), 
account.getSecretKey());
+            clientConfiguration = ClientConfiguration.newBuilder()
+                    .setEndpoints(account.getEndpoint())
+                    .setRequestTimeout(Duration.ofSeconds(10))
+                    .setCredentialProvider(staticSessionCredentialsProvider)
+                    .build();
+        }else {
+            clientConfiguration = ClientConfiguration.newBuilder()
+                    .setEndpoints(account.getEndpoint())
+                    .setRequestTimeout(Duration.ofSeconds(10))
+                    .build();
+        }
         return clientConfiguration;
     }
 
diff --git a/java/e2e/src/main/java/org/apache/rocketmq/frame/ResourceInit.java 
b/java/e2e/src/main/java/org/apache/rocketmq/frame/ResourceInit.java
index cbc86a3..bf56c2b 100644
--- a/java/e2e/src/main/java/org/apache/rocketmq/frame/ResourceInit.java
+++ b/java/e2e/src/main/java/org/apache/rocketmq/frame/ResourceInit.java
@@ -91,10 +91,10 @@ public class ResourceInit {
     private static void initAcl() {
         aclEnable = Boolean.parseBoolean(System.getProperty("aclEnable", 
properties.getProperty("aclEnable", "false")));
         if (aclEnable) {
-            String instanceUsername = System.getProperty("INSTANCE_USERNAME", 
properties.getProperty("INSTANCE_USERNAME"));
-            String instancePassword = System.getProperty("INSTANCE_PASSWORD", 
properties.getProperty("INSTANCE_PASSWORD"));
-            account = new Account(instanceUsername, instancePassword);
-            log.info("INIT - acl is enabled, [instanceUsername:{}, 
instancePassword:{}]", instanceUsername, instancePassword);
+            String accessKey = System.getProperty("accessKey", 
properties.getProperty("accessKey"));
+            String secretKey = System.getProperty("secretKey", 
properties.getProperty("secretKey"));
+            account = new Account(accessKey, secretKey, endPoint);
+            log.info("INIT - acl is enabled, [accessKey:{}, secretKey:{}]", 
accessKey, secretKey);
         } else {
             log.info("INIT - acl is disabled");
             account = new Account(endPoint);

Reply via email to