### Question:
SecureLogin { public UserGroupInformation getLoginUser(RequestContext context, Configuration configuration) throws IOException { return getLoginUser(context.getServerName(), context.getConfig(), configuration); } private  SecureLogin(); static SecureLogin getInstance(); UserGroupInformation getLoginUser(RequestContext context, Configuration configuration); UserGroupInformation getLoginUser(String serverName, String configDirectory, Configuration configuration); boolean isUserImpersonationEnabled(Configuration configuration); static final String CONFIG_KEY_SERVICE_PRINCIPAL; static final String CONFIG_KEY_SERVICE_KEYTAB; static final String CONFIG_KEY_SERVICE_USER_IMPERSONATION; static final String CONFIG_KEY_SERVICE_USER_NAME; }### Answer:
@Test public void testLoginKerberosFailsWhenNoPrincipal() throws IOException { expectedException.expect(RuntimeException.class); expectedException.expectMessage("PXF service login failed for server test : Kerberos Security for server test requires a valid principal."); PowerMockito.mockStatic(PxfUserGroupInformation.class); configuration.set("hadoop.security.authentication", "kerberos"); secureLogin.getLoginUser("test", "config", configuration); }
@Test public void testLoginKerberosFailsWhenNoKeytab() throws IOException { expectedException.expect(RuntimeException.class); expectedException.expectMessage("PXF service login failed for server test : Kerberos Security for server test requires a valid keytab file name."); PowerMockito.mockStatic(PxfUserGroupInformation.class); configuration.set("hadoop.security.authentication", "kerberos"); configuration.set(PROPERTY_KEY_SERVICE_PRINCIPAL, "foo"); secureLogin.getLoginUser("test", "config", configuration); }