@Test
  public void testLoginWithUserKeytabAndPrincipal() throws Exception {
    String clientKeytab = getClientKeytabForTesting();
    String clientPrincipal = getClientPrincipalForTesting();
    assertNotNull("Path for client keytab is not specified.", clientKeytab);
    assertNotNull("Client principal is not specified.", clientPrincipal);

    Configuration conf = getSecuredConfiguration();
    conf.set(AuthUtil.HBASE_CLIENT_KEYTAB_FILE, clientKeytab);
    conf.set(AuthUtil.HBASE_CLIENT_KERBEROS_PRINCIPAL, clientPrincipal);
    UserGroupInformation.setConfiguration(conf);

    UserProvider provider = UserProvider.instantiate(conf);
    assertTrue("Client principal or keytab is empty", provider.shouldLoginFromKeytab());

    provider.login(AuthUtil.HBASE_CLIENT_KEYTAB_FILE, AuthUtil.HBASE_CLIENT_KERBEROS_PRINCIPAL);
    User loginUser = provider.getCurrent();
    assertEquals(CLIENT_NAME, loginUser.getShortName());
    assertEquals(getClientPrincipalForTesting(), loginUser.getName());
  }
test login with security enabled configuration To run this test, we must specify the following
system properties:
<p>
<b> hbase.regionserver.kerberos.principal </b>
<p>
<b> hbase.regionserver.keytab.file </b>
hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestUsersOperationsWithSecureHadoop.java