use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class IpClientTests method testMissingProfileCreator.
@Test
public void testMissingProfileCreator() {
final var client = new IpClient(new SimpleTestTokenAuthenticator());
client.setProfileCreator(null);
TestsHelper.expectException(() -> client.getUserProfile(new TokenCredentials(TOKEN), MockWebContext.create(), new MockSessionStore()), TechnicalException.class, "profileCreator cannot be null");
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class FormClientTests method testGetCredentials.
@Test
public void testGetCredentials() {
final var formClient = getFormClient();
final var context = MockWebContext.create();
final var action = (FoundAction) TestsHelper.expectException(() -> formClient.getCredentials(context.addRequestParameter(formClient.getUsernameParameter(), USERNAME).addRequestParameter(formClient.getPasswordParameter(), PASSWORD), new MockSessionStore()));
assertEquals(302, action.getCode());
assertEquals(LOGIN_URL + "?" + formClient.getUsernameParameter() + "=" + USERNAME + "&" + FormClient.ERROR_PARAMETER + "=" + CredentialsException.class.getSimpleName(), action.getLocation());
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class IpRegexpAuthenticatorTests method testValidateGoodIP.
@Test
public void testValidateGoodIP() {
final var credentials = new TokenCredentials(GOOD_IP);
authenticator.validate(credentials, null, new MockSessionStore());
final var profile = (IpProfile) credentials.getUserProfile();
assertEquals(GOOD_IP, profile.getId());
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class DigestExtractorTests method testRetrieveDigestHeaderComponents.
@Test
public void testRetrieveDigestHeaderComponents() {
final var context = MockWebContext.create();
context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER, DIGEST_AUTHORIZATION_HEADER_VALUE);
final var credentials = (DigestCredentials) digestExtractor.extract(context, new MockSessionStore()).get();
assertEquals(DIGEST_RESPONSE, credentials.getToken());
assertEquals(USERNAME, credentials.getUsername());
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class ParameterExtractorTests method testRetrieveNoPostParameter.
@Test
public void testRetrieveNoPostParameter() {
final var context = MockWebContext.create().setRequestMethod(HttpConstants.HTTP_METHOD.POST.name());
final var credentials = postExtractor.extract(context, new MockSessionStore());
assertFalse(credentials.isPresent());
}
Aggregations