use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class DefaultAuthorizationCheckerTests method testTwoExistingAuthorizerProfileMatch.
@Test
public void testTwoExistingAuthorizerProfileMatch() {
profile.setId(VALUE);
profile.addRole(ROLE);
final Map<String, Authorizer> authorizers = new HashMap<>();
authorizers.put(NAME, new IdAuthorizer());
authorizers.put(VALUE, new RequireAnyRoleAuthorizer(ROLE));
assertTrue(checker.isAuthorized(null, new MockSessionStore(), profiles, NAME + Pac4jConstants.ELEMENT_SEPARATOR + VALUE, authorizers, new ArrayList<>()));
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class DefaultAuthorizationCheckerTests method testBlankAuthorizerNameAProfilePostRequestIndirectClient.
@Test
public void testBlankAuthorizerNameAProfilePostRequestIndirectClient() {
final var context = MockWebContext.create().setRequestMethod("POST");
final List<Client> clients = new ArrayList<>();
clients.add(new MockIndirectClient("test"));
assertFalse(checker.isAuthorized(context, new MockSessionStore(), profiles, " ", new HashMap<>(), clients));
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class DefaultAuthorizationCheckerTests method testNullAuthorizerNameAProfilePostRequestIndirectClient.
@Test
public void testNullAuthorizerNameAProfilePostRequestIndirectClient() {
final var context = MockWebContext.create().setRequestMethod("POST");
final List<Client> clients = new ArrayList<>();
clients.add(new MockIndirectClient("test"));
assertFalse(checker.isAuthorized(context, new MockSessionStore(), profiles, null, new HashMap<>(), clients));
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class DefaultAuthorizationCheckerTests method testNullAuthorizers.
@Test(expected = TechnicalException.class)
public void testNullAuthorizers() {
assertTrue(checker.isAuthorized(null, new MockSessionStore(), profiles, null));
checker.isAuthorized(null, new MockSessionStore(), profiles, "auth1", null, new ArrayList<>());
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class DefaultAuthorizationCheckerTests method testTwoExistingAuthorizerProfileDoesNotMatch.
@Test
public void testTwoExistingAuthorizerProfileDoesNotMatch() {
profile.addRole(ROLE);
final Map<String, Authorizer> authorizers = new HashMap<>();
authorizers.put(NAME, new IdAuthorizer());
authorizers.put(VALUE, new RequireAnyRoleAuthorizer(ROLE));
assertFalse(checker.isAuthorized(null, new MockSessionStore(), profiles, NAME + Pac4jConstants.ELEMENT_SEPARATOR + VALUE, authorizers, new ArrayList<>()));
}
Aggregations