@Test
  public void testLabelsWithAppend() throws Throwable {
    PrivilegedExceptionAction<VisibilityLabelsResponse> action =
      new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
        @Override
        public VisibilityLabelsResponse run() throws Exception {
          try (Connection conn = ConnectionFactory.createConnection(conf)) {
            return VisibilityClient.setAuths(conn, new String[] { TOPSECRET }, USER.getShortName());
          } catch (Throwable e) {
          }
          return null;
        }
      };
    SUPERUSER.runAs(action);
    final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
    try (Table table = TEST_UTIL.createTable(tableName, fam)) {
      final byte[] row1 = Bytes.toBytes("row1");
      final byte[] val = Bytes.toBytes("a");
      PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws Exception {
          try (Connection connection = ConnectionFactory.createConnection(conf);
            Table table = connection.getTable(tableName)) {
            Put put = new Put(row1);
            put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, val);
            put.setCellVisibility(new CellVisibility(TOPSECRET));
            table.put(put);
          }
          return null;
        }
      };
      USER.runAs(actiona);
      actiona = new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws Exception {
          try (Connection connection = ConnectionFactory.createConnection(conf);
            Table table = connection.getTable(tableName)) {
            Append append = new Append(row1);
            append.addColumn(fam, qual, Bytes.toBytes("b"));
            table.append(append);
          }
          return null;
        }
      };
      USER.runAs(actiona);
      actiona = new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws Exception {
          try (Connection connection = ConnectionFactory.createConnection(conf);
            Table table = connection.getTable(tableName)) {
            Append append = new Append(row1);
            append.addColumn(fam, qual, Bytes.toBytes("c"));
            append.setCellVisibility(new CellVisibility(PUBLIC));
            table.append(append);
            Assert.fail("Testcase should fail with AccesDeniedException");
          } catch (Throwable t) {
            assertTrue(t.getMessage().contains("AccessDeniedException"));
          }
          return null;
        }
      };
      USER.runAs(actiona);
    }
  }
Test visibility by setting 'hbase.security.visibility.mutations.checkauths' to true
hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityWithCheckAuths.java