[java-idp-integration-tests] 02/04: Enable WebAuthn Plugin test when not running headless

Tom Zeller tzeller at dragonacea.biz
Thu Sep 11 12:41:06 UTC 2025


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=eae029e5dfc70be046612fd539d9bc527d1c0c05

commit eae029e5dfc70be046612fd539d9bc527d1c0c05
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed Sep 10 19:57:31 2025 -0500

    Enable WebAuthn Plugin test when not running headless
---
 .../shibboleth/idp/integration/tests/BaseTest.java | 32 ++++++++
 .../tests/plugins/WebAuthnPluginTest.java          | 87 ++++------------------
 .../tests/util/testng/IgnoreTestIntercepter.java   | 28 +++++++
 .../tests/util/testng/annotation/NoHeadless.java   | 13 ++++
 4 files changed, 87 insertions(+), 73 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java b/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
index 6f4f06c..5f40df6 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
@@ -3650,4 +3650,36 @@ public abstract class BaseTest {
         }
     }
 
+    /**
+     * Whether browser is headless (the default).
+     * 
+     * Sauce Labs and Safari are not headless.
+     * 
+     * Firefox and Chrome are headless unless the no-headless system property is
+     * defined.
+     * 
+     * @return return true if browser is headless, false otherwise
+     */
+    public static boolean isHeadless() {
+
+        // Remote browsers on Sauce Labs are not headless
+        if (BaseTest.isRemote()) {
+            return false;
+        }
+
+        // Safari does not support headless
+        final String browser = System.getProperty("SELENIUM_BROWSER", System.getenv("SELENIUM_BROWSER"));
+        if ("safari".equalsIgnoreCase(browser)) {
+            return false;
+        }
+
+        // Headless is the default unless no-headless is defined
+        if (Boolean.getBoolean("no-headless")) {
+            return false;
+        }
+
+        // Headless is the default
+        return true;
+    }
+
 }
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/plugins/WebAuthnPluginTest.java b/src/test/java/net/shibboleth/idp/integration/tests/plugins/WebAuthnPluginTest.java
index 4ee5c7b..95a1646 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/plugins/WebAuthnPluginTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/plugins/WebAuthnPluginTest.java
@@ -39,59 +39,26 @@ import org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 
 import net.shibboleth.idp.integration.tests.saml2.AbstractSAML2IntegrationTest;
+import net.shibboleth.idp.integration.tests.util.testng.IgnoreTestIntercepter;
 import net.shibboleth.idp.integration.tests.util.testng.annotation.ChromeOnly;
+import net.shibboleth.idp.integration.tests.util.testng.annotation.NoHeadless;
 
 /**
  * Some tests for the WebAuthn plugin for the IdP.
  * 
  * https://shibboleth.atlassian.net/wiki/spaces/IDPPLUGINS/pages/3395321933/WebAuthnAuthnConfiguration
  */
