NegotiateAuthenticationFilter extends AuthenticatingFilter { void sendChallengeOnFailure(final ServletResponse response) { final HttpServletResponse httpResponse = WebUtils.toHttp(response); this.sendUnauthorized(NegotiateAuthenticationFilter.PROTOCOLS, null, httpResponse); httpResponse.setHeader("Connection", "close"); try { httpResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED); httpResponse.flushBuffer(); } catch (final IOException e) { throw new RuntimeException(e); } } NegotiateAuthenticationFilter(); String getRememberMeParam(); void setRememberMeParam(final String value); String getFailureKeyAttribute(); void setFailureKeyAttribute(final String value);  }
@Test void testSendChallengeOnFailure() { this.negAuthFilter.sendChallengeOnFailure(this.response); Assertions.assertEquals("Negotiate", this.response.headersAdded.get("WWW-Authenticate").get(0)); Assertions.assertEquals("NTLM", this.response.headersAdded.get("WWW-Authenticate").get(1)); Assertions.assertEquals("close", this.response.headers.get("Connection")); Assertions.assertEquals(0, this.response.sc); Assertions.assertEquals(HttpServletResponse.SC_UNAUTHORIZED, this.response.errorCode); Assertions.assertTrue(this.response.isFlushed); }