@Test
  public void authUtilsTest_PathPrivilegeAddRemove() throws IllegalPathException, AuthException {
    List<PathPrivilege> privs = new ArrayList<>();
    PartialPath path1 = new PartialPath("root.t1");

    AuthUtils.addPrivilege(path1, PrivilegeType.READ_SCHEMA, privs, false);
    AuthUtils.addPrivilege(path1, PrivilegeType.READ_DATA, privs, false);
    AuthUtils.addPrivilege(path1, PrivilegeType.WRITE_SCHEMA, privs, true);

    Assert.assertEquals(privs.size(), 1);
    Assert.assertEquals(privs.get(0).getPrivilegeIntSet().size(), 3);
    Assert.assertEquals(privs.get(0).getGrantOpt().size(), 1);

    PartialPath path2 = new PartialPath("root.t2");
    AuthUtils.addPrivilege(path2, PrivilegeType.READ_SCHEMA, privs, false);

    Assert.assertEquals(privs.size(), 2);

    AuthUtils.removePrivilege(path2, PrivilegeType.READ_SCHEMA, privs);
    Assert.assertEquals(privs.size(), 1);

    // if we revoke privileges on root.**, privileges on root.t1 and root.t2 will also be removed.
    PartialPath rootPath = new PartialPath("root.**");
    AuthUtils.removePrivilege(rootPath, PrivilegeType.READ_DATA, privs);
    Assert.assertEquals(2, privs.get(0).getPrivilegeIntSet().size());
    Assert.assertFalse(privs.get(0).getPrivileges().contains(PrivilegeType.READ_DATA));

    AuthUtils.addPrivilege(path2, PrivilegeType.WRITE_SCHEMA, privs, true);
    AuthUtils.removePrivilege(rootPath, PrivilegeType.WRITE_SCHEMA, privs);
    Assert.assertEquals(1, privs.size());
    Assert.assertEquals(1, privs.get(0).getPrivilegeIntSet().size());
  }
root.t1 : read data; root.t2 : write schema ; root.** : read data
iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/utils/AuthUtilsTest.java