MockCatalinaRequest request = AuthenticatorTestUtils.createRequest(SERVICE_PROVIDER_HOST_ADDRESS, true);
MockCatalinaResponse response = new MockCatalinaResponse();
sendAuthenticationRequest(request, response, SERVICE_PROVIDER_URL, true);
IdentityParticipantStack testIdentityParticipantStack = TestIdentityParticipantStack.getDelegate();
assertEquals("Unexpected total created sessions.", 1, testIdentityParticipantStack.totalSessions());
ResponseType responseType = getResponseTypeAndCheckSignature(response, null);
assertNotNull(responseType);
assertEquals(1, responseType.getAssertions().size());
assertEquals(responseType.getAssertions().get(0).getAssertion().getIssuer().getValue(), IDENTITY_PROVIDER_URL);
// The response should redirect back to the caller SP
assertTrue("Expected a redirect to the SP.", response.redirectString.contains(SERVICE_PROVIDER_URL));
String currentSessionID = request.getSession().getId();
// asserts if there is a participant for the current session ID
assertEquals(1, testIdentityParticipantStack.getParticipants(currentSessionID));
// asserts if the last participant in the stack is the last caller SP
assertEquals(SERVICE_PROVIDER_URL, testIdentityParticipantStack.peek(currentSessionID));
}