@Test
  public void testListUserPrivileges() throws SQLException {
    Connection adminCon = EnvFactory.getEnv().getConnection();
    Statement adminStmt = adminCon.createStatement();

    try {
      adminStmt.execute("CREATE USER user1 'password1'");
      adminStmt.execute("GRANT READ_SCHEMA ON root.a.b TO USER user1");
      adminStmt.execute("CREATE ROLE role1");
      adminStmt.execute("GRANT READ_SCHEMA,WRITE_DATA ON root.a.b.c TO ROLE role1");
      adminStmt.execute(
          "GRANT READ_SCHEMA,WRITE_DATA ON root.d.b.c TO ROLE role1 WITH GRANT OPTION");
      adminStmt.execute("GRANT ROLE role1 TO user1");

      ResultSet resultSet = adminStmt.executeQuery("LIST PRIVILEGES OF USER user1");
      String ans =
          ",root.a.b,READ_SCHEMA,false,\n"
              + "role1,root.a.b.c,WRITE_DATA,false,\n"
              + "role1,root.a.b.c,READ_SCHEMA,false,\n"
              + "role1,root.d.b.c,READ_SCHEMA,true,\n"
              + "role1,root.d.b.c,WRITE_DATA,true,\n";
      try {
        validateResultSet(resultSet, ans);

        adminStmt.execute("REVOKE ROLE role1 from user1");

        resultSet = adminStmt.executeQuery("LIST PRIVILEGES OF USER user1");
        ans = ",root.a.b,READ_SCHEMA,false,\n";
        validateResultSet(resultSet, ans);
        resultSet = adminStmt.executeQuery("LIST PRIVILEGES OF USER root");
        ans =
            ",,MANAGE_USER,true,\n"
                + ",,MANAGE_ROLE,true,\n"
                + ",,USE_TRIGGER,true,\n"
                + ",,USE_UDF,true,\n"
                + ",,USE_CQ,true,\n"
                + ",,USE_PIPE,true,\n"
                + ",,USE_MODEL,true,\n"
                + ",,EXTEND_TEMPLATE,true,\n"
                + ",,MANAGE_DATABASE,true,\n"
                + ",,MAINTAIN,true,\n"
                + ",root.**,READ_DATA,true,\n"
                + ",root.**,WRITE_DATA,true,\n"
                + ",root.**,READ_SCHEMA,true,\n"
                + ",root.**,WRITE_SCHEMA,true,\n";
        validateResultSet(resultSet, ans);
      } finally {
        resultSet.close();
      }
    } finally {
      adminStmt.close();
      adminCon.close();
    }
  }
This is an example for integration test.
integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBAuthIT.java