[java-plugin-shibd-saml] branch main updated: Add some more tests/
Scott Cantor
cantor.2 at osu.edu
Mon Oct 7 20:47:00 UTC 2024
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-plugin-shibd-saml.
View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-shibd-saml.git;a=commit;h=cb57e84262b5da2e94ab4b0c33dbefbbecf5060d
The following commit(s) were added to refs/heads/main by this push:
new cb57e84 Add some more tests/
cb57e84 is described below
commit cb57e84262b5da2e94ab4b0c33dbefbbecf5060d
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Oct 7 16:46:58 2024 -0400
Add some more tests/
---
.../flows/saml2/SAML2TokenConsumerFlowTest.java | 75 ++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/sp-saml-conf-impl/src/test/java/net/shibboleth/sp/saml/flows/saml2/SAML2TokenConsumerFlowTest.java b/sp-saml-conf-impl/src/test/java/net/shibboleth/sp/saml/flows/saml2/SAML2TokenConsumerFlowTest.java
index 4435048..c1866da 100644
--- a/sp-saml-conf-impl/src/test/java/net/shibboleth/sp/saml/flows/saml2/SAML2TokenConsumerFlowTest.java
+++ b/sp-saml-conf-impl/src/test/java/net/shibboleth/sp/saml/flows/saml2/SAML2TokenConsumerFlowTest.java
@@ -36,6 +36,8 @@ import org.opensaml.saml.saml2.core.Response;
import org.opensaml.saml.saml2.core.StatusCode;
import org.opensaml.saml.saml2.core.Subject;
import org.opensaml.saml.saml2.core.SubjectConfirmation;
+import org.opensaml.saml.saml2.core.SubjectConfirmationData;
+import org.opensaml.saml.saml2.core.SubjectLocality;
import org.opensaml.saml.saml2.testing.SAML2ActionTestingSupport;
import org.opensaml.security.SecurityException;
import org.opensaml.security.credential.Credential;
@@ -242,6 +244,79 @@ public class SAML2TokenConsumerFlowTest extends AbstractSPFlowTest {
validateAssertionError(output, "Assertion IssueInstant was expired");
}
+ /**
+ * Test flow with bad SubjectLocality.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testSubjectLocality() throws IOException {
+ final Response response = buildSAMLResponse(ISSUER, StatusCode.SUCCESS);
+ final SubjectLocality locality = response.getAssertions().get(0).getAuthnStatements().get(0).getSubjectLocality();
+ assert locality != null;
+ locality.setAddress("127.0.0.1");
+ sign(response);
+ final DDF input = buildRemotedPOSTResponse(response);
+ setApplicationRequest(APPLICATION_ID, input);
+
+ final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ assertFlowExecutionResult(result, FLOW_ID);
+ assertFlowExecutionOutcome(result.getOutcome());
+ final DDF output = assertOutputMessageEvent(result, EventIds.INVALID_MESSAGE);
+ validateAssertionError(output, String.format("SubjectLocality/@Address for assertion '%s' did not match supplied valid addresses: [/192.168.1.1]",
+ response.getAssertions().get(0).getID()));
+ }
+
+ /**
+ * Test flow with bad confirmation address.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testBadConfirmationAddress() throws IOException {
+ final Response response = buildSAMLResponse(ISSUER, StatusCode.SUCCESS);
+ final Subject subject = response.getAssertions().get(0).getSubject();
+ assert subject != null;
+ final SubjectConfirmationData data = subject.getSubjectConfirmations().get(0).getSubjectConfirmationData();
+ assert data != null;
+ data.setAddress("127.0.0.1");
+ sign(response);
+ final DDF input = buildRemotedPOSTResponse(response);
+ setApplicationRequest(APPLICATION_ID, input);
+
+ final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ assertFlowExecutionResult(result, FLOW_ID);
+ assertFlowExecutionOutcome(result.getOutcome());
+ final DDF output = assertOutputMessageEvent(result, EventIds.INVALID_MESSAGE);
+ validateAssertionError(output, String.format("SubjectConfirmationData/@Address for assertion '%s' did not match supplied valid addresses: [/192.168.1.1]",
+ response.getAssertions().get(0).getID()));
+ }
+
+ /**
+ * Test flow with bad confirmation recipient.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testBadRecipient() throws IOException {
+ final Response response = buildSAMLResponse(ISSUER, StatusCode.SUCCESS);
+ final Subject subject = response.getAssertions().get(0).getSubject();
+ assert subject != null;
+ final SubjectConfirmationData data = subject.getSubjectConfirmations().get(0).getSubjectConfirmationData();
+ assert data != null;
+ data.setRecipient(RESPONSE_URL + "/bad");
+ sign(response);
+ final DDF input = buildRemotedPOSTResponse(response);
+ setApplicationRequest(APPLICATION_ID, input);
+
+ final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ assertFlowExecutionResult(result, FLOW_ID);
+ assertFlowExecutionOutcome(result.getOutcome());
+ final DDF output = assertOutputMessageEvent(result, EventIds.INVALID_MESSAGE);
+ validateAssertionError(output, String.format("SubjectConfirmationData/@Recipient for assertion '%s' did not match any valid recipients: [https://sp.example.org/Shibboleth.sso/SAML2/POST]",
+ response.getAssertions().get(0).getID()));
+ }
+
/**
* Test flow with bad issuer value.
*
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list