### Question:
FalconAuthenticationFilter extends org.apache.hadoop.security.authentication.server.AuthenticationFilter { @Override protected Properties getConfiguration(String configPrefix, FilterConfig filterConfig) { Properties authProperties = new Properties(); Properties configProperties = StartupProperties.get(); authProperties.setProperty( org.apache.hadoop.security.authentication.server.AuthenticationFilter.COOKIE_PATH, "/"); for (Map.Entry entry : configProperties.entrySet()) { String name = (String) entry.getKey(); if (name.startsWith(FALCON_PREFIX)) { String value = (String) entry.getValue(); name = name.substring(FALCON_PREFIX.length()); authProperties.setProperty(name, value); } } if (UserGroupInformation.isSecurityEnabled()) { String principal = getKerberosPrincipalWithSubstitutedHost(configProperties); authProperties.setProperty(KerberosAuthenticationHandler.PRINCIPAL, principal); } return authProperties; }  @Override void init(FilterConfig filterConfig); @Override void doFilter(final ServletRequest request, final ServletResponse response,
                         final FilterChain filterChain); @Override void destroy();  }### Answer:
@Test public void testGetKerberosPrincipalWithSubstitutedHostNonSecure() throws Exception { String principal = StartupProperties.get().getProperty(FalconAuthenticationFilter.KERBEROS_PRINCIPAL); Configuration conf = new Configuration(false); conf.set("hadoop.security.authentication", "simple"); UserGroupInformation.setConfiguration(conf); Assert.assertFalse(UserGroupInformation.isSecurityEnabled()); FalconAuthenticationFilter filter = new FalconAuthenticationFilter(); Properties properties = filter.getConfiguration(FalconAuthenticationFilter.FALCON_PREFIX, null); Assert.assertEquals(properties.get(KerberosAuthenticationHandler.PRINCIPAL), principal); }
@Test public void testGetKerberosPrincipalWithSubstitutedHostSecure() throws Exception { String principal = StartupProperties.get().getProperty(FalconAuthenticationFilter.KERBEROS_PRINCIPAL); String expectedPrincipal = "falcon/" + SecurityUtil.getLocalHostName().toLowerCase() + "@Example.com"; try { Configuration conf = new Configuration(false); conf.set("hadoop.security.authentication", "kerberos"); UserGroupInformation.setConfiguration(conf); Assert.assertTrue(UserGroupInformation.isSecurityEnabled()); StartupProperties.get().setProperty( FalconAuthenticationFilter.KERBEROS_PRINCIPAL, "falcon/_HOST@Example.com"); FalconAuthenticationFilter filter = new FalconAuthenticationFilter(); Properties properties = filter.getConfiguration(FalconAuthenticationFilter.FALCON_PREFIX, null); Assert.assertEquals( properties.get(KerberosAuthenticationHandler.PRINCIPAL), expectedPrincipal); } finally { StartupProperties.get().setProperty(FalconAuthenticationFilter.KERBEROS_PRINCIPAL, principal); } }