use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class BaseClientTests method testAlreadyTried.
@Test
public void testAlreadyTried() {
final var client = new MockIndirectClient(TYPE, new FoundAction(LOGIN_URL), Optional.empty(), new CommonProfile());
client.setCallbackUrl(CALLBACK_URL);
final var context = MockWebContext.create();
final SessionStore sessionStore = new MockSessionStore();
sessionStore.set(context, client.getName() + IndirectClient.ATTEMPTED_AUTHENTICATION_SUFFIX, "true");
final var e = (HttpAction) TestsHelper.expectException(() -> client.getRedirectionAction(context, sessionStore));
assertEquals(401, e.getCode());
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class IsAnonymousAuthorizerTests method testAnonymousProfile.
@Test
public void testAnonymousProfile() {
profiles.add(new AnonymousProfile());
assertTrue(authorizer.isAuthorized(null, new MockSessionStore(), profiles));
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class IsAnonymousAuthorizerTests method testCommonProfileRedirectionUrl.
@Test
public void testCommonProfileRedirectionUrl() {
profiles.add(new CommonProfile());
authorizer.setRedirectionUrl(PAC4J_URL);
TestsHelper.expectException(() -> authorizer.isAuthorized(MockWebContext.create(), new MockSessionStore(), profiles), HttpAction.class, "Performing a 302 HTTP action");
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class IsAnonymousAuthorizerTests method testAnonProfileTwoProfiles.
@Test
public void testAnonProfileTwoProfiles() {
profiles.add(new AnonymousProfile());
profiles.add(new CommonProfile());
assertFalse(authorizer.isAuthorized(null, new MockSessionStore(), profiles));
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class DefaultMatchingCheckerTests method testHsts.
@Test
public void testHsts() {
final var context = MockWebContext.create();
context.setScheme(SCHEME_HTTPS);
checker.matches(context, new MockSessionStore(), DefaultMatchers.HSTS, new HashMap<>(), new ArrayList<>());
assertNotNull(context.getResponseHeaders().get("Strict-Transport-Security"));
}
Aggregations