[java-idp-integration-tests] 03/03: Fix passive consent test port updates

Codeberg noreply at shibboleth.net
Wed Nov 19 23:06:46 UTC 2025


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-idp-integration-tests.

View the commit online:
https://codeberg.org/Shibboleth/java-idp-integration-tests/commit/68e2f70bfb1d52e2e9838a6acf6b42d3ed035180

commit 68e2f70bfb1d52e2e9838a6acf6b42d3ed035180
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Tue Nov 18 21:54:41 2025 -0600

    Fix passive consent test port updates
    
    And some cleanup
---
 .../tests/consent/PassiveConsentTest.java          | 190 +++++++++++----------
 1 file changed, 102 insertions(+), 88 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/integration/tests/consent/PassiveConsentTest.java b/src/test/java/net/shibboleth/idp/integration/tests/consent/PassiveConsentTest.java
index 00e33b0..dca2022 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/consent/PassiveConsentTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/consent/PassiveConsentTest.java
@@ -28,10 +28,11 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
+import com.google.common.net.UrlEscapers;
+
 import net.shibboleth.idp.integration.tests.saml2.AbstractSAML2IntegrationTest;
 import net.shibboleth.idp.integration.tests.util.testng.annotation.LinuxOnly;
 import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.net.URISupport;
 
 /**
  * Test consent with isPassive=true and allow global consent both true and false.
@@ -45,89 +46,13 @@ public class PassiveConsentTest extends AbstractSAML2IntegrationTest {
     @Nonnull protected final List<SPContainer> sps = new ArrayList<>();
 
     @BeforeClass
-    public void setUpURLs() throws Exception {
+    protected void setUpURLs() throws Exception {
 
         loginPageURLPath = "/idp/profile/SAML2/Redirect/SSO";
 
         responsePageURLPath = "/sp/SAML2/POST/ACS";
     }
 
-    @Test
-    @LinuxOnly
-    /**
-     * Test consent with isPassive=true and global consent allowed (the default).
-     * 
-     * @throws Exception
-     *             if an error occurs
-     */
-    public void testIdP2409() throws Exception {
-
-        // Start SP
-
-        final SPContainer sp = startSP("shib-test-sp");
-
-        // Set up SP metadata with runtime port
-
-        setUpSPMetadata(sp.httpsPort);
-
-        // Start browser
-
-        startBrowser();
-
-        // Start IdP
-
-        startServer();
-
-        // Start flow at SP
-
-        final String target = sp.getBaseURL() + "/cgi-bin/printenv";
-
-        final String startFlowURL = sp.getBaseURL() + "/Shibboleth.sso/Login?target=" + URISupport.doURLEncode(target);
-
-        driver.get(startFlowURL);
-
-        // login
-
-        waitForLoginPage();
-
-        login();
-
-        // attribute release
-
-        waitForAttributeReleasePage();
-
-        // start flow again with isPassive=true
-
-        sleep(1000);
-
-        driver.get(startFlowURL + "&isPassive=true");
-
-        sleep(1000);
-
-        // should see NoPassive error
-
-        waitForPageBodyContains("Status: urn:oasis:names:tc:SAML:2.0:status:Requester");
-        waitForPageBodyContains("Sub-Status: urn:oasis:names:tc:SAML:2.0:status:NoPassive");
-        waitForPageBodyContains("Message: An error occurred");
-    }
-
-    @Test(enabled = false)
-    @LinuxOnly
-    /**
-     * Test consent with isPassive=true and global consent not allowed.
-     * 
-     * @throws Exception
-     *             if an error occurs
-     */
-    public void testIdP2409AllowGlobalFalse() throws Exception {
-
-        // Do not allow global consent
-
-        replaceIdPProperty("idp.consent.allowGlobal", "false");
-
-        testIdP2409();
-    }
-
     /**
      * Set up metadata about/for the SP.
      * 
@@ -140,8 +65,8 @@ public class PassiveConsentTest extends AbstractSAML2IntegrationTest {
      * @throws Exception
      *             if an error occurs
      */
