[java-idp-integration-tests] 05/10: Cleanup - rename OIDCTest to OPTest and extract abstract test class

Tom Zeller tzeller at dragonacea.biz
Wed Aug 28 22:38:33 UTC 2024


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

commit a6cc03efbb4be9330aed5896529b8d4227358ad8
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Tue Aug 27 23:44:20 2024 -0500

    Cleanup - rename OIDCTest to OPTest and extract abstract test class
---
 .../oidc/{OIDCTest.java => AbstractOPTest.java}    | 119 +---------------
 .../idp/integration/tests/oidc/OPTest.java         | 149 +++++++++++++++++++++
 2 files changed, 152 insertions(+), 116 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/integration/tests/oidc/OIDCTest.java b/src/test/java/net/shibboleth/idp/integration/tests/oidc/AbstractOPTest.java
similarity index 84%
rename from src/test/java/net/shibboleth/idp/integration/tests/oidc/OIDCTest.java
rename to src/test/java/net/shibboleth/idp/integration/tests/oidc/AbstractOPTest.java
index 8f6fb05..0d4f957 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/oidc/OIDCTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/oidc/AbstractOPTest.java
@@ -33,20 +33,18 @@ import org.slf4j.LoggerFactory;
 import org.testcontainers.containers.Container.ExecResult;
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
 
 import net.shibboleth.idp.integration.tests.BaseIntegrationTest;
 import net.shibboleth.shared.component.ComponentInitializationException;
 
 /**
- * Test the OIDC OP plugin for the IdP.
+ * Abstract OIDC OP integration test.
  */
