### Question:
AuthFilter extends AuthenticationFilter { @Override protected Properties getConfiguration(String prefix, FilterConfig config) throws ServletException { final Properties p = super.getConfiguration(CONF_PREFIX, config); String authType = null; if(UserGroupInformation.isSecurityEnabled()) { if(UserGroupInformation.isTokenAuthEnabled()) { authType = TokenAuthAuthenticationHandler.class.getName(); } else { authType = KerberosAuthenticationHandler.TYPE; } } else { authType = PseudoAuthenticationHandler.TYPE; } p.setProperty(AUTH_TYPE, authType); if (p.getProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED) == null) { p.setProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED, "true"); } p.setProperty(COOKIE_PATH, "/"); return p; }  @Override void doFilter(ServletRequest request, ServletResponse response,
      FilterChain filterChain);  }### Answer:
@Test public void testGetConfiguration() throws ServletException { AuthFilter filter = new AuthFilter(); Map<String, String> m = new HashMap<String,String>(); m.put(DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_PRINCIPAL_KEY, "xyz/thehost@REALM"); m.put(DFSConfigKeys.DFS_WEB_AUTHENTICATION_KERBEROS_KEYTAB_KEY, "thekeytab"); FilterConfig config = new DummyFilterConfig(m); Properties p = filter.getConfiguration("random", config); Assert.assertEquals("xyz/thehost@REALM", p.getProperty("kerberos.principal")); Assert.assertEquals("thekeytab", p.getProperty("kerberos.keytab")); Assert.assertEquals("true", p.getProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED)); }
@Test public void testGetSimpleAuthDisabledConfiguration() throws ServletException { AuthFilter filter = new AuthFilter(); Map<String, String> m = new HashMap<String,String>(); m.put(DFSConfigKeys.DFS_WEB_AUTHENTICATION_SIMPLE_ANONYMOUS_ALLOWED, "false"); FilterConfig config = new DummyFilterConfig(m); Properties p = filter.getConfiguration("random", config); Assert.assertEquals("false", p.getProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED)); }
@Test public void testGetSimpleAuthDefaultConfiguration() throws ServletException { AuthFilter filter = new AuthFilter(); Map<String, String> m = new HashMap<String,String>(); FilterConfig config = new DummyFilterConfig(m); Properties p = filter.getConfiguration("random", config); Assert.assertEquals("true", p.getProperty(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED)); }