@Test
  public void testNormalGrantRevoke() {
    grantRevokeCheck testGrant =
        (privilege, name, isuser, path, grantOpt) -> {
          String sql = "grant %s on %s to %s %s %s ;";
          sql =
              String.format(
                  sql,
                  privilege,
                  path,
                  isuser ? "USER" : "ROLE",
                  name,
                  grantOpt ? "with grant option" : "");
          AuthorStatement aclStmt = createAuthDclStmt(sql);
          assertEquals(
              isuser ? StatementType.GRANT_USER_PRIVILEGE : StatementType.GRANT_ROLE_PRIVILEGE,
              aclStmt.getType());
          assertEquals(path, aclStmt.getPaths().get(0).toString());
          assertEquals(name, isuser ? aclStmt.getUserName() : aclStmt.getRoleName());
          assertEquals(grantOpt, aclStmt.getGrantOpt());
          assertEquals(privilege, aclStmt.getPrivilegeList()[0]);
        };

    String name = "test1";
    String path = "root.**";
    String pathErr = "root.t1.**";
    String pathsErr = "root.**, root.t1.**";

    // 1. check simple privilege grant to user/role with/without grant option.
    for (PrivilegeType privilege : PrivilegeType.values()) {
      if (privilege.isRelationalPrivilege()) {
        continue;
      }
      testGrant.checkParser(privilege.toString(), name, true, path, true);
      testGrant.checkParser(privilege.toString(), name, true, path, false);
      testGrant.checkParser(privilege.toString(), name, false, path, true);
      testGrant.checkParser(privilege.toString(), name, false, path, false);
      // 2. if grant stmt has system privilege, path should be root.**
      if (!privilege.isPathPrivilege()) {
        assertThrows(
            SemanticException.class,
            () ->
                createAuthDclStmt(
                    String.format("GRANT %s on %s to USER `user1`;", privilege, pathErr)));
        assertThrows(
            SemanticException.class,
            () ->
                createAuthDclStmt(
                    String.format("GRANT %s on %s to USER `user1`;", privilege, pathsErr)));
      }
    }

    grantRevokeCheck testRevoke =
        (privilege, username, isuser, targtePath, grantOpt) -> {
          String sql = "revoke %s on %s from %s %s";
          sql = String.format(sql, privilege, targtePath, isuser ? "USER" : "ROLE", username);
          AuthorStatement aclStmt = createAuthDclStmt(sql);
          assertEquals(
              isuser ? StatementType.REVOKE_USER_PRIVILEGE : StatementType.REVOKE_ROLE_PRIVILEGE,
              aclStmt.getType());
          assertEquals(path, aclStmt.getPaths().get(0).toString());
          assertEquals(username, isuser ? aclStmt.getUserName() : aclStmt.getRoleName());
          assertFalse(aclStmt.getGrantOpt());
          assertEquals(privilege, aclStmt.getPrivilegeList()[0]);
        };

    // 3. check simple privilege revoke from user/role on simple path
    for (PrivilegeType type : PrivilegeType.values()) {
      if (type.isRelationalPrivilege()) {
        continue;
      }
      testRevoke.checkParser(type.toString(), name, true, path, false);
      testRevoke.checkParser(type.toString(), name, false, path, false);

      // 4. check system privilege revoke from user on wrong paths.
      if (!type.isPathPrivilege()) {
        assertThrows(
            SemanticException.class,
            () ->
                createAuthDclStmt(
                    String.format("revoke %s on %s FROM USER `user1`;", type, pathErr)));
        assertThrows(
            SemanticException.class,
            () ->
                createAuthDclStmt(
                    String.format("revoke %s on %s FROM USER `user1`;", type, pathsErr)));
      }
    }
  }
This test will check grant/revoke simple privilege on/from paths.
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/parser/StatementGeneratorTest.java