@Test
  public void testClearUserAuths() throws Throwable {
    PrivilegedExceptionAction<Void> action = new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        String[] auths = { SECRET, CONFIDENTIAL, PRIVATE };
        String user = "testUser";
        try (Connection conn = ConnectionFactory.createConnection(conf)) {
          VisibilityClient.setAuths(conn, auths, user);
        } catch (Throwable e) {
          throw new IOException(e);
        }
        // Removing the auths for SECRET and CONFIDENTIAL for the user.
        // Passing a non existing auth also.
        auths = new String[] { SECRET, PUBLIC, CONFIDENTIAL };
        VisibilityLabelsResponse response = null;
        try (Connection conn = ConnectionFactory.createConnection(conf)) {
          response = VisibilityClient.clearAuths(conn, auths, user);
        } catch (Throwable e) {
          fail("Should not have failed");
        }
        List<RegionActionResult> resultList = response.getResultList();
        assertEquals(3, resultList.size());
        assertTrue(resultList.get(0).getException().getValue().isEmpty());
        assertEquals("org.apache.hadoop.hbase.DoNotRetryIOException",
          resultList.get(1).getException().getName());
        assertTrue(Bytes.toString(resultList.get(1).getException().getValue().toByteArray())
          .contains("org.apache.hadoop.hbase.security.visibility.InvalidLabelException: "
            + "Label 'public' is not set for the user testUser"));
        assertTrue(resultList.get(2).getException().getValue().isEmpty());
        try (Connection connection = ConnectionFactory.createConnection(conf);
          Table ht = connection.getTable(LABELS_TABLE_NAME)) {
          ResultScanner scanner = ht.getScanner(new Scan());
          Result result = null;
          List<Result> results = new ArrayList<>();
          while ((result = scanner.next()) != null) {
            results.add(result);
          }
          List<String> curAuths = extractAuths(user, results);
          assertTrue(curAuths.contains(PRIVATE));
          assertEquals(1, curAuths.size());
        }

        GetAuthsResponse authsResponse = null;
        try (Connection conn = ConnectionFactory.createConnection(conf)) {
          authsResponse = VisibilityClient.getAuths(conn, user);
        } catch (Throwable e) {
          throw new IOException(e);
        }
        List<String> authsList = new ArrayList<>(authsResponse.getAuthList().size());
        for (ByteString authBS : authsResponse.getAuthList()) {
          authsList.add(Bytes.toString(authBS.toByteArray()));
        }
        assertEquals(1, authsList.size());
        assertTrue(authsList.contains(PRIVATE));
        return null;
      }
    };
    SUPERUSER.runAs(action);
  }
Base test class for visibility labels basic features
hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabels.java