[java-plugin-shibd] branch main updated: More tests and fixes.
Scott Cantor
cantor.2 at osu.edu
Tue Jul 1 14:20:04 UTC 2025
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-plugin-shibd.
View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-shibd.git;a=commit;h=fe7953d613832d0e21d58a1164c1f1a53354b45a
The following commit(s) were added to refs/heads/main by this push:
new fe7953d More tests and fixes.
fe7953d is described below
commit fe7953d613832d0e21d58a1164c1f1a53354b45a
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Jul 1 10:20:00 2025 -0400
More tests and fixes.
---
.../sp/profile/impl/IssueDiscoveryRequest.java | 9 ++--
.../sp/profile/impl/IssueDiscoveryRequestTest.java | 48 ++++++++++++++++++++--
2 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/IssueDiscoveryRequest.java b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/IssueDiscoveryRequest.java
index 9bbaf17..5cd448a 100644
--- a/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/IssueDiscoveryRequest.java
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/profile/impl/IssueDiscoveryRequest.java
@@ -175,11 +175,12 @@ public class IssueDiscoveryRequest extends AbstractApplicationAction {
final Escaper escaper = UrlEscapers.urlFormParameterEscaper();
if (state != null) {
- returnURL += escaper.escape('&' + SPConstants.STATE + '=' + state);
- // At this point, discoveryURL is already encoded, and thus does not need to
+ returnURL += escaper.escape('&' + SPConstants.STATE + '=' + escaper.escape(state));
+
+ // At this point, the return value is already encoded, and thus does not need to
// be run through the encoder, which is done this way to ensure that the character set
// of this URL is arbitrary from the hub's perspective, to avoid requiiring an explicit
- // conversion into String, that would depend on charset, This is the essence of the web's
+ // conversion into String that would depend on charset, This is the essence of the web's
// brokenness, that URLs are not in a defined or even *knowable* character encoding
// (as only the *body* is covered by the headers sent with the request).
}
@@ -234,7 +235,7 @@ public class IssueDiscoveryRequest extends AbstractApplicationAction {
/** {@inheritDoc} */
public boolean test(@Nullable final ProfileRequestContext t) {
return Integer.valueOf(1).equals(input.getmember("isPassive").integer())
- && "none".equals(input.getmember("prompt").string());
+ || "none".equals(input.getmember("prompt").string());
}
}
diff --git a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/IssueDiscoveryRequestTest.java b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/IssueDiscoveryRequestTest.java
index c6ccb6e..3ee5629 100644
--- a/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/IssueDiscoveryRequestTest.java
+++ b/sp-server-impl/src/test/java/net/shibboleth/sp/profile/impl/IssueDiscoveryRequestTest.java
@@ -37,6 +37,7 @@ import net.shibboleth.sp.ddf.DDF;
import net.shibboleth.sp.messaging.RemotedHttpServletResponse;
import net.shibboleth.sp.messaging.impl.RemotedlHttpServletResponseSupplier;
import net.shibboleth.sp.profile.InitiatorConstants;
+import net.shibboleth.sp.profile.SPConstants;
/**
* Unit test for {@link IssueDiscoveryRequest} action.
@@ -148,7 +149,45 @@ public class IssueDiscoveryRequestTest extends BaseAgplicationActionTest {
final byte[] redirect = output.getmember(
RemotedHttpServletResponse.STRUCTURE_NAME + '.' +
RemotedHttpServletResponse.REDIRECT).unsafe_string();
- Assert.assertEquals(redirect, buildDiscoveryURL(TEST_DISCOVERY_URL, TEST_RESPONSE_URL, null));
+ Assert.assertEquals(redirect, buildDiscoveryURL(TEST_DISCOVERY_URL, TEST_RESPONSE_URL, null, false));
+ }
+
+ @Test
+ public void testState() throws ComponentInitializationException {
+ final DDF input = new DDF(null).structure();
+ input.addmember(SPConstants.STATE).string("foo bar");
+ input.addmember(InitiatorConstants.DISCOVERY_RETURN_URL).string(escaper.escape("https://sp.example.org/handler?DS=1"));
+ arc.setInput(input);
+
+ final Event event = action.execute(src);
+ ActionTestingSupport.assertProceedEvent(event);
+
+ final DDF output = arc.getOutput();
+ assert output != null;
+ final byte[] redirect = output.getmember(
+ RemotedHttpServletResponse.STRUCTURE_NAME + '.' +
+ RemotedHttpServletResponse.REDIRECT).unsafe_string();
+ Assert.assertEquals(redirect, buildDiscoveryURL(TEST_DISCOVERY_URL, TEST_RESPONSE_URL, "foo bar", false));
+ }
+
+
+ @Test
+ public void testPassive() throws ComponentInitializationException {
+ final DDF input = new DDF(null).structure();
+ input.addmember(SPConstants.STATE).string("foo bar");
+ input.addmember(InitiatorConstants.DISCOVERY_RETURN_URL).string(escaper.escape("https://sp.example.org/handler?DS=1"));
+ input.addmember("prompt").string("none");
+ arc.setInput(input);
+
+ final Event event = action.execute(src);
+ ActionTestingSupport.assertProceedEvent(event);
+
+ final DDF output = arc.getOutput();
+ assert output != null;
+ final byte[] redirect = output.getmember(
+ RemotedHttpServletResponse.STRUCTURE_NAME + '.' +
+ RemotedHttpServletResponse.REDIRECT).unsafe_string();
+ Assert.assertEquals(redirect, buildDiscoveryURL(TEST_DISCOVERY_URL, TEST_RESPONSE_URL, "foo bar", true));
}
/**
@@ -161,16 +200,19 @@ public class IssueDiscoveryRequestTest extends BaseAgplicationActionTest {
* @return the final URL
*/
@Nonnull private byte[] buildDiscoveryURL(@Nonnull final String url, @Nonnull final String returnURL,
- @Nullable final String state) {
+ @Nullable final String state, boolean passive) {
final StringBuilder builder = new StringBuilder(url);
builder.append("?return=");
if (state != null) {
- builder.append(escaper.escape(returnURL) + escaper.escape("&state=" + state));
+ builder.append(escaper.escape(returnURL) + escaper.escape("&state=" + escaper.escape(state)));
} else {
builder.append(escaper.escape(returnURL));
}
builder.append("&entityID=").append(escaper.escape(TEST_ISSUER));
+ if (passive) {
+ builder.append("&isPassive=1");
+ }
return builder.toString().getBytes(StandardCharsets.UTF_8);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list