[ISSUE #4624] Add plain_acl_bak.xml for reset at test case start. (#4625)

* add plain_acl_bak.xml to reset at test case start.

* add license

* reset file at test case start
This commit is contained in:
lizhiboo
2022-07-18 17:28:23 +08:00
committed by GitHub
parent ac6ccc5445
commit d930cb96ad
2 changed files with 80 additions and 16 deletions
@@ -470,9 +470,12 @@ public class PlainAccessValidatorTest {
@Test
public void addAccessAclYamlConfigTest() throws InterruptedException {
String backupFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl_bak.yml".replace("/", File.separator);
String targetFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(targetFileName, Map.class);
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(backupFileName, Map.class);
AclUtils.writeDataObject(targetFileName, backUpAclConfigMap);
PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
plainAccessConfig.setAccessKey("rocketmq3");
@@ -552,8 +555,12 @@ public class PlainAccessValidatorTest {
@Test
public void updateAccessAclYamlConfigTest() throws InterruptedException {
String targetFileName = System.getProperty("rocketmq.home.dir") + File.separator + "conf/plain_acl.yml";
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(targetFileName, Map.class);
String backupFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl_bak.yml".replace("/", File.separator);
String targetFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(backupFileName, Map.class);
AclUtils.writeDataObject(targetFileName, backUpAclConfigMap);
PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
plainAccessConfig.setAccessKey("rocketmq3");
@@ -628,9 +635,12 @@ public class PlainAccessValidatorTest {
@Test
public void deleteAccessAclYamlConfigTest() throws InterruptedException {
String backupFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl_bak.yml".replace("/", File.separator);
String targetFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(targetFileName, Map.class);
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(backupFileName, Map.class);
AclUtils.writeDataObject(targetFileName, backUpAclConfigMap);
PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
plainAccessConfig.setAccessKey("rocketmq3");
@@ -676,9 +686,12 @@ public class PlainAccessValidatorTest {
@Test
public void updateGlobalWhiteRemoteAddressesTest() throws InterruptedException {
String backupFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl_bak.yml".replace("/", File.separator);
String targetFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(targetFileName, Map.class);
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(backupFileName, Map.class);
AclUtils.writeDataObject(targetFileName, backUpAclConfigMap);
List<String> globalWhiteAddrsList = new ArrayList<>();
globalWhiteAddrsList.add("192.168.1.*");
@@ -794,9 +807,12 @@ public class PlainAccessValidatorTest {
@Test(expected = AclException.class)
public void createAndUpdateAccessAclNullSkExceptionTest() {
String backupFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl_bak.yml".replace("/", File.separator);
String targetFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/acl/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(targetFileName, Map.class);
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(backupFileName, Map.class);
AclUtils.writeDataObject(targetFileName, backUpAclConfigMap);
PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
plainAccessConfig.setAccessKey("RocketMQ33");
@@ -811,9 +827,12 @@ public class PlainAccessValidatorTest {
@Test
public void addAccessDefaultAclYamlConfigTest() throws InterruptedException {
PlainAccessValidator plainAccessValidator = new PlainAccessValidator();
String backupFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl_bak.yml".replace("/", File.separator);
String targetFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(targetFileName, Map.class);
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(backupFileName, Map.class);
AclUtils.writeDataObject(targetFileName, backUpAclConfigMap);
PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
plainAccessConfig.setAccessKey("watchrocketmqh");
@@ -903,9 +922,12 @@ public class PlainAccessValidatorTest {
@Test
public void updateAccessConfigEmptyPermListTest() {
String backupFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl_bak.yml".replace("/", File.separator);
String targetFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(targetFileName, Map.class);
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(backupFileName, Map.class);
AclUtils.writeDataObject(targetFileName, backUpAclConfigMap);
PlainAccessValidator plainAccessValidator = new PlainAccessValidator();
PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
@@ -932,9 +954,12 @@ public class PlainAccessValidatorTest {
@Test
public void updateAccessConfigEmptyWhiteRemoteAddressTest() {
String backupFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl_bak.yml".replace("/", File.separator);
String targetFileName = System.getProperty("rocketmq.home.dir")
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(targetFileName, Map.class);
+ File.separator + "conf/plain_acl.yml".replace("/", File.separator);
Map<String, Object> backUpAclConfigMap = AclUtils.getYamlDataObject(backupFileName, Map.class);
AclUtils.writeDataObject(targetFileName, backUpAclConfigMap);
PlainAccessValidator plainAccessValidator = new PlainAccessValidator();
PlainAccessConfig plainAccessConfig = new PlainAccessConfig();
@@ -0,0 +1,39 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
## suggested format
globalWhiteRemoteAddresses:
- 10.10.103.*
- 192.168.0.*
accounts:
- accessKey: RocketMQ
secretKey: 12345678
whiteRemoteAddress: 192.168.0.*
admin: false
defaultTopicPerm: DENY
defaultGroupPerm: SUB
topicPerms:
- topicA=DENY
- topicB=PUB|SUB
- topicC=SUB
groupPerms:
- groupA=DENY
- groupB=SUB
- groupC=SUB
- accessKey: rocketmq2
secretKey: 12345678
whiteRemoteAddress: 192.168.1.*
admin: true