public static void validateKerberosPrincipal(
      KerberosPrincipal kerberosPrincipal) throws IOException {
    if (!StringUtils.isEmpty(kerberosPrincipal.getPrincipalName())) {
      if (!kerberosPrincipal.getPrincipalName().contains("/")) {
        throw new IllegalArgumentException(String.format(
            RestApiErrorMessages.ERROR_KERBEROS_PRINCIPAL_NAME_FORMAT,
            kerberosPrincipal.getPrincipalName()));
      }
    }
  }
@Test
  public void testKerberosPrincipal() throws IOException {
    SliderFileSystem sfs = ServiceTestUtils.initMockFs();
    Service app = createValidApplication("comp-a");
    KerberosPrincipal kp = new KerberosPrincipal();
    kp.setKeytab("file:///tmp/a.keytab");
    kp.setPrincipalName("user/_HOST@domain.com");
    app.setKerberosPrincipal(kp);

    // This should succeed
    try {
      ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
    } catch (IllegalArgumentException e) {
      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
    }

    // Keytab with no URI scheme should succeed too
    kp.setKeytab("/some/path");
    try {
      ServiceApiUtil.validateKerberosPrincipal(app.getKerberosPrincipal());
    } catch (IllegalArgumentException e) {
      Assert.fail(NO_EXCEPTION_PREFIX + e.getMessage());
    }
  }