use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class HttpMethodMatcherTests method testBadMethod.
@Test
public void testBadMethod() {
final HttpMethodMatcher matcher = new HttpMethodMatcher(HTTP_METHOD.GET);
final MockWebContext context = MockWebContext.create().setRequestMethod(HTTP_METHOD.POST.name());
assertFalse(matcher.matches(context));
}
use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class DefaultCallbackClientFinderTests method testQueryParameter.
@Test
public void testQueryParameter() {
final IndirectClient facebook = new MockIndirectClient("Facebook");
final DirectClient basicAuth = new MockDirectClient("BasicAuth");
final IndirectClient cas = new MockIndirectClient("cas");
final Clients clients = new Clients(CALLBACK_URL, facebook, basicAuth, cas);
clients.init();
final MockWebContext context = MockWebContext.create().addRequestParameter(Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER, "facebook ");
final ClientFinder finder = new DefaultCallbackClientFinder();
final List<Client> result = finder.find(clients, context, null);
assertEquals(1, result.size());
assertEquals(facebook, result.get(0));
}
use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class DefaultCallbackClientFinderTests method testDefaultClientIndirectClientInURL.
@Test
public void testDefaultClientIndirectClientInURL() {
final IndirectClient facebook = new MockIndirectClient("Facebook");
final IndirectClient twitter = new MockIndirectClient("Twitter");
final Clients clients = new Clients(CALLBACK_URL, twitter, facebook);
clients.init();
final MockWebContext context = MockWebContext.create().addRequestParameter(Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER, "Twitter");
final DefaultCallbackClientFinder finder = new DefaultCallbackClientFinder();
final List<Client> result = finder.find(clients, context, "Twitter");
assertEquals(1, result.size());
assertEquals(twitter, result.get(0));
}
use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class HeaderExtractorTests method testRetrieveHeaderOk.
@Test
public void testRetrieveHeaderOk() {
final MockWebContext context = MockWebContext.create().addRequestHeader(GOOD_HEADER, GOOD_PREFIX + VALUE);
final TokenCredentials credentials = extractor.extract(context);
assertEquals(VALUE, credentials.getToken());
}
use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.
the class RememberMeAuthorizationGeneratorTests method testGoodRmeValue.
@Test
public void testGoodRmeValue() {
final RememberMeAuthorizationGenerator ag = new RememberMeAuthorizationGenerator<>();
final MockWebContext context = MockWebContext.create().addRequestParameter("rme", "true");
ag.generate(context, profile);
assertTrue(profile.isRemembered());
}
Aggregations