use of org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator in project pac4j by pac4j.
the class IndirectBasicAuthClientTests method testMissingProfileCreator.
@Test
public void testMissingProfileCreator() {
final IndirectBasicAuthClient basicAuthClient = new IndirectBasicAuthClient(NAME, new SimpleTestUsernamePasswordAuthenticator());
basicAuthClient.setCallbackUrl(CALLBACK_URL);
basicAuthClient.setProfileCreator(null);
TestsHelper.expectException(() -> basicAuthClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null");
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator in project pac4j by pac4j.
the class IndirectBasicAuthClientTests method testMissingCallbackUrl.
@Test
public void testMissingCallbackUrl() {
final IndirectBasicAuthClient basicAuthClient = new IndirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
TestsHelper.initShouldFail(basicAuthClient, "callbackUrl cannot be blank: set it up either on this IndirectClient or on the global Config");
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator in project pac4j by pac4j.
the class DirectBasicAuthClientTests method testHasDefaultProfileCreator.
@Test
public void testHasDefaultProfileCreator() {
final DirectBasicAuthClient basicAuthClient = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
basicAuthClient.init();
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator in project pac4j by pac4j.
the class DirectBasicAuthClientTests method testMissingProfileCreator.
@Test
public void testMissingProfileCreator() {
final DirectBasicAuthClient basicAuthClient = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator(), null);
TestsHelper.expectException(() -> basicAuthClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null");
}
use of org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator in project pac4j by pac4j.
the class DirectBasicAuthClientTests method testAuthentication.
@Test
public void testAuthentication() {
final DirectBasicAuthClient client = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
final MockWebContext context = MockWebContext.create();
final String header = USERNAME + ":" + USERNAME;
context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER, "Basic " + Base64.getEncoder().encodeToString(header.getBytes(StandardCharsets.UTF_8)));
final UsernamePasswordCredentials credentials = client.getCredentials(context);
final CommonProfile profile = client.getUserProfile(credentials, context);
assertEquals(USERNAME, profile.getId());
}
Aggregations