+ at Listeners(value = IgnoreTestIntercepter.class)
 public class WebAuthnPluginTest extends AbstractSAML2IntegrationTest {
 
     /** Class logger. */
     @Nonnull
     private final Logger log = LoggerFactory.getLogger(WebAuthnPluginTest.class);
 
-    /**
-     * Download, cache, and install plugin dependencies to speed up tests during
-     * development.
-     * 
-     * @throws IOException
-     *             if an error occurs
-     */
-    protected void downloadAndInstallPluginDependencies() throws IOException {
-        try {
-            // "net.shibboleth.oidc.common"
-            download("https://shibboleth.net/downloads/identity-provider/plugins/oidc-common/3.1.1/",
-                    "oidc-common-dist-3.1.1.tar.gz");
-            download("https://shibboleth.net/downloads/identity-provider/plugins/oidc-common/3.1.1/",
-                    "oidc-common-dist-3.1.1.tar.gz.asc");
-            installLocalPlugin("net.shibboleth.oidc.common",
-                    pathToDownloadsDir.resolve("oidc-common-dist-3.1.1.tar.gz").toAbsolutePath().toString());
-
-            // "net.shibboleth.idp.plugin.nashorn"
-            download("https://shibboleth.net/downloads/identity-provider/plugins/duo-oidc/2.1.0/",
-                    "idp-plugin-duo-nimbus-dist-2.1.0.tar.gz");
-            download("https://shibboleth.net/downloads/identity-provider/plugins/duo-oidc/2.1.0/",
-                    "idp-plugin-duo-nimbus-dist-2.1.0.tar.gz.asc");
-            installLocalPlugin("net.shibboleth.idp.plugin.authn.duo.nimbus",
-                    pathToDownloadsDir.resolve("idp-plugin-duo-nimbus-dist-2.1.0.tar.gz").toAbsolutePath().toString());
-
-            // "net.shibboleth.idp.plugin.authn.duo.nimbus"
-            download("https://shibboleth.net/downloads/identity-provider/plugins/scripting/2.0.0/",
-                    "idp-plugin-nashorn-jdk-dist-2.0.0.tar.gz");
-            download("https://shibboleth.net/downloads/identity-provider/plugins/scripting/2.0.0/",
-                    "idp-plugin-nashorn-jdk-dist-2.0.0.tar.gz.asc");
-            installLocalPlugin("net.shibboleth.idp.plugin.nashorn",
-                    pathToDownloadsDir.resolve("idp-plugin-nashorn-jdk-dist-2.0.0.tar.gz").toAbsolutePath().toString());
-        } catch (final URISyntaxException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
     /**
      * Install the WebAuthn Plugin and dependencies.
      * 
@@ -101,43 +68,14 @@ public class WebAuthnPluginTest extends AbstractSAML2IntegrationTest {
     protected void installWebAuthnPlugin() throws IOException {
 
         final String[] plugins = new String[] { //
-                "net.shibboleth.oidc.common", //
-                "net.shibboleth.idp.plugin.authn.duo.nimbus", //
-                "net.shibboleth.idp.plugin.nashorn" };
-
-        // TODO Include WebAuthn Plugin after 1.0 is released
-        // "net.shibboleth.idp.plugin.authn.webauthn"
-        // installPlugins(plugins);
-        downloadAndInstallPluginDependencies();
-        installWebAuthnPluginPrelease();
+                "net.shibboleth.idp.plugin.nashorn", //
+                "net.shibboleth.idp.plugin.authn.webauthn", //
+        };
+        installPlugins(plugins);
 
         assertPluginsAreInstalled(plugins);
     }
 
-    /**
-     * Install WebAuthn Plugin prerelease.
-     * 
-     * @throws IOException
-     *             if an error occurs
-     */
-    protected void installWebAuthnPluginPrelease() throws IOException {
-        try {
-
-            final String plugin = "net.shibboleth.idp.plugin.authn.webauthn";
-
-            final String fileName = "idp-plugin-webauthn-0.0.3.tar.gz";
-
-            downloadPrerelease(fileName);
-
-            installLocalPluginPrerelease(plugin, fileName);
-
-            assertPluginsAreInstalled(plugin);
-
-        } catch (final URISyntaxException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
     /**
      * Enter credential nickname.
      * 
@@ -357,8 +295,9 @@ public class WebAuthnPluginTest extends AbstractSAML2IntegrationTest {
      * @throws Exception
      *             if an error occurs
      */
-    @Test(enabled = false)
+    @Test
     @ChromeOnly
+    @NoHeadless
     public void testSAML2SSO() throws Exception {
 
         setUpSAML2URLs();
@@ -380,7 +319,7 @@ public class WebAuthnPluginTest extends AbstractSAML2IntegrationTest {
 
         waitForLoginPage();
 
-        click(By.linkText("Enroll New Devices"));
+        click(By.linkText("Register a new credential"));
 
         waitForPageWithURL(getBaseURL() + "/idp/profile/admin/webauthn-registration");
 
@@ -388,6 +327,8 @@ public class WebAuthnPluginTest extends AbstractSAML2IntegrationTest {
 
         waitForPageWithURL(getBaseURL() + "/idp/profile/admin/webauthn-registration");
 
+        sleep(1000);
+
         login();
 
         click(By.id("registerButton"));
@@ -396,7 +337,7 @@ public class WebAuthnPluginTest extends AbstractSAML2IntegrationTest {
 
         click(By.id("finish_button"));
 
-        waitForPageBodyContains("Your registration session has ended");
+        sleep(1000);
 
         // login
 
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/util/testng/IgnoreTestIntercepter.java b/src/test/java/net/shibboleth/idp/integration/tests/util/testng/IgnoreTestIntercepter.java
index 8a49789..dbf9ebd 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/util/testng/IgnoreTestIntercepter.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/util/testng/IgnoreTestIntercepter.java
@@ -16,6 +16,7 @@ import net.shibboleth.idp.integration.tests.BaseTest;
 import net.shibboleth.idp.integration.tests.util.testng.annotation.ChromeOnly;
 import net.shibboleth.idp.integration.tests.util.testng.annotation.IdPV5OrLater;
 import net.shibboleth.idp.integration.tests.util.testng.annotation.LinuxOnly;
+import net.shibboleth.idp.integration.tests.util.testng.annotation.NoHeadless;
 import net.shibboleth.idp.integration.tests.util.testng.annotation.OPConformance;
 
 /**
@@ -49,6 +50,11 @@ public class IgnoreTestIntercepter implements IMethodInterceptor {
                 continue;
             }
 
+            if (!noHeadless(method)) {
+                log.debug("Skipping no-headless test '{}'", method);
+                continue;
+            }
+
             if (!opConformance(method)) {
                 log.debug("Skipping OP Conformance test '{}'", method);
                 continue;
@@ -129,6 +135,28 @@ public class IgnoreTestIntercepter implements IMethodInterceptor {
         return true;
     }
 
+    /**
+     * Return false if test is annotated as {@link NoHeadless} and test is headless.
+     * 
+     * @param method
+     *            the test method
+     * @return return false if test is annotated as NoHeadless and test is headless,
+     *         true otherwise.
+     */
+    public boolean noHeadless(final IMethodInstance method) {
+
+        final NoHeadless noHeadless = method.getMethod()
+                .getConstructorOrMethod()
+                .getMethod()
+                .getAnnotation(NoHeadless.class);
+
+        if (noHeadless != null && BaseTest.isHeadless()) {
+            return false;
+        }
+
+        return true;
+    }
+
     /**
      * Return false if test is annotated as {@link OPConformance} and
      * 'OPConformance' system property is not 'true'.
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/util/testng/annotation/NoHeadless.java b/src/test/java/net/shibboleth/idp/integration/tests/util/testng/annotation/NoHeadless.java
new file mode 100644
index 0000000..326e082
--- /dev/null
+++ b/src/test/java/net/shibboleth/idp/integration/tests/util/testng/annotation/NoHeadless.java
@@ -0,0 +1,13 @@
+
+package net.shibboleth.idp.integration.tests.util.testng.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+public @interface NoHeadless {
+
+}

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


More information about the commits mailing list