@BeforeClass
  public static void beforeClass() throws Exception {
    UserProvider.setUserProviderForTesting(UTIL.getConfiguration(),
      HadoopSecurityEnabledUserProviderForTesting.class);
    setUpKdcServer();
    SecureTestUtil.enableSecurity(UTIL.getConfiguration());
    UTIL.getConfiguration().setBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY, true);
    VisibilityTestUtil.enableVisiblityLabels(UTIL.getConfiguration());
    SecureTestUtil.verifyConfiguration(UTIL.getConfiguration());
    setUpClusterKdc();
    UTIL.startMiniCluster();
    UTIL.waitUntilAllRegionsAssigned(PermissionStorage.ACL_TABLE_NAME);
    UTIL.waitUntilAllRegionsAssigned(VisibilityConstants.LABELS_TABLE_NAME);
    UTIL.waitTableEnabled(PermissionStorage.ACL_TABLE_NAME, 50000);
    UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME, 50000);
    SecureTestUtil.grantGlobal(UTIL, USER_ADMIN, Permission.Action.ADMIN, Permission.Action.CREATE,
      Permission.Action.EXEC, Permission.Action.READ, Permission.Action.WRITE);
    SecureTestUtil.grantGlobal(UTIL, USER_OWNER, Permission.Action.CREATE);
    addLabels(UTIL.getConfiguration(), Arrays.asList(USER_OWNER),
      Arrays.asList(PRIVATE, CONFIDENTIAL, SECRET, TOPSECRET));
  }
Sets the security firstly for getting the correct default realm.
hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestSecureExport.java