[java-idp-integration-tests] 01/02: Run tests using Jetty 10

Tom Zeller tzeller at dragonacea.biz
Wed May 25 17:49:06 UTC 2022


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=5656c92275215a5490f8e1fd61baa44b94f7a2a4

commit 5656c92275215a5490f8e1fd61baa44b94f7a2a4
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed May 25 10:20:00 2022 -0500

    Run tests using Jetty 10
---
 pom.xml                                            | 44 +++++++++++++++++-----
 .../idp/integration/tests/BaseIntegrationTest.java | 41 +++++++++++---------
 src/test/jetty-base/etc/testbed.xml                | 28 ++++++++++++++
 3 files changed, 85 insertions(+), 28 deletions(-)

diff --git a/pom.xml b/pom.xml
index 09dfd4d..451246e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,10 +25,10 @@
         <idp-to-be-tested.version>${idp.version}</idp-to-be-tested.version>
 
         <!-- Version of Jetty Base to be tested -->
-        <idp-jetty-base.version>9.4.1-SNAPSHOT</idp-jetty-base.version>
+        <idp-jetty-base.version>10.0.0-SNAPSHOT</idp-jetty-base.version>
 
         <!-- Default version of Jetty to be tested -->
-        <jetty.version>9.4.46.v20220331</jetty.version>
+        <jetty.version>10.0.9</jetty.version>
 
         <!-- Tomcat -->
         <idp-tomcat-base.version>9.0.0-SNAPSHOT</idp-tomcat-base.version>
@@ -247,6 +247,7 @@
                                     <type>test-jar</type>
                                     <classifier>tests</classifier>
                                     <includes>**/credentials/*</includes>
+                                    <excludes>**/credentials/idp-userfacing.p12</excludes>
                                 </artifactItem>
                             </artifactItems>
                             <outputDirectory>${idp-to-be-tested.directory}</outputDirectory>
@@ -454,12 +455,12 @@
                                             <type>tar.gz</type>
                                         </artifactItem>
                                     </artifactItems>
-                                    <outputDirectory>${idp-to-be-tested.directory}</outputDirectory>
+                                    <outputDirectory>${test-distributions.directory}</outputDirectory>
                                 </configuration>
                             </execution>
-                            <!-- Copy testbed deployment descriptor from testbed jar to Jetty. -->
+                            <!-- Copy credentials to jetty-base. -->
                             <execution>
-                                <id>copy-testbed-deployment-descriptor-jetty</id>
+                                <id>copy-idp-userfacing.p12</id>
                                 <phase>compile</phase>
                                 <goals>
                                     <goal>unpack</goal>
@@ -468,18 +469,41 @@
                                     <artifactItems>
                                         <artifactItem>
                                             <groupId>net.shibboleth.idp</groupId>
-                                            <artifactId>idp-testbed</artifactId>
-                                            <version>${testbed.version}</version>
+                                            <artifactId>idp-conf</artifactId>
+                                            <version>${idp-to-be-tested.version}</version>
                                             <type>jar</type>
-                                            <classifier>${testbed.classifier}</classifier>
-                                            <includes>etc/testbed.xml</includes>
+                                            <classifier>tests</classifier>
+                                            <includes>credentials/idp-userfacing.p12,credentials/idp-backchannel.p12</includes>
                                         </artifactItem>
                                     </artifactItems>
-                                    <outputDirectory>${idp-to-be-tested.directory}/jetty-base/</outputDirectory>
+                                    <outputDirectory>${test-distributions.directory}/jetty-base/</outputDirectory>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                    <plugin>
+                        <artifactId>maven-resources-plugin</artifactId>
+                        <executions>
+                            <!-- Copy testbed deployment descriptor. -->
+                            <execution>
+                                <id>copy-resources</id>
+                                <phase>compile</phase>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <configuration>
+                                    <outputDirectory>${test-distributions.directory}/jetty-base/</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>src/test/jetty-base/</directory>
+                                        </resource>
+                                    </resources>
                                 </configuration>
                             </execution>
                         </executions>
                     </plugin>
