@Test public void testSaveAlreadyTried() throws RequiresHttpAction { final MockIndirectClient client = new MockIndirectClient( TYPE, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile()); client.setCallbackUrl(CALLBACK_URL); final MockWebContext context = MockWebContext.create(); client.getCredentials(context); assertEquals( "true", (String) context.getSessionAttribute( client.getName() + IndirectClient.ATTEMPTED_AUTHENTICATION_SUFFIX)); }
@Test public void testAlreadyTried() { final MockIndirectClient client = new MockIndirectClient( TYPE, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile()); client.setCallbackUrl(CALLBACK_URL); final MockWebContext context = MockWebContext.create(); context.setSessionAttribute( client.getName() + IndirectClient.ATTEMPTED_AUTHENTICATION_SUFFIX, "true"); final RequiresHttpAction e = (RequiresHttpAction) TestsHelper.expectException(() -> client.redirect(context)); assertEquals(401, e.getCode()); assertEquals(401, context.getResponseStatus()); }