Search in sources :

Example 11 with MockWebContext

use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.

the class DefaultAjaxRequestResolverTests method testForcedAjaxParameter.

@Test
public void testForcedAjaxParameter() {
    final MockWebContext context = MockWebContext.create().addRequestParameter("is_ajax_request", "true");
    assertTrue(resolver.isAjax(context));
}
Also used : MockWebContext(org.pac4j.core.context.MockWebContext) Test(org.junit.Test)

Example 12 with MockWebContext

use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.

the class PathParameterCallbackUrlResolverTests method testMatchesSimplePath.

@Test
public void testMatchesSimplePath() {
    final MockWebContext context = MockWebContext.create();
    context.setPath(CLIENT_NAME);
    assertTrue(resolver.matches(CLIENT_NAME, context));
}
Also used : MockWebContext(org.pac4j.core.context.MockWebContext) Test(org.junit.Test)

Example 13 with MockWebContext

use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.

the class QueryParameterCallbackUrlResolverTests method testMatches.

@Test
public void testMatches() {
    final MockWebContext context = MockWebContext.create();
    context.addRequestParameter(Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER, CLIENT_NAME);
    assertTrue(resolver.matches(CLIENT_NAME, context));
}
Also used : MockWebContext(org.pac4j.core.context.MockWebContext) Test(org.junit.Test)

Example 14 with MockWebContext

use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.

the class DefaultUrlResolverTests method testCompute_whenHostIsPresent.

@Test
public void testCompute_whenHostIsPresent() {
    final MockWebContext context = MockWebContext.create();
    context.setServerName("pac4j.com");
    final String result = resolver.compute("http://cashost.com/cas/login", context);
    assertEquals("http://cashost.com/cas/login", result);
}
Also used : MockWebContext(org.pac4j.core.context.MockWebContext) Test(org.junit.Test)

Example 15 with MockWebContext

use of org.pac4j.core.context.MockWebContext in project pac4j by pac4j.

the class DefaultUrlResolverTests method testCompute_whenServerIsNotUsingDefaultHttpsPort.

@Test
public void testCompute_whenServerIsNotUsingDefaultHttpsPort() {
    final MockWebContext context = MockWebContext.create();
    context.setServerName("pac4j.com");
    context.setScheme("https");
    context.setSecure(true);
    context.setServerPort(8181);
    final String result = resolver.compute("/cas/login", context);
    assertEquals("https://pac4j.com:8181/cas/login", result);
}
Also used : MockWebContext(org.pac4j.core.context.MockWebContext) Test(org.junit.Test)

Aggregations

MockWebContext (org.pac4j.core.context.MockWebContext)96 Test (org.junit.Test)91 TokenCredentials (org.pac4j.core.credentials.TokenCredentials)20 CommonProfile (org.pac4j.core.profile.CommonProfile)18 CasConfiguration (org.pac4j.cas.config.CasConfiguration)10 UsernamePasswordCredentials (org.pac4j.core.credentials.UsernamePasswordCredentials)5 HttpAction (org.pac4j.core.exception.HttpAction)5 CasProfile (org.pac4j.cas.profile.CasProfile)4 SimpleTestTokenAuthenticator (org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator)4 DigestCredentials (org.pac4j.http.credentials.DigestCredentials)3 AssertionImpl (org.jasig.cas.client.validation.AssertionImpl)2 CasRestProfile (org.pac4j.cas.profile.CasRestProfile)2 Credentials (org.pac4j.core.credentials.Credentials)2 TechnicalException (org.pac4j.core.exception.TechnicalException)2 KerberosCredentials (org.pac4j.kerberos.credentials.KerberosCredentials)2 URL (java.net.URL)1 IndirectClient (org.pac4j.core.client.IndirectClient)1 Cookie (org.pac4j.core.context.Cookie)1 PathParameterCallbackUrlResolver (org.pac4j.core.http.callback.PathParameterCallbackUrlResolver)1 JavaSerializationHelper (org.pac4j.core.util.JavaSerializationHelper)1