### Question:
SecureLogin { public boolean isUserImpersonationEnabled(Configuration configuration) { String valueFromUserImpersonationOnServer = configuration.get(SecureLogin.CONFIG_KEY_SERVICE_USER_IMPERSONATION, System.getProperty(PROPERTY_KEY_USER_IMPERSONATION, "false")); return StringUtils.equalsIgnoreCase(valueFromUserImpersonationOnServer, "true"); } 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 testServerConfigurationImpersonationPropertyTrue() { configuration.set("pxf.service.user.impersonation", "true"); assertTrue(secureLogin.isUserImpersonationEnabled(configuration)); }
@Test public void testServerConfigurationImpersonationPropertyTRUE() { configuration.set("pxf.service.user.impersonation", "TRUE"); assertTrue(secureLogin.isUserImpersonationEnabled(configuration)); }
@Test public void testServerConfigurationImpersonationOverwritesGlobalTrue() { System.setProperty(PROPERTY_KEY_USER_IMPERSONATION, "false"); configuration.set("pxf.service.user.impersonation", "true"); assertTrue(secureLogin.isUserImpersonationEnabled(configuration)); }
@Test public void testServerConfigurationImpersonationOverwritesGlobalFalse() { System.setProperty(PROPERTY_KEY_USER_IMPERSONATION, "true"); configuration.set("pxf.service.user.impersonation", "false"); assertFalse(secureLogin.isUserImpersonationEnabled(configuration)); }
@Test public void testGlobalImpersonationPropertyAbsent() { assertFalse(secureLogin.isUserImpersonationEnabled(configuration)); }
@Test public void testGlobalImpersonationPropertyEmpty() { System.setProperty(PROPERTY_KEY_USER_IMPERSONATION, ""); assertFalse(secureLogin.isUserImpersonationEnabled(configuration)); }
@Test public void testGlobalImpersonationPropertyFalse() { System.setProperty(PROPERTY_KEY_USER_IMPERSONATION, "foo"); assertFalse(secureLogin.isUserImpersonationEnabled(configuration)); }
@Test public void testGlobalImpersonationPropertyTRUE() { System.setProperty(PROPERTY_KEY_USER_IMPERSONATION, "TRUE"); assertTrue(secureLogin.isUserImpersonationEnabled(configuration)); }
@Test public void testGlobalImpersonationPropertyTrue() { System.setProperty(PROPERTY_KEY_USER_IMPERSONATION, "true"); assertTrue(secureLogin.isUserImpersonationEnabled(configuration)); }
@Test public void testServerConfigurationImpersonationPropertyFalse() { configuration.set("pxf.service.user.impersonation", "foo"); assertFalse(secureLogin.isUserImpersonationEnabled(configuration)); }