+
                 </plugins>
             </build>
         </profile>
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 2615da1..f44ad6f 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
@@ -306,6 +306,9 @@ public abstract class BaseIntegrationTest
     /** Path to conf/ldap.properties. */
     @NonnullAfterInit protected Path pathToLDAPProperties;
     
+    /** Path to directory containing idp.home and jetty-base for each test. */
+    @NonnullAfterInit protected Path pathToPerTestDirectory;
+
     /** Resource to messages.properties.*/
     @NonnullAfterInit protected Resource messagesPropertiesResource;
 
@@ -424,13 +427,15 @@ public abstract class BaseIntegrationTest
         // Path to per-test idp.home
         final String timestamp = DateTimeFormatter.ofPattern(idpHomePattern).format(LocalDateTime.now());
         final String perTestDirectoryName = String.join("-", timestamp, getClass().getSimpleName());
-        log.debug("Per-test idp.home directory name '{}'", perTestDirectoryName);
-        pathToIdPHome = pathToIdPDist.getParent().resolve(perTestDirectoryName);
+        log.debug("Per-test directory name '{}'", perTestDirectoryName);
+        pathToPerTestDirectory = buildPath.resolve(perTestDirectoryName); 
+        log.debug("Per-test directory '{}'", pathToPerTestDirectory);
+        pathToIdPHome = pathToPerTestDirectory.resolve("shibboleth-idp");
         log.debug("Path to idp.home '{}'", pathToIdPHome.toAbsolutePath());
         final File idpHome = pathToIdPHome.toAbsolutePath().toFile();
         Assert.assertFalse(idpHome.exists(), "Path to idp.home already exists");
         // Create empty idp.home directory
-        Files.createDirectory(pathToIdPHome.toAbsolutePath());
+        Files.createDirectories(pathToIdPHome.toAbsolutePath());
         Assert.assertTrue(idpHome.exists(), "Path to idp.home not found");
 
         // Run installer from idp distribution directory
@@ -633,18 +638,23 @@ public abstract class BaseIntegrationTest
             }
 
             // Path to jetty.base
-            pathToJettyBase = pathToIdPHome.resolve(Paths.get("jetty-base"));
+            pathToJettyBase = pathToIdPHome.getParent().resolve(Paths.get("jetty-base"));
             log.debug("Path to jetty.base '{}'", pathToJettyBase.toAbsolutePath());
 
             // Copy jetty-base
-            copyFromIdPDistToIdPHome("jetty-base");
+            final Path pathToJettyBaseDist = buildPath.resolve("jetty-base");
+            FileSystemUtils.copyRecursively(pathToJettyBaseDist, pathToJettyBase);
             Assert.assertNotNull(pathToJettyBase, "Path to jetty.base not found");
             Assert.assertTrue(pathToJettyBase.toAbsolutePath().toFile().exists(), "Path to jetty.base not found");
 
             // Make tmp directories exist
             Assert.assertTrue(pathToJettyBase.resolve("tmp").toFile().exists(), "Path to jetty.base/tmp/ not found");
             
+            // set idp.home system property
             serverCommands.add(0, "-Didp.home=" + System.getProperty("idp.home"));
+            // set idp.war.path system property to webapp directory
+            serverCommands.add("-Didp.war.path=" + pathToIdPHome.resolve("webapp").toAbsolutePath());
+            // set tmp directory system property
             serverCommands.add("-Djava.io.tmpdir=" + pathToJettyBase.resolve("tmp").toAbsolutePath());
         } else {
             Assert.fail("Unable to find jetty.home");
@@ -712,11 +722,6 @@ public abstract class BaseIntegrationTest
         } else {
             Assert.fail("Unable to find start.ini or idp.ini");
         }
