예제 #1
0
 @Test
 public void testNullCredentials() throws RequiresHttpAction {
   final MockIndirectClient client =
       new MockIndirectClient(
           TYPE, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
   final MockWebContext context = MockWebContext.create();
   client.setCallbackUrl(CALLBACK_URL);
   assertNull(client.getUserProfile(null, context));
 }
예제 #2
0
 @Test
 public void testIndirectClientWithImmediate() 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.redirect(context);
   final String redirectionUrl = context.getResponseLocation();
   assertEquals(LOGIN_URL, redirectionUrl);
 }
예제 #3
0
 @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));
 }
예제 #4
0
 @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());
 }
예제 #5
0
 @Test
 public void testAjaxRequest() {
   final MockIndirectClient client =
       new MockIndirectClient(
           TYPE, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
   client.setCallbackUrl(CALLBACK_URL);
   final MockWebContext context =
       MockWebContext.create()
           .addRequestHeader(HttpConstants.AJAX_HEADER_NAME, HttpConstants.AJAX_HEADER_VALUE);
   final RequiresHttpAction e =
       (RequiresHttpAction) TestsHelper.expectException(() -> client.redirect(context));
   assertEquals(401, e.getCode());
   assertEquals(401, context.getResponseStatus());
 }