@BeforeClass
  public static void setUpBeforeClass() throws Exception {
    kdc = SimpleKdcServerUtil.getRunningSimpleKdcServer(
      new File(TEST_UTIL.getDataTestDir().toString()), HBaseTestingUtil::randomFreePort);

    File keytabDir = Paths.get(TEST_UTIL.getRandomDir().toString()).toAbsolutePath().toFile();
    assertTrue(keytabDir.mkdirs());

    clientPrincipal = "client@" + kdc.getKdcConfig().getKdcRealm();
    clientKeytab = new File(keytabDir, clientPrincipal + ".keytab");
    kdc.createAndExportPrincipals(clientKeytab, clientPrincipal);

    serverPrincipal = "hbase/" + HConstants.LOCALHOST + "@" + kdc.getKdcConfig().getKdcRealm();
    serverKeytab = new File(keytabDir, serverPrincipal.replace('/', '_') + ".keytab");

    spnegoServerPrincipal = "HTTP/" + HConstants.LOCALHOST + "@" + kdc.getKdcConfig().getKdcRealm();
    // Add SPNEGO principal to server keytab
    kdc.createAndExportPrincipals(serverKeytab, serverPrincipal, spnegoServerPrincipal);

    TEST_UTIL.getConfiguration().setBoolean(Constants.USE_HTTP_CONF_KEY, true);
    addSecurityConfigurations(TEST_UTIL.getConfiguration());

    TestThriftHttpServer.setUpBeforeClass();
  }
Start the HBase Thrift HTTP server on a random port through the command-line interface and talk
to it from client side with SPNEGO security enabled. Supplemental test to
TestThriftSpnegoHttpServer which falls back to the original Kerberos principal and keytab
configuration properties, not the separate SPNEGO-specific properties.
hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftSpnegoHttpFallbackServer.java