Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public void ttlOperationsTest() {
assertNonQueryTestFail(
statement,
"set ttl to root.__audit.** 1",
"803: The database 'root.__audit' is read-only.");
"803: Apache IoTDB does not support this operation on database 'root.__audit'.");
} catch (SQLException e) {
e.printStackTrace();
fail(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,15 @@ public void manageDataBaseTest() {
"create database root.__audit",
"803: The database name \"root.__audit\" is reserved, please use another valid database name.");

assertNonQueryTestFail(
adminStmt,
"delete database root.__audit",
"803: Apache IoTDB does not support this operation on database 'root.__audit'.");

assertNonQueryTestFail(
adminStmt,
"set device template t1 to root.__audit",
"803: The database 'root.__audit' is read-only");
"803: Apache IoTDB does not support this operation on database 'root.__audit'.");

Set<String> retSet = new HashSet<>(Arrays.asList("t1", "t2", "t3"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ public void testInsert() throws IoTDBConnectionException, StatementExecutionExce
e.getMessage());
}

try {
sessionRoot.executeNonQueryStatement("DROP DATABASE __audit");
fail("Should have thrown an exception");
} catch (StatementExecutionException e) {
assertEquals(
"803: Access Denied: Apache IoTDB does not support this operation on database '__audit'.",
e.getMessage());
}

sessionRoot.executeNonQueryStatement("CREATE DATABASE IF NOT EXISTS \"汉化\"");
sessionRoot.executeNonQueryStatement("USE \"汉化\"");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3050,8 +3050,9 @@ private DataNodeQueryMessages() {}
"getOutputColumnNames of CreateMultiTimeSeriesNode is not implemented";
public static final String QUERY_EXCEPTION_GETOUTPUTCOLUMNNAMES_OF_ALTERLOGICALVIEWNODE_IS_NOT_IMPLEMENTED_D2294789 =
"getOutputColumnNames of AlterLogicalViewNode is not implemented";
public static final String QUERY_EXCEPTION_THE_DATABASE_S_IS_READ_ONLY_CB6732CE =
"The database '%s' is read-only.";
public static final String
EXCEPTION_APACHE_IOTDB_DOES_NOT_SUPPORT_THIS_OPERATION_ON_DATABASE_ARG_B09ADFD7 =
"Apache IoTDB does not support this operation on database '%s'.";
public static final String QUERY_EXCEPTION_THE_DATABASE_S_CAN_ONLY_BE_QUERIED_BY_AUDIT_ADMIN_4A510F66 =
"The database '%s' can only be queried by AUDIT admin.";
public static final String QUERY_EXCEPTION_UNEXPECTED_WINDOW_FRAME_TYPE_S_F06F81B8 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3683,9 +3683,10 @@ private DataNodeQueryMessages() {}
public static final String QUERY_EXCEPTION_GETOUTPUTCOLUMNNAMES_OF_ALTERLOGICALVIEWNODE_IS_NOT_IMPLEMENTED_D2294789 =

"AlterLogicalViewNode 的 getOutputColumnNames 尚未实现";
public static final String QUERY_EXCEPTION_THE_DATABASE_S_IS_READ_ONLY_CB6732CE =
public static final String
EXCEPTION_APACHE_IOTDB_DOES_NOT_SUPPORT_THIS_OPERATION_ON_DATABASE_ARG_B09ADFD7 =

"数据库 '%s' 为只读。";
"Apache IoTDB 不支持对数据库 '%s' 执行此操作。";
public static final String QUERY_EXCEPTION_THE_DATABASE_S_CAN_ONLY_BE_QUERIED_BY_AUDIT_ADMIN_4A510F66 =

"数据库 '%s' 仅允许 AUDIT admin 查询。";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@

public class AccessControlImpl implements AccessControl {

public static final String READ_ONLY_DB_ERROR_MSG = "The database '%s' is read-only.";
static String getUnsupportedAuditDatabaseOperationMessage(String databaseName) {
return String.format(
DataNodeQueryMessages
.EXCEPTION_APACHE_IOTDB_DOES_NOT_SUPPORT_THIS_OPERATION_ON_DATABASE_ARG_B09ADFD7,
databaseName);
}

protected final ITableAuthChecker authChecker;

Expand All @@ -72,7 +77,7 @@ public AccessControlImpl(ITableAuthChecker authChecker, TreeAccessCheckVisitor v
private void checkAuditDatabase(String databaseName) {
if (TABLE_MODEL_AUDIT_DATABASE.equalsIgnoreCase(databaseName)) {
throw new AccessDeniedException(
String.format(READ_ONLY_DB_ERROR_MSG, TABLE_MODEL_AUDIT_DATABASE));
getUnsupportedAuditDatabaseOperationMessage(TABLE_MODEL_AUDIT_DATABASE));
}
}

Expand Down Expand Up @@ -567,11 +572,11 @@ public TSStatus checkFullPathWriteDataPermission(
IAuditEntity auditEntity, IDeviceID device, String measurementId) {
try {
PartialPath path = new MeasurementPath(device, measurementId);
// audit db is read-only
// Apache IoTDB does not support external writes to the audit database.
if (includeByAuditTreeDB(path)
&& !auditEntity.getUsername().equals(AuthorityChecker.INTERNAL_AUDIT_USER)) {
return new TSStatus(TSStatusCode.NO_PERMISSION.getStatusCode())
.setMessage(String.format(READ_ONLY_DB_ERROR_MSG, TREE_MODEL_AUDIT_DATABASE));
.setMessage(getUnsupportedAuditDatabaseOperationMessage(TREE_MODEL_AUDIT_DATABASE));
}
return checkTimeSeriesPermission(
auditEntity, () -> Collections.singletonList(path), PrivilegeType.WRITE_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ private static void checkAuditDatabase(
.setResult(false),
() -> databaseName);
throw new AccessDeniedException(
String.format(
DataNodeQueryMessages.QUERY_EXCEPTION_THE_DATABASE_S_IS_READ_ONLY_CB6732CE,
AccessControlImpl.getUnsupportedAuditDatabaseOperationMessage(
TABLE_MODEL_AUDIT_DATABASE));
}
}
Expand Down
Loading
Loading