Skip to content

Commit 4b29130

Browse files
authored
Move password history under __audit (apache#16496)
1 parent 5ea679f commit 4b29130

File tree

13 files changed

+29
-36
lines changed

13 files changed

+29
-36
lines changed

integration-test/src/test/java/org/apache/iotdb/confignode/it/load/IoTDBMultiDBRegionGroupLeaderDistributionIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ public void testMultiDatabaseLeaderDistribution()
113113
TShowRegionResp showRegionResp = client.showRegion(new TShowRegionReq());
114114
showRegionResp
115115
.getRegionInfoList()
116-
.removeIf(r -> r.database.startsWith("root." + SystemConstant.SYSTEM_PREFIX_KEY));
116+
// Skip AUDIT database
117+
.removeIf(r -> r.database.startsWith(SystemConstant.AUDIT_DATABASE));
117118
showRegionResp
118119
.getRegionInfoList()
119120
.forEach(

integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBAutoRegionGroupExtensionIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private void checkRegionDistribution(
189189
.merge(regionInfo.getDataNodeId(), 1, Integer::sum);
190190
});
191191
// The number of RegionGroups should not less than the testMinRegionGroupNum for each database
192-
// +1 for system database
192+
// +1 for AUDIT database
193193
Assert.assertEquals(TEST_DATABASE_NUM + 1, databaseRegionCounter.size());
194194
databaseRegionCounter.forEach(
195195
(database, regionCount) ->

integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionGetterIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public void testGetSchemaNodeManagementPartition() throws Exception {
535535
nodeManagementResp = client.getSchemaNodeManagementPartition(nodeManagementReq);
536536
Assert.assertEquals(
537537
TSStatusCode.SUCCESS_STATUS.getStatusCode(), nodeManagementResp.getStatus().getCode());
538-
// +1 for SYSTEM database
538+
// +1 for AUDIT database
539539
Assert.assertEquals(storageGroupNum + 1, nodeManagementResp.getMatchedNodeSize());
540540
Assert.assertNotNull(nodeManagementResp.getSchemaRegionMap());
541541
Assert.assertEquals(0, nodeManagementResp.getSchemaRegionMapSize());

integration-test/src/test/java/org/apache/iotdb/confignode/it/regionmigration/pass/commit/IoTDBRegionGroupExpandAndShrinkForIoTV1IT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void singleRegionTest() throws Exception {
9494
Set<Integer> allDataNodeId = getAllDataNodes(statement);
9595

9696
// expect one data region, one schema region
97-
// plus one system data region, one system schema region
97+
// plus one AUDIT data region, one AUDIT schema region
9898
Assert.assertEquals(4, regionMap.size());
9999

100100
// expand
@@ -217,7 +217,7 @@ public void multiRegionNormalTest() throws Exception {
217217
Set<Integer> allDataNodeId = getAllDataNodes(statement);
218218

219219
// expect one data region, one schema region
220-
// plus one system data region, one system schema region
220+
// plus one AUDIT data region, one AUDIT schema region
221221
Assert.assertEquals(4, regionMap.size());
222222

223223
// select multiple regions for testing

integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBMiscIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void testCompressionRatioFile() throws SQLException {
5555
Statement statement = connection.createStatement()) {
5656
statement.execute("insert into root.comprssion_ratio_file.d1(timestamp,s1) values(1,1.0)");
5757
statement.execute("flush");
58-
// one global file and two data region file (including one system region)
58+
// one global file and two data region file (including one AUDIT region)
5959
assertEquals(3, collectCompressionRatioFiles(nodeWrapper).size());
6060

6161
statement.execute("drop database root.comprssion_ratio_file");

integration-test/src/test/java/org/apache/iotdb/db/it/audit/IoTDBAuditLogBasicIT.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,6 @@ public static void tearDown() {
165165
"null",
166166
"null",
167167
"Successfully start the Audit service with configurations (auditableOperationType [DDL, DML, QUERY, CONTROL], auditableOperationLevel GLOBAL, auditableOperationResult SUCCESS,FAIL)"),
168-
// Create password history TODO: @Hongzhi Gao move password history under __audit
169-
Arrays.asList(
170-
"node_1",
171-
"u_0",
172-
"root",
173-
"",
174-
"OBJECT_AUTHENTICATION",
175-
"DDL",
176-
"null",
177-
"null",
178-
"true",
179-
"root.__system",
180-
"null",
181-
"User root (ID=0) requests authority on object root.__system with result true"),
182168
// Show audit database TODO: Fix typo in tree model
183169
Arrays.asList(
184170
"node_1",

integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBAuthIT.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import java.util.Set;
5151
import java.util.concurrent.Callable;
5252

53+
import static org.apache.iotdb.db.audit.DNAuditLogger.PREFIX_PASSWORD_HISTORY;
5354
import static org.apache.iotdb.db.it.utils.TestUtils.createUser;
5455
import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
5556
import static org.junit.Assert.assertEquals;
@@ -1519,7 +1520,7 @@ public void testPasswordHistoryCreateAndDrop(Statement statement) throws SQLExce
15191520

15201521
try (ResultSet resultSet =
15211522
statement.executeQuery(
1522-
"select last password from root.__system.password_history.`_userA`")) {
1523+
String.format("select last password from %s.`_userA`", PREFIX_PASSWORD_HISTORY))) {
15231524
if (!resultSet.next()) {
15241525
fail("Password history not found");
15251526
}
@@ -1528,7 +1529,7 @@ public void testPasswordHistoryCreateAndDrop(Statement statement) throws SQLExce
15281529

15291530
try (ResultSet resultSet =
15301531
statement.executeQuery(
1531-
"select last oldPassword from root.__system.password_history.`_userA`")) {
1532+
String.format("select last oldPassword from %s.`_userA`", PREFIX_PASSWORD_HISTORY))) {
15321533
if (!resultSet.next()) {
15331534
fail("Password history not found");
15341535
}
@@ -1539,13 +1540,13 @@ public void testPasswordHistoryCreateAndDrop(Statement statement) throws SQLExce
15391540

15401541
try (ResultSet resultSet =
15411542
statement.executeQuery(
1542-
"select last password from root.__system.password_history.`_userA`")) {
1543+
String.format("select last password from %s.`_userA`", PREFIX_PASSWORD_HISTORY))) {
15431544
assertFalse(resultSet.next());
15441545
}
15451546

15461547
try (ResultSet resultSet =
15471548
statement.executeQuery(
1548-
"select last oldPassword from root.__system.password_history.`_userA`")) {
1549+
String.format("select last oldPassword from %s.`_userA`", PREFIX_PASSWORD_HISTORY))) {
15491550
assertFalse(resultSet.next());
15501551
}
15511552
}
@@ -1556,7 +1557,7 @@ public void testPasswordHistoryAlter(Statement statement) throws SQLException {
15561557

15571558
try (ResultSet resultSet =
15581559
statement.executeQuery(
1559-
"select last password from root.__system.password_history.`_userA`")) {
1560+
String.format("select last password from %s.`_userA`", PREFIX_PASSWORD_HISTORY))) {
15601561
if (!resultSet.next()) {
15611562
fail("Password history not found");
15621563
}
@@ -1565,13 +1566,15 @@ public void testPasswordHistoryAlter(Statement statement) throws SQLException {
15651566

15661567
try (ResultSet resultSet =
15671568
statement.executeQuery(
1568-
"select oldPassword from root.__system.password_history.`_userA` order by time desc limit 1")) {
1569+
String.format(
1570+
"select oldPassword from %s.`_userA` order by time desc limit 1",
1571+
PREFIX_PASSWORD_HISTORY))) {
15691572
if (!resultSet.next()) {
15701573
fail("Password history not found");
15711574
}
15721575
assertEquals(
15731576
AuthUtils.encryptPassword("abcdef123456"),
1574-
resultSet.getString("root.__system.password_history._userA.oldPassword"));
1577+
resultSet.getString(String.format("%s._userA.oldPassword", PREFIX_PASSWORD_HISTORY)));
15751578
}
15761579
}
15771580

integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBDeleteDatabaseIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ public void testDeleteAllDatabases() throws Exception {
159159
result.add(resultSet.getString(1));
160160
}
161161
}
162-
assertEquals(0, result.size());
162+
// One for un-deletable AUDIT database
163+
assertEquals(1, result.size());
163164
}
164165
}
165166

integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ public void testMixedDatabase() throws SQLException {
804804

805805
try (final Connection connection = EnvFactory.getEnv().getConnection();
806806
final Statement statement = connection.createStatement()) {
807+
// One for AUDIT database
807808
TestUtils.assertResultSetSize(statement.executeQuery("show databases"), 2);
808809
}
809810
}

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteTimeSeriesProcedure.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected Flow executeFromState(
141141
// Return the total num of timeSeries in schemaEngine black list
142142
private long constructBlackList(final ConfigNodeProcedureEnv env) {
143143
final Map<TConsensusGroupId, TRegionReplicaSet> targetSchemaRegionGroup =
144-
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree, false);
144+
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree, true);
145145
if (targetSchemaRegionGroup.isEmpty()) {
146146
return 0;
147147
}
@@ -260,7 +260,7 @@ private void deleteTimeSeriesSchema(final ConfigNodeProcedureEnv env) {
260260
new DeleteTimeSeriesRegionTaskExecutor<>(
261261
"delete time series in schema engine",
262262
env,
263-
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree, false),
263+
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree, true),
264264
CnToDnAsyncRequestType.DELETE_TIMESERIES,
265265
((dataNodeLocation, consensusGroupIdList) ->
266266
new TDeleteTimeSeriesReq(consensusGroupIdList, patternTreeBytes)

0 commit comments

Comments
 (0)