  @Test
  public void testGetPrincipalFromKeytab() throws IOException {

    String keytabLocation = "dummy.keytab";
    String expectedPrincipalName = "somedomain/somehost";
    String fullPrincipalName = expectedPrincipalName + "@somecompany.com";

    Keytab kt = new Keytab();
    KeytabEntry kte = new KeytabEntry(fullPrincipalName, 0,
        new KerberosTime(), (byte) (0), new EncryptionKey(EncryptionType.AES256_CTS_HMAC_SHA1_96, new byte[0]));
    kt.setEntries(Arrays.asList(kte));
    File keytabFile = new File(keytabLocation);
    kt.write(keytabFile);

    String actualPrincipalName = TokenFetcherService.getPrincipalFromKeytab(keytabLocation);
    Assert.assertEquals(actualPrincipalName, expectedPrincipalName);

    keytabFile.delete();
  }