[java-idp-integration-tests] 05/05: Support testing CAS on Sauce Labs

Tom Zeller tzeller at dragonacea.biz
Wed Jun 9 18:54:13 UTC 2021


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

commit 7a3962cb4b6032b5619e9b9046beb6b28d1831bf
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed Jun 9 13:40:47 2021 -0500

    Support testing CAS on Sauce Labs
---
 .../shibboleth/idp/test/BaseIntegrationTest.java   | 62 ++++++++++++++++++----
 .../idp/test/cas/CASIntegrationTest.java           |  6 +--
 2 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
index 28de186..a98d2eb 100644
--- a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
@@ -1271,14 +1271,38 @@ public abstract class BaseIntegrationTest
      * 
      * @throws IOException ...
      */
-    public void enableLocalhostCASServiceDefinition() throws IOException {
+    public void enableCASServiceDefinition() throws IOException {
         final Path pathToCASProtocolXML = Paths.get("conf", "cas-protocol.xml");
 
         final String regex = "</list>";
-        final String replacement = "<bean class=\"net.shibboleth.idp.cas.service.ServiceDefinition\"\n"
-                + "c:regex=\"https?://localhost(:\\\\d+)?/.*\"\n" + "p:group=\"test-services\"\n"
-                + "p:authorizedToProxy=\"false\" />\n" + "</list>";
-        replaceIdPHomeFile(pathToCASProtocolXML, regex, replacement);
+
+        final String serviceDefintiion = 
+                  "<bean class=\"net.shibboleth.idp.cas.service.ServiceDefinition\"\n"
+                + "c:regex=\"https?://localhost(:\\\\d+)?/.*\"\n"
+                + "p:group=\"test-services\"\n"
+                + "p:authorizedToProxy=\"false\" />\n";
+
+        final StringBuilder replacement = new StringBuilder();
+
+        // localhost
+        replacement.append(serviceDefintiion);
+
+        // Add public server addresses if not localhost
+        final Set<String> addresses = new LinkedHashSet();
+        addresses.add(address);
+        addresses.add(secureAddress);
+        addresses.add(privateAddress);
+        addresses.add(privateSecureAddress);
+        for (final String addr : addresses) {
+            if (addr == "localhost") {
+                continue;
+            }
+            replacement.append(serviceDefintiion.replaceFirst("localhost", addr));
+        }
+
+        replacement.append(regex);
+
+        replaceIdPHomeFile(pathToCASProtocolXML, "[ \t]*" + regex, replacement.toString());
     }
 
     /**
@@ -1286,12 +1310,32 @@ public abstract class BaseIntegrationTest
      * 
      * @throws IOException ...
      */
-    public void enableLocalhostCASAttributes() throws IOException {
-        final Path pathToLogbackXML = Paths.get("conf", "attribute-filter.xml");
+    public void enableCASAttributes() throws IOException {
+        final Path pathToAttributeFilterXML = Paths.get("conf", "attribute-filter.xml");
 
         final String oldText = "<Rule xsi:type=\"Requester\" value=\"https://another.example.org/shibboleth\" />";
-        final String newText = "<Rule xsi:type=\"RequesterRegex\" regex=\"https?://localhost(:\\\\d+)?/.*\" />";
-        replaceIdPHomeFile(pathToLogbackXML, oldText, newText);
+        
+        final String requesterRegex = "<Rule xsi:type=\"RequesterRegex\" regex=\"https?://localhost(:\\\\d+)?/.*\" />\n";
+
+        final StringBuilder replacement = new StringBuilder();
+
+        // localhost
+        replacement.append(requesterRegex);
+
+        // Add public server addresses if not localhost
+        final Set<String> addresses = new LinkedHashSet();
+        addresses.add(address);
+        addresses.add(secureAddress);
+        addresses.add(privateAddress);
+        addresses.add(privateSecureAddress);
+        for (final String addr : addresses) {
+            if (addr == "localhost") {
+                continue;
+            }
+            replacement.append(requesterRegex.replaceFirst("localhost", addr));
+        }
+
+        replaceIdPHomeFile(pathToAttributeFilterXML, oldText, replacement.toString());
     }
 
     public void enableAttributeReleaseConsent() throws IOException {
diff --git a/src/test/java/net/shibboleth/idp/test/cas/CASIntegrationTest.java b/src/test/java/net/shibboleth/idp/test/cas/CASIntegrationTest.java
index 6e42cd8..5676cff 100644
--- a/src/test/java/net/shibboleth/idp/test/cas/CASIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/cas/CASIntegrationTest.java
@@ -107,7 +107,7 @@ public class CASIntegrationTest extends BaseIntegrationTest {
 
         enableCAS();
 
-        enableLocalhostCASServiceDefinition();
+        enableCASServiceDefinition();
 
         startServer();
 
@@ -137,9 +137,9 @@ public class CASIntegrationTest extends BaseIntegrationTest {
 
         enableCAS();
 
-        enableLocalhostCASServiceDefinition();
+        enableCASServiceDefinition();
 
-        enableLocalhostCASAttributes();
+        enableCASAttributes();
 
         startServer();
 

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


More information about the commits mailing list