use of org.pac4j.core.client.Clients in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testBlankClientName.
@Test
public void testBlankClientName() {
final List<Client> currentClients = finder.find(new Clients(), MockWebContext.create(), " ");
assertEquals(0, currentClients.size());
}
use of org.pac4j.core.client.Clients in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testOneClientAsDefault.
@Test
public void testOneClientAsDefault() {
final MockIndirectClient client1 = new MockIndirectClient(NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final Clients clients = new Clients(client1);
final List<Client> result = finder.find(clients, MockWebContext.create(), null);
assertEquals(1, result.size());
assertEquals(client1, result.get(0));
}
use of org.pac4j.core.client.Clients in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method internalTestClientOnRequestAllowedList.
private void internalTestClientOnRequestAllowedList(final String parameterName, final String names) {
final MockIndirectClient client = new MockIndirectClient(NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final Clients clients = new Clients(client);
final WebContext context = MockWebContext.create().addRequestParameter(Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER, parameterName);
final List<Client> currentClients = finder.find(clients, context, names);
assertEquals(1, currentClients.size());
assertEquals(client, currentClients.get(0));
}
use of org.pac4j.core.client.Clients in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testBadClientOnRequest.
@Test
public void testBadClientOnRequest() {
final MockIndirectClient client = new MockIndirectClient(NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final Clients clients = new Clients(client);
final WebContext context = MockWebContext.create().addRequestParameter(Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER, FAKE_VALUE);
TestsHelper.expectException(() -> finder.find(clients, context, NAME), TechnicalException.class, "No client found for name: " + FAKE_VALUE);
}
use of org.pac4j.core.client.Clients in project pac4j by pac4j.
the class DefaultCallbackLogicTests method testCallbackWithOriginallyRequestedUrl.
@Test
public void testCallbackWithOriginallyRequestedUrl() {
HttpSession session = request.getSession();
final String originalSessionId = session.getId();
session.setAttribute(Pac4jConstants.REQUESTED_URL, PAC4J_URL);
request.setParameter(Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER, NAME);
final CommonProfile profile = new CommonProfile();
final IndirectClient indirectClient = new MockIndirectClient(NAME, null, new MockCredentials(), profile);
config.setClients(new Clients(CALLBACK_URL, indirectClient));
config.getClients().init();
call();
session = request.getSession();
final String newSessionId = session.getId();
final LinkedHashMap<String, CommonProfile> profiles = (LinkedHashMap<String, CommonProfile>) session.getAttribute(Pac4jConstants.USER_PROFILES);
assertTrue(profiles.containsValue(profile));
assertEquals(1, profiles.size());
assertNotEquals(newSessionId, originalSessionId);
assertEquals(302, response.getStatus());
assertEquals(PAC4J_URL, response.getRedirectedUrl());
}
Aggregations