@Test public void testSetLoginUri() throws Exception { configureBrowserRequest(); final String logoutUri = "/foo"; authenticationEntryPoint.setLoginUri(logoutUri); authenticationEntryPoint.commence(request, response, null); assertEquals(HttpStatus.FOUND.value(), response.getStatus()); assertEquals(logoutUri, response.getHeader("Location")); }
@Test public void testCommenceWithUnauthorizedWithAccept() throws Exception { request.addHeader(HttpHeaders.ACCEPT, "application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); authenticationEntryPoint.commence(request, response, null); assertEquals(HttpStatus.UNAUTHORIZED.value(), response.getStatus()); assertNotNull(response.getHeader(HttpHeaders.WWW_AUTHENTICATE)); }
@Test public void testCommenceWithRedirect() throws Exception { configureBrowserRequest(); authenticationEntryPoint.commence(request, response, null); assertEquals(HttpStatus.FOUND.value(), response.getStatus()); assertEquals( KeycloakAuthenticationEntryPoint.DEFAULT_LOGIN_URI, response.getHeader("Location")); }