-public class OIDCTest extends BaseIntegrationTest {
+public class AbstractOPTest extends BaseIntegrationTest {
 
     /** Class logger. */
     @Nonnull
-    private final Logger log = LoggerFactory.getLogger(OIDCTest.class);
+    private final Logger log = LoggerFactory.getLogger(AbstractOPTest.class);
 
     /** CLI to generate keys. */
     @Nullable
@@ -56,13 +54,6 @@ public class OIDCTest extends BaseIntegrationTest {
     @Nonnull
     protected final List<RPContainer> rps = new ArrayList<>();
 
-    @BeforeClass
-    protected void setUpURLs() throws Exception {
-
-        loginPageURLPath = "/idp/profile/oidc/authorize";
-
-    }
-
     /**
      * Enable OIDC credentials.
      * 
@@ -501,110 +492,6 @@ public class OIDCTest extends BaseIntegrationTest {
         Assert.assertTrue(response.contains(expectedIssuer), "Expected issuer not found");
     }
 
-    /**
-     * Test the IdP + OP plugin with 2 Docker OIDC RPs.
-     * 
-     * @throws Exception
-     *             if an error occurs
-     */
-    @Test
-    public void testSSO() throws Exception {
-
-        // Only run if IdP V5 or later on Linux
-        if (isWindows() || idpVersion.startsWith("4")) {
-            log.debug("Skipping OIDC test, only runs IdP V5 on Linux with Jetty");
-            return;
-        }
-
-        // Install OIDC OP plugin
-        final String[] plugins = new String[] { //
-                "net.shibboleth.oidc.common", //
-                "net.shibboleth.idp.plugin.oidc.config", //
-                "net.shibboleth.idp.plugin.oidc.op" };
-
-        installPlugins(plugins);
-
-        assertPluginsAreInstalled(plugins);
-
-        buildWAR();
-
-        enableOIDCCredentials();
-
-        enableOIDCAttributes();
-
-        createOIDCCredentials();
-
-        enableOIDCProfiles();
-
-        enableStaticClientRegistration();
-
-        copyStaticClientRegistrations();
-
-        enableOIDCDiscovery();
-
-        setUpIdPAttributes();
-
-        setUpOPIssuer();
-
-        // Start rp.tests.shibboleth.net
-
-        final RPContainer rp = startRP("rp", "test_oidc_rp");
-
-        updateClientMetadata("40443", rp.httpsPort.toString());
-        
-        updateClientMetadata("rp.tests.shibboleth.net", rp.rpHost);
-
-        // Start rp1.tests.shibboleth.net
-
-        final RPContainer rp1 = startRP("rp1", "test_oidc_rp_1");
-
-        updateClientMetadata("41443", rp1.httpsPort.toString());
-        
-        updateClientMetadata("rp1.tests.shibboleth.net", rp1.rpHost);
-
-        // Start IdP
-
-        startServer();
-
-        assertPluginsAreOnStatusPage(plugins);
-
-        startBrowser();
-
-        getOpenIDConfigurationFromBrowser();
-
-        getOpenIDConfigurationFromContainer(rp);
-
-        // Authenticate to rp.tests.shibboleth.net
-
-        driver.get(rp.getBaseURL() + "/cgi-bin/printenv");
-
-        waitForLoginPage();
-
-        login();
-
-        waitForPageURLContains("/cgi-bin/printenv");
-
-        Assert.assertTrue(getPageSource().contains("OIDC_CLAIM_iss=\"https://idp.tests.shibboleth.net\""));
-
-        Assert.assertTrue(getPageSource().contains("OIDC_CLAIM_sub=\"jdoe at example.org\""));
-
-        Assert.assertTrue(getPageSource().contains("SERVER_NAME=\"" + rp.rpHost + "\""));
-
-        // SSO to rp1.tests.shibboleth.net
-
-        driver.get(rp1.getBaseURL() + "/cgi-bin/printenv");
-
-        waitForPageURLContains("/cgi-bin/printenv");
-
-        Assert.assertTrue(getPageSource().contains("OIDC_CLAIM_iss=\"https://idp.tests.shibboleth.net\""));
-
-        Assert.assertTrue(getPageSource().contains("OIDC_CLAIM_sub=\"jdoe at example.org\""));
-
-        Assert.assertTrue(getPageSource().contains("SERVER_NAME=\"" + rp1.rpHost + "\""));
-
-        // TODO more asserts
-    }
-
     /**
      * Stop all RPs.
      */
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/oidc/OPTest.java b/src/test/java/net/shibboleth/idp/integration/tests/oidc/OPTest.java
new file mode 100644
index 0000000..6da61aa
--- /dev/null
+++ b/src/test/java/net/shibboleth/idp/integration/tests/oidc/OPTest.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development, 
+ * Inc. (UCAID) under one or more contributor license agreements.  See the 
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache 
+ * License, Version 2.0 (the "License"); you may not use this file except in 
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.integration.tests.oidc;
+
+import javax.annotation.Nonnull;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Test the OIDC OP plugin for the IdP.
+ */
+public class OPTest extends AbstractOPTest {
+
+    /** Class logger. */
+    @Nonnull
+    private final Logger log = LoggerFactory.getLogger(OPTest.class);
+
+    @BeforeClass
+    protected void setUpURLs() throws Exception {
+
+        loginPageURLPath = "/idp/profile/oidc/authorize";
+
+    }
+
+    /**
+     * Test the IdP + OP plugin with 2 Docker OIDC RPs.
+     * 
+     * @throws Exception
+     *             if an error occurs
+     */
+    @Test
+    public void testSSO() throws Exception {
+
+        // Only run if IdP V5 or later on Linux
+        if (isWindows() || idpVersion.startsWith("4")) {
+            log.debug("Skipping OIDC test, only runs IdP V5 on Linux with Jetty");
+            return;
+        }
+
+        // Install OIDC OP plugin
+        final String[] plugins = new String[] { //
+                "net.shibboleth.oidc.common", //
+                "net.shibboleth.idp.plugin.oidc.config", //
+                "net.shibboleth.idp.plugin.oidc.op" };
+
+        installPlugins(plugins);
+
+        assertPluginsAreInstalled(plugins);
+
+        buildWAR();
+
+        enableOIDCCredentials();
+
+        enableOIDCAttributes();
+
+        createOIDCCredentials();
+
+        enableOIDCProfiles();
+
+        enableStaticClientRegistration();
+
+        copyStaticClientRegistrations();
+
+        enableOIDCDiscovery();
+
+        setUpIdPAttributes();
+
+        setUpOPIssuer();
+
+        // Start rp.tests.shibboleth.net
+
+        final RPContainer rp = startRP("rp", "test_oidc_rp");
+
+        updateClientMetadata("40443", rp.httpsPort.toString());
+        
+        updateClientMetadata("rp.tests.shibboleth.net", rp.rpHost);
+
+        // Start rp1.tests.shibboleth.net
+
+        final RPContainer rp1 = startRP("rp1", "test_oidc_rp_1");
+
+        updateClientMetadata("41443", rp1.httpsPort.toString());
+        
+        updateClientMetadata("rp1.tests.shibboleth.net", rp1.rpHost);
+
+        // Start IdP
+
+        startServer();
+
+        assertPluginsAreOnStatusPage(plugins);
+
+        startBrowser();
+
+        getOpenIDConfigurationFromBrowser();
+
+        getOpenIDConfigurationFromContainer(rp);
+
+        // Authenticate to rp.tests.shibboleth.net
+
+        driver.get(rp.getBaseURL() + "/cgi-bin/printenv");
+
+        waitForLoginPage();
+
+        login();
+
+        waitForPageURLContains("/cgi-bin/printenv");
+
+        Assert.assertTrue(getPageSource().contains("OIDC_CLAIM_iss=\"https://idp.tests.shibboleth.net\""));
+
+        Assert.assertTrue(getPageSource().contains("OIDC_CLAIM_sub=\"jdoe at example.org\""));
+
+        Assert.assertTrue(getPageSource().contains("SERVER_NAME=\"" + rp.rpHost + "\""));
+
+        // SSO to rp1.tests.shibboleth.net
+
+        driver.get(rp1.getBaseURL() + "/cgi-bin/printenv");
+
+        waitForPageURLContains("/cgi-bin/printenv");
+
+        Assert.assertTrue(getPageSource().contains("OIDC_CLAIM_iss=\"https://idp.tests.shibboleth.net\""));
+
+        Assert.assertTrue(getPageSource().contains("OIDC_CLAIM_sub=\"jdoe at example.org\""));
+
+        Assert.assertTrue(getPageSource().contains("SERVER_NAME=\"" + rp1.rpHost + "\""));
+
+        // TODO more asserts
+    }
+
+}

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


More information about the commits mailing list