Search in sources :

Example 11 with HttpAction

use of org.pac4j.core.exception.HttpAction in project pac4j by pac4j.

the class DirectCasClientTests method testNoTokenRedirectionExpected.

@Test
public void testNoTokenRedirectionExpected() {
    final CasConfiguration configuration = new CasConfiguration();
    configuration.setLoginUrl(LOGIN_URL);
    final DirectCasClient client = new DirectCasClient(configuration);
    final MockWebContext context = MockWebContext.create();
    context.setFullRequestURL(CALLBACK_URL);
    final HttpAction action = (HttpAction) TestsHelper.expectException(() -> client.getCredentials(context));
    assertEquals(302, action.getCode());
    assertEquals(addParameter(LOGIN_URL, CasConfiguration.SERVICE_PARAMETER, CALLBACK_URL), context.getResponseHeaders().get(HttpConstants.LOCATION_HEADER));
}
Also used : MockWebContext(org.pac4j.core.context.MockWebContext) CasConfiguration(org.pac4j.cas.config.CasConfiguration) HttpAction(org.pac4j.core.exception.HttpAction) Test(org.junit.Test)

Aggregations

HttpAction (org.pac4j.core.exception.HttpAction)11 Test (org.junit.Test)5 MockWebContext (org.pac4j.core.context.MockWebContext)5 CommonProfile (org.pac4j.core.profile.CommonProfile)5 Client (org.pac4j.core.client.Client)4 Clients (org.pac4j.core.client.Clients)3 IndirectClient (org.pac4j.core.client.IndirectClient)3 Credentials (org.pac4j.core.credentials.Credentials)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 CasConfiguration (org.pac4j.cas.config.CasConfiguration)2 WebContext (org.pac4j.core.context.WebContext)2 ProfileManager (org.pac4j.core.profile.ProfileManager)2 RedirectAction (org.pac4j.core.redirect.RedirectAction)2 LinkedHashSet (java.util.LinkedHashSet)1 HttpSession (javax.servlet.http.HttpSession)1 PreventedException (org.apereo.cas.authentication.PreventedException)1 ClientCredential (org.apereo.cas.authentication.principal.ClientCredential)1 WebApplicationService (org.apereo.cas.authentication.principal.WebApplicationService)1 UnauthorizedServiceException (org.apereo.cas.services.UnauthorizedServiceException)1