-
-        // Jetty 9.4 point IdP webapp to /webapp rather than /war/idp.war
-        final Path pathToIdpXML = pathToJettyBase.resolve(Paths.get("webapps", "idp.xml"));
-        Assert.assertTrue(pathToIdpXML.toAbsolutePath().toFile().exists(), "Path to idp.xml not found");
-        replaceFile(pathToIdpXML, "/war/idp.war", "/webapp/");
     }
  
     /**
@@ -907,12 +912,12 @@ public abstract class BaseIntegrationTest
      */
     public void setUpNonSecurePort() throws IOException {
         // Add http module to Jetty
-        final Path pathToIdPMod = Paths.get("jetty-base", "modules", "idp.mod");
-        replaceIdPHomeFile(pathToIdPMod, "https", "http\nhttps");
+        final Path pathToIdPMod = pathToJettyBase.resolve(Paths.get("modules", "idp.mod"));
+        replaceFile(pathToIdPMod, "https", "http\nhttps");
 
         // Set HTTP port used by Jetty
-        final Path pathToIdpIni = Paths.get("jetty-base", "start.d", "idp.ini");
-        replaceIdPHomeFile(pathToIdpIni, "\\z", System.lineSeparator() + "jetty.http.port=" + port);
+        final Path pathToIdpIni = pathToJettyBase.resolve(Paths.get("start.d", "idp.ini"));
+        replaceFile(pathToIdpIni, "\\z", System.lineSeparator() + "jetty.http.port=" + port);
 
         // Set secure container session cookie to false
         final Path pathToIdPWebXML = Paths.get("webapp", "WEB-INF", "web.xml");
@@ -1015,7 +1020,7 @@ public abstract class BaseIntegrationTest
             return;
         }
 
-        final Path pathToIdPXML = pathToIdPHome.resolve(Paths.get("jetty-base", "webapps", "idp.xml"));
+        final Path pathToIdPXML = pathToJettyBase.resolve(Paths.get("webapps", "idp.xml"));
         Assert.assertTrue(pathToIdPXML.toAbsolutePath().toFile().exists(), "Path to idp.xml not found");
 
         final String oldText = "</Configure>";
@@ -1866,10 +1871,10 @@ public abstract class BaseIntegrationTest
     public void deletePerTestIdPHomeDirectory() {
         if (testClassFailed) {
             log.debug("There was a test class failure, not deleting per-test idp.home directory '{}'",
-                    pathToIdPHome.toAbsolutePath());
+                    pathToPerTestDirectory.toAbsolutePath());
         } else if (!Boolean.getBoolean("keepTests")) {
-            log.debug("Deleting per-test idp.home directory '{}'", pathToIdPHome.toAbsolutePath());
-            FileSystemUtils.deleteRecursively(pathToIdPHome.toAbsolutePath().toFile());
+            log.debug("Deleting per-test idp.home directory '{}'", pathToPerTestDirectory.toAbsolutePath());
+            FileSystemUtils.deleteRecursively(pathToPerTestDirectory.toAbsolutePath().toFile());
         }
     }
 
diff --git a/src/test/jetty-base/etc/testbed.xml b/src/test/jetty-base/etc/testbed.xml
new file mode 100644
index 0000000..4a2b6d6
--- /dev/null
+++ b/src/test/jetty-base/etc/testbed.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
+
+<!-- =============================================================== -->
+<!-- Configure the Shibboleth Testbed webapp                             -->
+<!-- =============================================================== -->
+<Configure id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
+  <Call name="addHandler">
+    <Arg>
+      <New class="org.eclipse.jetty.webapp.WebAppContext">
+        <Set name="war">../shibboleth-idp/testbed-war/idp-testbed.war</Set>
+        <Set name="contextPath">/</Set>
+        <Set name="extractWAR">false</Set>
+        <Set name="copyWebDir">false</Set>
+        <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=375504 -->
+        <Set name="copyWebInf">true</Set>
+        <Call name="setAttribute">
+          <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
+          <Arg>none</Arg>
+        </Call>
+        <Call name="setAttribute">
+          <Arg>org.eclipse.jetty.webapp.basetempdir</Arg>
+          <Arg><Property name="jetty.base" />/tmp</Arg>
+        </Call>
+      </New>
+    </Arg>
+  </Call>
+</Configure>
\ No newline at end of file

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


More information about the commits mailing list