-
-    public void setUpSPMetadata(@Nonnull final Integer port) throws Exception {
+    @BeforeClass
+    protected void setUpSPMetadata() throws Exception {
 
         // Copy SP metadata to idp.home
 
@@ -155,12 +80,6 @@ public class PassiveConsentTest extends AbstractSAML2IntegrationTest {
 
         Files.copy(pathToImageSPMetadata, pathToSPMetadata);
 
-        // Update port in SP metadata
-
-        replaceIdPHomeFile(pathToSPMetadata, //
-                "Location=\"https://sp.tests.shibboleth.net/",
-                "Location=\"https://sp.tests.shibboleth.net:" + port + "/");
-
         // Enable SP metadata
 
         final Path pathToMetadataProvidersXML = Paths.get("conf", "metadata-providers.xml");
@@ -179,7 +98,7 @@ public class PassiveConsentTest extends AbstractSAML2IntegrationTest {
      * @param sp
      *            the SP container
      */
-    protected void setUpSKeyStore(final SPContainer sp) {
+    protected void setUpSPKeyStore(final SPContainer sp) {
 
         final Path pathToContainerBase = pathToJettyBase != null ? pathToJettyBase : pathToTomcatBase;
 
@@ -190,6 +109,23 @@ public class PassiveConsentTest extends AbstractSAML2IntegrationTest {
         sp.setKeyStore(pathToKeyStore.toAbsolutePath().toString());
     }
 
+    /**
+     * Update port in SP metadata.
+     * 
+     * @param port
+     *            the SP port
+     * @throws Exception
+     *             if an error occurs
+     */
+    protected void updateSPMetadata(@Nonnull final Integer port) throws Exception {
+
+        final Path pathToSPMetadata = pathToIdPHome.toAbsolutePath().resolve("metadata").resolve("sp-metadata.xml");
+
+        replaceIdPHomeFile(pathToSPMetadata, //
+                "Location=\"https://sp.tests.shibboleth.net(:\\d+)?/",
+                "Location=\"https://sp.tests.shibboleth.net:" + port + "/");
+    }
+
     /**
      * Start SP.
      * 
@@ -209,7 +145,7 @@ public class PassiveConsentTest extends AbstractSAML2IntegrationTest {
 
         sp.setIdPMetadata(pathToIdPHome.resolve(Paths.get("metadata", "idp-metadata.xml")));
 
-        setUpSKeyStore(sp);
+        setUpSPKeyStore(sp);
 
         sp.initialize();
 
@@ -229,4 +165,82 @@ public class PassiveConsentTest extends AbstractSAML2IntegrationTest {
             }
         }
     }
+
+    @Test
+    @LinuxOnly
+    /**
+     * Test consent with isPassive=true and global consent allowed (the default).
+     * 
+     * @throws Exception
+     *             if an error occurs
+     */
+    public void testIdP2409() throws Exception {
+
+        // Start SP
+
+        final SPContainer sp = startSP("shib-test-sp");
+
+        // Update SP metadata with runtime port
+
+        updateSPMetadata(sp.httpsPort);
+
+        // Start browser
+
+        startBrowser();
+
+        // Start IdP
+
+        startServer();
+
+        // Start flow at SP
+
+        final String target = sp.getBaseURL() + "/cgi-bin/printenv";
+
+        final String startFlowURL = sp.getBaseURL() + "/Shibboleth.sso/Login?target="
+                + UrlEscapers.urlFormParameterEscaper().escape(target);
+
+        driver.get(startFlowURL);
+
+        // login
+
+        waitForLoginPage();
+
+        login();
+
+        // attribute release
+
+        waitForAttributeReleasePage();
+
+        // start flow again with isPassive=true
+
+        sleep(1000);
+
+        driver.get(startFlowURL + "&isPassive=true");
+
+        sleep(1000);
+
+        // should see NoPassive error
+
+        waitForPageBodyContains("Status: urn:oasis:names:tc:SAML:2.0:status:Requester");
+        waitForPageBodyContains("Sub-Status: urn:oasis:names:tc:SAML:2.0:status:NoPassive");
+        waitForPageBodyContains("Message: An error occurred");
+    }
+
+    @Test(enabled = false)
+    @LinuxOnly
+    /**
+     * Test consent with isPassive=true and global consent not allowed.
+     * 
+     * @throws Exception
+     *             if an error occurs
+     */
+    public void testIdP2409AllowGlobalFalse() throws Exception {
+
+        // Do not allow global consent
+
+        replaceIdPProperty("idp.consent.allowGlobal", "false");
+
+        testIdP2409();
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list