use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class RedirectSAML2ClientTests method testSetComparisonTypeWithRedirectBinding.
@Test
public void testSetComparisonTypeWithRedirectBinding() {
final var client = getClient();
client.getConfiguration().setComparisonType(AuthnContextComparisonTypeEnumeration.EXACT.toString());
final var action = (FoundAction) client.getRedirectionAction(MockWebContext.create(), new MockSessionStore()).get();
assertTrue(getInflatedAuthnRequest(action.getLocation()).contains("Comparison=\"exact\""));
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class RedirectSAML2ClientTests method testCustomSpEntityIdForRedirectBinding.
@Test
public void testCustomSpEntityIdForRedirectBinding() {
final var client = getClient();
client.getConfiguration().setServiceProviderEntityId("http://localhost:8080/callback");
client.getConfiguration().setUseNameQualifier(true);
final var action = (FoundAction) client.getRedirectionAction(MockWebContext.create(), new MockSessionStore()).get();
final var inflated = getInflatedAuthnRequest(action.getLocation());
final var issuerJdk11 = "<saml2:Issuer " + "xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\" " + "Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\" " + "NameQualifier=\"http://localhost:8080/callback\">http://localhost:8080/callback</saml2:Issuer>";
assertTrue(inflated.contains(issuerJdk11));
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class RedirectSAML2ClientTests method testStandardSpEntityIdForRedirectBinding.
@Test
public void testStandardSpEntityIdForRedirectBinding() {
final var client = getClient();
client.getConfiguration().setServiceProviderEntityId("http://localhost:8080/callback");
final var action = (FoundAction) client.getRedirectionAction(MockWebContext.create(), new MockSessionStore()).get();
final var inflated = getInflatedAuthnRequest(action.getLocation());
final var issuerJdk11 = "<saml2:Issuer " + "xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\" " + "Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\">http://localhost:8080/callback</saml2:Issuer>";
assertTrue(inflated.contains(issuerJdk11));
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class SAML2LogoutValidatorTests method getSaml2MessageContext.
private static SAML2MessageContext getSaml2MessageContext(final MockWebContext webContext, final String xml) {
final var context = new SAML2MessageContext();
context.setSaml2Configuration(getSaml2Configuration());
final var samlMessage = new MessageContext();
final var samlResponse = (LogoutResponse) Configuration.deserializeSamlObject(xml).get();
samlMessage.setMessage(samlResponse);
context.setMessageContext(samlMessage);
final var entityDescriptor = new EntityDescriptorBuilder().buildObject();
context.getSAMLPeerMetadataContext().setEntityDescriptor(entityDescriptor);
context.setWebContext(webContext);
context.setSessionStore(new MockSessionStore());
final var spDescriptor = new SPSSODescriptorBuilder().buildObject();
final var logoutService = new SingleLogoutServiceBuilder().buildObject();
logoutService.setLocation("http://sp.example.com/demo1/logout");
spDescriptor.getSingleLogoutServices().add(logoutService);
context.getSAMLSelfMetadataContext().setRoleDescriptor(spDescriptor);
return context;
}
use of org.pac4j.core.context.session.MockSessionStore in project pac4j by pac4j.
the class IpClientTests method testAuthentication.
@Test
public void testAuthentication() {
final var client = new IpClient(new SimpleTestTokenAuthenticator());
final var context = MockWebContext.create();
context.setRemoteAddress(IP);
final var credentials = (TokenCredentials) client.getCredentials(context, new MockSessionStore()).get();
final var profile = (CommonProfile) client.getUserProfile(credentials, context, new MockSessionStore()).get();
assertEquals(IP, profile.getId());
}
Aggregations