Search in sources :

Example 6 with AnonymousProfile

use of org.pac4j.core.profile.AnonymousProfile in project pac4j by pac4j.

the class IsAuthenticatedAuthorizerTests method testCommonProfileTwoProfiles.

@Test
public void testCommonProfileTwoProfiles() {
    profiles.add(new AnonymousProfile());
    profiles.add(profile);
    assertTrue(authorizer.isAuthorized(null, new MockSessionStore(), profiles));
}
Also used : AnonymousProfile(org.pac4j.core.profile.AnonymousProfile) MockSessionStore(org.pac4j.core.context.session.MockSessionStore) Test(org.junit.Test)

Example 7 with AnonymousProfile

use of org.pac4j.core.profile.AnonymousProfile in project pac4j by pac4j.

the class DefaultAuthorizationCheckerTests method testIsAnonymous.

@Test
public void testIsAnonymous() {
    profiles.clear();
    profiles.add(new AnonymousProfile());
    assertTrue(checker.isAuthorized(null, new MockSessionStore(), profiles, DefaultAuthorizers.IS_ANONYMOUS, new HashMap<>(), new ArrayList<>()));
}
Also used : AnonymousProfile(org.pac4j.core.profile.AnonymousProfile) MockSessionStore(org.pac4j.core.context.session.MockSessionStore) Test(org.junit.Test)

Example 8 with AnonymousProfile

use of org.pac4j.core.profile.AnonymousProfile in project pac4j by pac4j.

the class IsAuthenticatedAuthorizerTests method testAnonymousProfileRedirectionUrl.

@Test
public void testAnonymousProfileRedirectionUrl() {
    profiles.add(new AnonymousProfile());
    ((IsAuthenticatedAuthorizer) authorizer).setRedirectionUrl(PAC4J_URL);
    TestsHelper.expectException(() -> authorizer.isAuthorized(MockWebContext.create(), new MockSessionStore(), profiles), HttpAction.class, "Performing a 302 HTTP action");
}
Also used : AnonymousProfile(org.pac4j.core.profile.AnonymousProfile) MockSessionStore(org.pac4j.core.context.session.MockSessionStore) Test(org.junit.Test)

Example 9 with AnonymousProfile

use of org.pac4j.core.profile.AnonymousProfile in project pac4j by pac4j.

the class IsAnonymousAuthorizerTests method testTwoAnonProfiles.

@Test
public void testTwoAnonProfiles() {
    profiles.add(new AnonymousProfile());
    profiles.add(new AnonymousProfile());
    assertTrue(authorizer.isAuthorized(null, new MockSessionStore(), profiles));
}
Also used : AnonymousProfile(org.pac4j.core.profile.AnonymousProfile) MockSessionStore(org.pac4j.core.context.session.MockSessionStore) Test(org.junit.Test)

Example 10 with AnonymousProfile

use of org.pac4j.core.profile.AnonymousProfile in project pac4j by pac4j.

the class IsFullyAuthenticatedAuthorizerTests method testAnonymousProfileRedirectionUrl.

@Override
@Test
public void testAnonymousProfileRedirectionUrl() {
    profiles.add(new AnonymousProfile());
    ((IsFullyAuthenticatedAuthorizer) authorizer).setRedirectionUrl(PAC4J_URL);
    TestsHelper.expectException(() -> authorizer.isAuthorized(MockWebContext.create(), new MockSessionStore(), profiles), HttpAction.class, "Performing a 302 HTTP action");
}
Also used : AnonymousProfile(org.pac4j.core.profile.AnonymousProfile) MockSessionStore(org.pac4j.core.context.session.MockSessionStore) Test(org.junit.Test)

Aggregations

AnonymousProfile (org.pac4j.core.profile.AnonymousProfile)10 Test (org.junit.Test)9 MockSessionStore (org.pac4j.core.context.session.MockSessionStore)9 lombok.val (lombok.val)1 CommonProfile (org.pac4j.core.profile.CommonProfile)1