@Test
  public void testListUserRole() throws SQLException {
    Connection adminCon = EnvFactory.getEnv().getConnection();
    Statement adminStmt = adminCon.createStatement();
    try {
      adminStmt.execute("CREATE USER user1 'password'");
      adminStmt.execute("CREATE USER user2 'password'");
      adminStmt.execute("CREATE ROLE role1");
      adminStmt.execute("CREATE ROLE role2");
      adminStmt.execute("GRANT ROLE role1 TO user1");
      adminStmt.execute("GRANT ROLE role1 TO user2");
      adminStmt.execute("GRANT ROLE role2 TO user2");
      adminStmt.execute("GRANT MANAGE_ROLE,MANAGE_USER ON root.** TO USER user1");

      // user1 : role1; MANAGE_ROLE,MANAGE_USER
      // user2 : role1, role2;
      ResultSet resultSet;
      String ans;
      Connection userCon = EnvFactory.getEnv().getConnection("user1", "password");
      Statement userStmt = userCon.createStatement();
      try {
        resultSet = userStmt.executeQuery("LIST ROLE OF USER user1");
        ans = "role1,\n";
        validateResultSet(resultSet, ans);
        resultSet = userStmt.executeQuery("LIST ROLE OF USER user2");
        ans = "role1,\nrole2,\n";
        validateResultSet(resultSet, ans);
        resultSet = userStmt.executeQuery("LIST USER OF ROLE role1");
        ans = "user1,\nuser2,\n";
        validateResultSet(resultSet, ans);
      } finally {
        userStmt.close();
        userCon.close();
      }

      Connection user2Con = EnvFactory.getEnv().getConnection("user2", "password");
      Statement user2Stmt = user2Con.createStatement();
      try {
        Assert.assertThrows(SQLException.class, () -> user2Stmt.execute("LIST ROLE OF USER user1"));
        Assert.assertThrows(SQLException.class, () -> user2Stmt.execute("LIST USER OF ROLE user1"));
        resultSet = user2Stmt.executeQuery("LIST ROLE OF USER user2");
        ans = "role1,\nrole2,\n";
        validateResultSet(resultSet, ans);
      } finally {
        user2Stmt.close();
        user2Con.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