Skip to content

Commit 8265a3c

Browse files
committed
partial
1 parent b639928 commit 8265a3c

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import org.apache.iotdb.commons.utils.AuthUtils;
7575
import org.apache.iotdb.commons.utils.PathUtils;
7676
import org.apache.iotdb.commons.utils.StatusUtils;
77+
import org.apache.iotdb.commons.utils.TestOnly;
7778
import org.apache.iotdb.confignode.audit.CNAuditLogger;
7879
import org.apache.iotdb.confignode.conf.ConfigNodeConfig;
7980
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
@@ -323,7 +324,7 @@ public class ConfigManager implements IManager {
323324
private final PartitionManager partitionManager;
324325

325326
/** Manage cluster authorization. */
326-
private final PermissionManager permissionManager;
327+
private PermissionManager permissionManager;
327328

328329
/** Manage load balancing. */
329330
protected LoadManager loadManager;
@@ -3106,4 +3107,9 @@ public DataSet registerAINode(TAINodeRegisterReq req) {
31063107
resp.setConfigNodeList(getNodeManager().getRegisteredConfigNodes());
31073108
return resp;
31083109
}
3110+
3111+
@TestOnly
3112+
public void setPermissionManager(final PermissionManager permissionManager) {
3113+
this.permissionManager = permissionManager;
3114+
}
31093115
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iotdb.confignode.manager.pipe.source;
21+
22+
import org.apache.iotdb.commons.auth.entity.PrivilegeUnion;
23+
import org.apache.iotdb.commons.exception.MetadataException;
24+
import org.apache.iotdb.commons.utils.StatusUtils;
25+
import org.apache.iotdb.confignode.manager.ConfigManager;
26+
import org.apache.iotdb.confignode.manager.PermissionManager;
27+
import org.apache.iotdb.confignode.rpc.thrift.TPermissionInfoResp;
28+
import org.apache.iotdb.confignode.service.ConfigNode;
29+
import org.apache.iotdb.db.exception.StorageEngineException;
30+
31+
import org.apache.tsfile.exception.write.WriteProcessException;
32+
import org.junit.After;
33+
import org.junit.Assert;
34+
import org.junit.Before;
35+
import org.junit.Test;
36+
37+
import java.io.IOException;
38+
39+
public class PipeConfigTreePrivilegeParseVisitorTest {
40+
41+
private final PipeConfigTreePrivilegeParseVisitor skipVisitor =
42+
new PipeConfigTreePrivilegeParseVisitor(true);
43+
private final PipeConfigTreePrivilegeParseVisitor throwVisitor =
44+
new PipeConfigTreePrivilegeParseVisitor(false);
45+
46+
private ConfigNode oldInstance;
47+
48+
@Before
49+
public void setUp()
50+
throws IOException, WriteProcessException, MetadataException, InterruptedException {
51+
oldInstance = ConfigNode.getInstance();
52+
ConfigNode.setInstance(new ConfigNode());
53+
final ConfigManager configManager = new ConfigManager();
54+
configManager.setPermissionManager(new TestPermissionManager());
55+
ConfigNode.getInstance().setConfigManager(configManager);
56+
}
57+
58+
@After
59+
public void tearDown() throws IOException, StorageEngineException {
60+
ConfigNode.setInstance(oldInstance);
61+
}
62+
63+
@Test
64+
public void testCreateDatabase() {
65+
Assert.assertTrue(skipVisitor.canReadSysSchema("root.db", null, true));
66+
}
67+
68+
private static class TestPermissionManager extends PermissionManager {
69+
public TestPermissionManager() {
70+
super(null, null);
71+
}
72+
73+
@Override
74+
public TPermissionInfoResp checkUserPrivileges(
75+
final String username, final PrivilegeUnion union) {
76+
return new TPermissionInfoResp(StatusUtils.OK);
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)