use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class ParameterExtractorTests method testRetrieveNoGetParameter.
@Test
public void testRetrieveNoGetParameter() {
final MockWebContext context = MockWebContext.create().setRequestMethod(HTTP_METHOD.GET.name());
final TokenCredentials credentials = getExtractor.extract(context);
assertNull(credentials);
}
use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class CasClientTests method testBackLogout.
@Test
public void testBackLogout() {
final CasConfiguration configuration = new CasConfiguration();
configuration.setLoginUrl(LOGIN_URL);
final CasClient casClient = new CasClient(configuration);
casClient.setCallbackUrl(CALLBACK_URL);
casClient.init();
final MockWebContext context = MockWebContext.create().addRequestParameter(CasConfiguration.LOGOUT_REQUEST_PARAMETER, LOGOUT_MESSAGE).setRequestMethod(HTTP_METHOD.POST.name());
TestsHelper.expectException(() -> casClient.getCredentials(context), HttpAction.class, "Perfoming a 204 HTTP action");
assertEquals(204, context.getResponseStatus());
}
use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class CasClientTests method testFrontLogout.
@Test
public void testFrontLogout() {
final CasConfiguration configuration = new CasConfiguration();
configuration.setLoginUrl(LOGIN_URL);
final CasClient casClient = new CasClient(configuration);
casClient.setCallbackUrl(CALLBACK_URL);
casClient.init();
final MockWebContext context = MockWebContext.create().addRequestParameter(CasConfiguration.LOGOUT_REQUEST_PARAMETER, deflateAndBase64(LOGOUT_MESSAGE)).setRequestMethod(HTTP_METHOD.GET.name());
assertNull(casClient.getCredentials(context));
}
use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class CasClientTests method testGatewayOK.
@Test
public void testGatewayOK() {
final CasConfiguration configuration = new CasConfiguration();
configuration.setLoginUrl(LOGIN_URL);
final CasClient casClient = new CasClient(configuration);
casClient.setCallbackUrl(CALLBACK_URL);
final MockWebContext context = MockWebContext.create();
configuration.setGateway(true);
casClient.redirect(context);
assertTrue(context.getResponseLocation().indexOf("gateway=true") >= 0);
final TokenCredentials credentials = casClient.getCredentials(context);
assertNull(credentials);
}
use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class CasClientTests method testRenew.
@Test
public void testRenew() {
final CasConfiguration configuration = new CasConfiguration();
configuration.setLoginUrl(LOGIN_URL);
final CasClient casClient = new CasClient(configuration);
casClient.setCallbackUrl(CALLBACK_URL);
configuration.setRenew(true);
final MockWebContext context = MockWebContext.create();
casClient.redirect(context);
assertTrue(context.getResponseLocation().indexOf("renew=true") >= 0);
}
Aggregations