[java-idp-integration-tests] branch main updated: Use environment variables instead of system properties for OIDC tests

Tom Zeller tzeller at dragonacea.biz
Wed Jun 19 22:40:17 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=9f4af843d77d481085ea58d1f3c53e0541403c2c

The following commit(s) were added to refs/heads/main by this push:
     new 9f4af84  Use environment variables instead of system properties for OIDC tests
9f4af84 is described below

commit 9f4af843d77d481085ea58d1f3c53e0541403c2c
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed Jun 19 16:57:35 2024 -0500

    Use environment variables instead of system properties for OIDC tests
    
    So Jenkins can inject secrets.
---
 pom.xml                                            | 15 ++++----
 .../idp/integration/tests/oidc/RPContainer.java    | 42 +++++++++++++---------
 2 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/pom.xml b/pom.xml
index fa72146..ea81dd6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -460,19 +460,20 @@
                                     <goal>run</goal>
                                 </goals>
                                 <configuration>
-                                    <!-- Run only if DNS system property is true -->
-                                    <target if="tests_cert">
-                                        <!-- Copy pfx file -->
+                                    <!-- Run only if environment variable is "true" -->
+                                    <target if="${env.shib_tests_p12}">
+                                        <!-- Copy p12 file -->
                                         <copy
-                                            file="${env.tests_pfx_filepath}"
+                                            file="${env.shib_tests_op_tls_p12}"
                                             tofile="${test-distributions.directory}/jetty-base/credentials/idp-userfacing.p12"
                                             failonerror="true"
-                                            overwrite="true"/>
-                                        <!-- Replace pfx password -->
+                                            overwrite="true"
+                                            preservelastmodified="true" />
+                                        <!-- Replace p12 password -->
                                         <replace
                                             file="${test-distributions.directory}/jetty-base/start.d/idp.ini"
                                             token="changeit"
-                                            value="${env.tests_pfx_pwd}"
+                                            value="${env.shib_tests_op_tls_pwd}"
                                             summary="true" />
                                     </target>
                                 </configuration>
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/oidc/RPContainer.java b/src/test/java/net/shibboleth/idp/integration/tests/oidc/RPContainer.java
index f79182d..0f88b06 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/oidc/RPContainer.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/oidc/RPContainer.java
@@ -45,8 +45,8 @@ import net.shibboleth.shared.logic.Constraint;
  * Default ServerName is rp.tests.shibboleth.net, may be overridden as system
  * property.
  * 
- * TLS cert and key should be copied to etc/pki/tls/, or path overridden as a
- * system property.
+ * TLS cert and key should be copied to etc/pki/tls/ or path overridden as
+ * environment variables.
  * 
  * See src/test/docker/shib-tests-rp for Dockerfile and container files.
  */
@@ -89,11 +89,11 @@ public class RPContainer extends AbstractIdentifiableInitializableComponent impl
     /** RP redirect URI, defaults to '/redirect_uri'. */
     private String redirectURI = "/redirect_uri";
 
-    /** System property to set path to TLS cert. */
-    final static String pathToTLSCertSystemProperty = "tlsCert";
-
-    /** System property to set path to TLS key. */
-    final static String pathToTLSKeySystemProperty = "tlsKey";
+    /** Environment variable path to TLS cert. */
+    final static String pathToTLSCertEnvVar = "shib_tests_rp_tls_crt";
+    
+    /** Environment variable path to TLS key. */
+    final static String pathToTLSKeyEnvVar = "shib_tests_rp_tls_key";
 
     /**
      * Path to RP directory.
@@ -136,8 +136,8 @@ public class RPContainer extends AbstractIdentifiableInitializableComponent impl
     /**
      * Path to TLS cert.
      * 
-     * Default path may be overridden using the {@link #pathToTLSCertSystemProperty}
-     * system property.
+     * Default path may be overridden using the {@link #pathToTLSCertEnvVar}
+     * environment variable.
      * 
      * @return path to TLS cert
      */
@@ -145,18 +145,24 @@ public class RPContainer extends AbstractIdentifiableInitializableComponent impl
 
         final String defaultPathToCert = pathToRP().toString() + "/etc/pki/tls/certs/fullchain.cer";
 
-        final Path pathToCert = Paths.get(System.getProperty(pathToTLSCertSystemProperty, defaultPathToCert));
+        final String envVarPathToCert = System.getenv(pathToTLSCertEnvVar);
+
+        final String pathToCert = envVarPathToCert != null ? envVarPathToCert : defaultPathToCert;
+
+        final Path path = Paths.get(pathToCert);
 
         log.debug("{} Path to cert '{}'", getLogPrefix(), pathToCert);
 
-        return pathToCert;
+        assert path.toFile().exists() : "Path to TLS cert " + path + " does not exist";
+
+        return path;
     }
 
     /**
      * Path to TLS key.
      * 
-     * Default path may be overridden using the {@link #pathToTLSKeySystemProperty}
-     * system property.
+     * Default path may be overridden using the {@link #pathToTLSKeyEnvVar}
+     * environment variable.
      * 
      * @return path to TLS key
      */
@@ -164,13 +170,17 @@ public class RPContainer extends AbstractIdentifiableInitializableComponent impl
 
         final String defaultPathToKey = pathToRP().toString() + "/etc/pki/tls/private/tests.shibboleth.net.key";
 
-        final Path pathToKey = Paths.get(System.getProperty(pathToTLSKeySystemProperty, defaultPathToKey));
+        final String envVarPathToKey = System.getenv(pathToTLSKeyEnvVar);
+
+        final String pathToKey = envVarPathToKey != null ? envVarPathToKey : defaultPathToKey;
+
+        final Path path = Paths.get(pathToKey);
 
         log.debug("{} Path to key '{}'", getLogPrefix(), pathToKey);
 
-        assert pathToKey.toFile().exists() : "Path to key does not exist";
+        assert path.toFile().exists() : "Path to TLS key " + path + " does not exist";
 
-        return pathToKey;
+        return path;
     }
 
     /**

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


More information about the commits mailing list