use of org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator in project pac4j by pac4j.
the class CookieClientTests method testMissingCookieName.
@Test(expected = Exception.class)
public void testMissingCookieName() {
final CookieClient cookieClient = new CookieClient(null, new SimpleTestTokenAuthenticator());
cookieClient.init();
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator in project pac4j by pac4j.
the class CookieClientTests method testAuthentication.
@Test
public void testAuthentication() {
final CookieClient client = new CookieClient(USERNAME, new SimpleTestTokenAuthenticator());
final MockWebContext context = MockWebContext.create();
final Cookie c = new Cookie(USERNAME, Base64.getEncoder().encodeToString(getClass().getName().getBytes(StandardCharsets.UTF_8)));
context.getRequestCookies().add(c);
final TokenCredentials credentials = client.getCredentials(context);
final CommonProfile profile = client.getUserProfile(credentials, context);
assertEquals(c.getValue(), profile.getId());
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator in project pac4j by pac4j.
the class HeaderClientTests method testMissingHeaderName.
@Test
public void testMissingHeaderName() {
final HeaderClient client = new HeaderClient(null, new SimpleTestTokenAuthenticator());
TestsHelper.initShouldFail(client, "headerName cannot be blank");
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestTokenAuthenticator in project pac4j by pac4j.
the class HeaderClientTests method testAuthentication.
@Test
public void testAuthentication() {
final HeaderClient client = new HeaderClient(HEADER_NAME, PREFIX_HEADER, new SimpleTestTokenAuthenticator());
final MockWebContext context = MockWebContext.create();
context.addRequestHeader(HEADER_NAME, PREFIX_HEADER + VALUE);
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 IpClientTests method testMissingProfileCreator.
@Test
public void testMissingProfileCreator() {
final IpClient client = new IpClient(new SimpleTestTokenAuthenticator());
client.setProfileCreator(null);
TestsHelper.expectException(() -> client.getUserProfile(new TokenCredentials(TOKEN), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null");
}
Aggregations