use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class FormClientTests method testGetCredentialsMissingPassword.
@Test
public void testGetCredentialsMissingPassword() {
final var formClient = getFormClient();
final var context = MockWebContext.create();
final var action = (FoundAction) TestsHelper.expectException(() -> formClient.getCredentials(context.addRequestParameter(formClient.getPasswordParameter(), PASSWORD), new MockSessionStore()));
assertEquals(302, action.getCode());
assertEquals(LOGIN_URL + "?" + formClient.getUsernameParameter() + "=&" + FormClient.ERROR_PARAMETER + "=" + FormClient.MISSING_FIELD_ERROR, action.getLocation());
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class FormClientTests method testGetRightCredentials.
@Test
public void testGetRightCredentials() {
final var formClient = getFormClient();
final var credentials = (UsernamePasswordCredentials) formClient.getCredentials(MockWebContext.create().addRequestParameter(formClient.getUsernameParameter(), USERNAME).addRequestParameter(formClient.getPasswordParameter(), USERNAME), new MockSessionStore()).get();
assertEquals(USERNAME, credentials.getUsername());
assertEquals(USERNAME, credentials.getPassword());
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class FormClientTests method testMissingProfileCreator.
@Test
public void testMissingProfileCreator() {
final var formClient = new FormClient(LOGIN_URL, new SimpleTestUsernamePasswordAuthenticator());
formClient.setCallbackUrl(CALLBACK_URL);
formClient.setProfileCreator(null);
TestsHelper.expectException(() -> formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD), 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 IpRegexpAuthenticatorTests method testNoPattern.
@Test(expected = TechnicalException.class)
public void testNoPattern() {
final var credentials = new TokenCredentials(GOOD_IP);
var authenticator = new IpRegexpAuthenticator();
authenticator.validate(credentials, null, new MockSessionStore());
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class DigestExtractorTests method testNotDigest.
@Test
public void testNotDigest() {
final var context = MockWebContext.create();
final var credentials = digestExtractor.extract(context, new MockSessionStore());
assertFalse(credentials.isPresent());
}
Aggregations