use of org.pac4j.core.client.MockIndirectClient in project pac4j by pac4j.
the class DefaultLogoutLogicTests method testCentralLogoutWithRelativeUrl.
@Test
public void testCentralLogoutWithRelativeUrl() {
final CommonProfile profile = new CommonProfile();
profile.setClientName(NAME);
final MockIndirectClient client = new MockIndirectClient(NAME);
client.setCallbackUrl(PAC4J_BASE_URL);
client.setLogoutActionBuilder((ctx, p, targetUrl) -> RedirectAction.redirect(CALLBACK_URL + "?p=" + targetUrl));
config.setClients(new Clients(client));
profiles.put(NAME, profile);
addProfilesToContext();
centralLogout = true;
context.addRequestParameter(Pac4jConstants.URL, PATH);
call();
assertEquals(302, context.getResponseStatus());
assertEquals(CALLBACK_URL + "?p=null", context.getResponseLocation());
expectedNProfiles(0);
}
use of org.pac4j.core.client.MockIndirectClient in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testBlankClientRequested.
@Test
public void testBlankClientRequested() {
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(), "");
assertEquals(0, result.size());
}
use of org.pac4j.core.client.MockIndirectClient in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testDefaultSecurityClients.
@Test
public void testDefaultSecurityClients() {
final MockIndirectClient client1 = new MockIndirectClient(NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final MockIndirectClient client2 = new MockIndirectClient(CLIENT_NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final Clients clients = new Clients(client1, client2);
clients.setDefaultSecurityClients(CLIENT_NAME);
final List<Client> result = finder.find(clients, MockWebContext.create(), null);
assertEquals(1, result.size());
assertEquals(client2, result.get(0));
}
use of org.pac4j.core.client.MockIndirectClient in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testNoClientOnRequestBadDefaultClient.
@Test
public void testNoClientOnRequestBadDefaultClient() {
final MockIndirectClient client1 = new MockIndirectClient(NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final MockIndirectClient client2 = new MockIndirectClient(CLIENT_NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final Clients clients = new Clients(client1, client2);
final WebContext context = MockWebContext.create();
TestsHelper.expectException(() -> finder.find(clients, context, FAKE_VALUE), TechnicalException.class, "No client found for name: " + FAKE_VALUE);
}
use of org.pac4j.core.client.MockIndirectClient in project pac4j by pac4j.
the class DefaultSecurityClientFinderTests method testNoClientOnRequest.
@Test
public void testNoClientOnRequest() {
final MockIndirectClient client1 = new MockIndirectClient(NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final MockIndirectClient client2 = new MockIndirectClient(CLIENT_NAME, RedirectAction.redirect(LOGIN_URL), (Credentials) null, new CommonProfile());
final Clients clients = new Clients(client1, client2);
final WebContext context = MockWebContext.create();
final List<Client> currentClients = finder.find(clients, context, CLIENT_NAME);
assertEquals(1, currentClients.size());
assertEquals(client2, currentClients.get(0));
}
Aggregations