[java-idp-integration-tests] branch main updated: Reload attribute resolver before running test

Tom Zeller tzeller at dragonacea.biz
Wed Dec 27 22:13:03 UTC 2023


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

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

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-integration-tests.git;a=commit;h=79352eb74698394b1379ae802951edf1bb70f1c4

The following commit(s) were added to refs/heads/main by this push:
     new 79352eb  Reload attribute resolver before running test
79352eb is described below

commit 79352eb74698394b1379ae802951edf1bb70f1c4
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed Dec 27 16:10:26 2023 -0600

    Reload attribute resolver before running test
    
    Servlet containers (Tomcat, Jetty) may not specify the order in which
    webapps are loaded.
    
    The testbed LDAP server may not be available when the IdP is started.
    
    Wait for the testbed webapp to be available and then reload the
    attribute resolver.
    
    More of an issue with Tomcat than Jetty.
---
 .../idp/integration/tests/BaseIntegrationTest.java | 50 ++++++++++++++++++++--
 .../tests/saml2/AbstractSAML2IntegrationTest.java  | 11 +++++
 .../saml2/SAML2SSORedirectLDAPIntegrationTest.java | 11 +++++
 3 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java b/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
index 52af08e..9fda142 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
@@ -386,6 +386,9 @@ public abstract class BaseIntegrationTest {
     /** Tomcat version determined from distribution name. **/
     @Nullable protected String tomcatVersion;
 
+    /** Path to bin directory. */
+    @NonnullAfterInit protected Path pathToBin;
+
     /** Path to build.sh or build.bat. */
     @NonnullAfterInit protected Path pathToBuildCLI;
     
@@ -404,6 +407,12 @@ public abstract class BaseIntegrationTest {
     /** Plugin CLI, either plugin.sh or plugin.bat. **/
     @NonnullAfterInit protected String pluginCLI;
 
+    /** Path to reload-service.sh or reload-service.bat. */
+    @NonnullAfterInit protected Path pathToReloadServiceCLI;
+
+    /** Reload service CLI, either reload-service.sh or reload-service.bat. **/
+    @NonnullAfterInit protected String reloadServiceCLI;
+
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(BaseIntegrationTest.class);
 
@@ -461,18 +470,25 @@ public abstract class BaseIntegrationTest {
         // Run installer from idp distribution directory
         installIdP();
 
-        pathToBuildCLI = pathToIdPHome.resolve(Paths.get("bin", isWindows() ? "build.bat" : "build.sh"));
+        pathToBin = pathToIdPHome.resolve("bin");
+        Assert.assertTrue(pathToBin.toFile().exists());
+
+        pathToBuildCLI = pathToBin.resolve(isWindows() ? "build.bat" : "build.sh");
         Assert.assertTrue(pathToBuildCLI.toFile().exists());
         buildCLI = pathToBuildCLI.toAbsolutePath().toString();
 
-        pathToModuleCLI = pathToIdPHome.resolve(Paths.get("bin", isWindows() ? "module.bat" : "module.sh"));
+        pathToModuleCLI = pathToBin.resolve(isWindows() ? "module.bat" : "module.sh");
         Assert.assertTrue(pathToModuleCLI.toFile().exists());
         moduleCLI = pathToModuleCLI.toAbsolutePath().toString();
 
-        pathToPluginCLI = pathToIdPHome.resolve(Paths.get("bin", isWindows() ? "plugin.bat" : "plugin.sh"));
+        pathToPluginCLI = pathToBin.resolve(isWindows() ? "plugin.bat" : "plugin.sh");
         Assert.assertTrue(pathToPluginCLI.toFile().exists());
         pluginCLI = pathToPluginCLI.toAbsolutePath().toString();
 
+        pathToReloadServiceCLI = pathToBin.resolve(isWindows() ? "reload-service.bat" : "reload-service.sh");
+        Assert.assertTrue(pathToReloadServiceCLI.toFile().exists());
+        reloadServiceCLI = pathToReloadServiceCLI.toAbsolutePath().toString();
+
         // Copy directories from idp distribution to idp home
         copyFromIdPDistToIdPHome("metadata");
         copyFromIdPDistToIdPHome("credentials");
@@ -1879,6 +1895,7 @@ public abstract class BaseIntegrationTest {
      * Start the flow by accessing the URL composed of {@link #getBaseURL()} and {@link #startFlowURLPath}.
      */
     public void startFlow() {
+        log.debug("Start flow '{}", getBaseURL() + startFlowURLPath);
         driver.get(getBaseURL() + startFlowURLPath);
     }
 
@@ -2666,4 +2683,31 @@ public abstract class BaseIntegrationTest {
         logProcess(installerProcess, "install :");
     }
 
+    /**
+     * Reload IdP service.
+     * 
+     * Uses non-secure (HTTP) endpoint.
+     * 
+     * @param id
+     *            service bean ID
+     * @throws IOException
+     *             if an error occurs
+     */
+    public void reloadService(@Nonnull final String id) throws IOException {
+
+        final String[] commands = new String[] {
+                reloadServiceCLI,
+                "-id",
+                id,
+                "--url",
+                getBaseURL(false) + "/idp",
+                };
+
+        log.debug("Reloading service '{}' using command '{}'", id, commands);
+
+        final Process process = Runtime.getRuntime().exec(commands, null, idpHome);
+
+        logProcess(process, "reload-service :");
+    }
+
 }
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/saml2/AbstractSAML2IntegrationTest.java b/src/test/java/net/shibboleth/idp/integration/tests/saml2/AbstractSAML2IntegrationTest.java
index 382f8f5..5a4c0cf 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/saml2/AbstractSAML2IntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/saml2/AbstractSAML2IntegrationTest.java
@@ -28,6 +28,7 @@ import javax.annotation.Nullable;
 
 import net.shibboleth.idp.integration.tests.BaseIntegrationTest;
 import net.shibboleth.idp.integration.tests.BrowserData;
+import net.shibboleth.idp.integration.tests.StatusTest;
 import net.shibboleth.idp.test.flows.saml2.SAML2TestResponseValidator;
 import net.shibboleth.idp.test.flows.saml2.SAML2TestStatusResponseTypeValidator;
 import net.shibboleth.shared.net.IPRange;
@@ -808,6 +809,16 @@ public abstract class AbstractSAML2IntegrationTest extends BaseIntegrationTest {
 
         startServer();
 
+        // Wait for testbed webapp to load
+        getAndWaitForTestbedPage();
+
+        // Reload attribute resolver now that the testbed LDAP server is up
+        reloadService("shibboleth.AttributeResolverService");
+
+        // Get status page, informational
+        driver.get(getBaseURL() + StatusTest.statusPath);
+        Assert.assertTrue(getPageSource().startsWith(StatusTest.STARTS_WITH));
+
         startFlow();
 
         waitForLoginPage();
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/saml2/SAML2SSORedirectLDAPIntegrationTest.java b/src/test/java/net/shibboleth/idp/integration/tests/saml2/SAML2SSORedirectLDAPIntegrationTest.java
index 5331141..3e63f77 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/saml2/SAML2SSORedirectLDAPIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/saml2/SAML2SSORedirectLDAPIntegrationTest.java
@@ -32,6 +32,7 @@ import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import net.shibboleth.idp.integration.tests.BrowserData;
+import net.shibboleth.idp.integration.tests.StatusTest;
 
 /** SAML 2 HTTP Redirect binding test with attributes from LDAP. */
 public class SAML2SSORedirectLDAPIntegrationTest extends AbstractSAML2IntegrationTest {
@@ -95,6 +96,16 @@ public class SAML2SSORedirectLDAPIntegrationTest extends AbstractSAML2Integratio
 
         startServer();
 
+        // Wait for testbed webapp to load
+        getAndWaitForTestbedPage();
+
+        // Reload attribute resolver now that the testbed LDAP server is up
+        reloadService("shibboleth.AttributeResolverService");
+
+        // Get status page, informational
+        driver.get(getBaseURL() + StatusTest.statusPath);
+        Assert.assertTrue(getPageSource().startsWith(StatusTest.STARTS_WITH));
+
         startFlow();
 
         waitForLoginPage();

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


More information about the commits mailing list