@Test
  public void testStackActionsAvailableForAdmins() throws Exception {
    final String expectedAuthorizedContent = "Process Thread Dump";
    UserGroupInformation admin = UserGroupInformation
      .loginUserFromKeytabAndReturnUGI(USER_ADMIN_STR, KEYTAB_FILE.getAbsolutePath());
    admin.doAs(new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        // Check the expected content is present in the http response
        Pair<Integer, String> pair = getStacksPage();
        assertEquals(HttpURLConnection.HTTP_OK, pair.getFirst().intValue());
        assertTrue("expected=" + expectedAuthorizedContent + ", content=" + pair.getSecond(),
          pair.getSecond().contains(expectedAuthorizedContent));
        return null;
      }
    });

    UserGroupInformation nonAdmin = UserGroupInformation
      .loginUserFromKeytabAndReturnUGI(USER_NONE_STR, KEYTAB_FILE.getAbsolutePath());
    nonAdmin.doAs(new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        Pair<Integer, String> pair = getStacksPage();
        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, pair.getFirst().intValue());
        return null;
      }
    });
  }
Helper method to shut down the cluster (if running)
hbase-server/src/test/java/org/apache/hadoop/hbase/http/TestInfoServersACL.java