use of org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator in project pac4j by pac4j.
the class IpClientTests method testAuthentication.
@Test
public void testAuthentication() {
final IpClient client = new IpClient(new SimpleTestTokenAuthenticator());
final MockWebContext context = MockWebContext.create();
context.setRemoteAddress(IP);
final TokenCredentials credentials = client.getCredentials(context);
final CommonProfile profile = client.getUserProfile(credentials, context);
assertEquals(IP, profile.getId());
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator in project pac4j by pac4j.
the class ParameterClientTests method testMissingProfileCreator.
@Test
public void testMissingProfileCreator() {
final ParameterClient client = new ParameterClient(PARAMETER_NAME, new SimpleTestTokenAuthenticator(), null);
TestsHelper.expectException(() -> client.getUserProfile(new TokenCredentials(TOKEN), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null");
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator in project pac4j by pac4j.
the class ParameterClientTests method testHasDefaultProfileCreator.
@Test
public void testHasDefaultProfileCreator() {
final ParameterClient client = new ParameterClient(null, new SimpleTestTokenAuthenticator());
client.setParameterName(PARAMETER_NAME);
client.init();
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator in project pac4j by pac4j.
the class ParameterClientTests method testAuthentication.
@Test
public void testAuthentication() {
final ParameterClient client = new ParameterClient(PARAMETER_NAME, new SimpleTestTokenAuthenticator());
client.setSupportGetRequest(SUPPORT_GET);
client.setSupportPostRequest(SUPPORT_POST);
final MockWebContext context = MockWebContext.create();
context.addRequestParameter(PARAMETER_NAME, VALUE);
context.setRequestMethod(HttpConstants.HTTP_METHOD.GET.name());
final TokenCredentials credentials = client.getCredentials(context);
final CommonProfile profile = client.getUserProfile(credentials, context);
assertEquals(VALUE, profile.getId());
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator in project pac4j by pac4j.
the class CookieClientTests method testMissingProfileCreator.
@Test
public void testMissingProfileCreator() {
final CookieClient cookieClient = new CookieClient("testcookie", new SimpleTestTokenAuthenticator());
cookieClient.setProfileCreator(null);
TestsHelper.expectException(() -> cookieClient.getUserProfile(new TokenCredentials(TOKEN), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null");
}
Aggregations