[java-idp-integration-tests] branch main updated: Add test installing JDBC Plugin snapshot

Tom Zeller tzeller at dragonacea.biz
Wed Oct 2 02:15:58 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=e91aacdf10e40fe28a8a403c2d54f8175bbf6e06

The following commit(s) were added to refs/heads/main by this push:
     new e91aacd  Add test installing JDBC Plugin snapshot
e91aacd is described below

commit e91aacdf10e40fe28a8a403c2d54f8175bbf6e06
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Tue Oct 1 21:15:43 2024 -0500

    Add test installing JDBC Plugin snapshot
---
 .../shibboleth/idp/integration/tests/BaseTest.java | 120 +++++++++++++++---
 .../plugins/JDBCStorageServicePluginTest.java      |  25 +++-
 .../tests/util/PluginSnapshotSupport.java          | 134 +++++++++++++++++++++
 .../tests/truststores/SHIBBOLETH_SNAPSHOT_PGP_KEYS |  67 +++++++++++
 4 files changed, 325 insertions(+), 21 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 83886a9..5958d26 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/BaseTest.java
@@ -26,6 +26,7 @@ import java.lang.ProcessBuilder.Redirect;
 import java.lang.reflect.Method;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
 import java.net.Socket;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -109,6 +110,7 @@ import org.testng.annotations.BeforeSuite;
 import org.testng.annotations.Listeners;
 
 import net.shibboleth.idp.installer.PropertiesWithComments;
+import net.shibboleth.idp.integration.tests.util.PluginSnapshotSupport;
 import net.shibboleth.idp.integration.tests.util.Route53Helper;
 import net.shibboleth.idp.integration.tests.util.server.AbstractServer;
 import net.shibboleth.idp.integration.tests.util.server.JettyServer;
@@ -3289,7 +3291,9 @@ public abstract class BaseTest {
             Files.createDirectory(pathToDownloadsDir);
         }
 
-        final String urlToDownload = baseUrl + fileName;
+        final String trailingSlashUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
+
+        final String urlToDownload = trailingSlashUrl + fileName;
 
         log.debug("Downloading '{}' to '{}'", urlToDownload, pathToDownloadedFile);
 
@@ -3312,27 +3316,28 @@ public abstract class BaseTest {
     }
 
     /**
-     * Install local plugin prerelease.
+     * Install local plugin.
      * 
-     * The truststore must exist in the {@link pathToTruststores} directory.
-     * 
-     * @param plugin
+     * @param pluginId
      *            the plugin ID
      * @param fileName
      *            the name of the downloaded plugin in the downloads directory
+     * @param pathToTruststore
+     *            path to truststore for plugin
+     * 
      * @throws IOException
      *             if an error occurs
      */
-    public void installLocalPluginPrerelease(@Nonnull final String plugin, @Nonnull final String fileName)
-            throws IOException {
+    public void installLocalPlugin(//
+            @Nonnull final String pluginId, //
+            @Nonnull final String fileName, //
+            @Nonnull final Path pathToTruststore) {
 
-        log.debug("Install local plugin prerelease '{}'", fileName);
+        log.debug("Install local plugin '{}' file '{}' with truststore '{}'", pluginId, fileName, pathToTruststore);
 
         final Path pathToPlugin = pathToDownloadsDir.resolve(fileName);
-        assert pathToPlugin.toAbsolutePath().toFile().exists() : "Path to plugin not found " + pathToPlugin;
 
-        final Path pathToTruststore = pathToTruststores.resolve(plugin).resolve("truststore.asc");
-        assert pathToTruststore.toAbsolutePath().toFile().exists() : "Path to truststore not found " + pathToTruststore;
+        assert pathToPlugin.toAbsolutePath().toFile().exists() : "Path to plugin not found " + pathToPlugin;
 
         final String[] commands = new String[] { //
                 pluginCLI, //
@@ -3342,15 +3347,94 @@ public abstract class BaseTest {
                 "--input ", pathToPlugin.toAbsolutePath().toString(), //
                 "--truststore ", pathToTruststore.toString() };
 
-        log.debug("Install local plugin prerelease with command '{}'", String.join("", commands));
+        log.debug("Install local plugin command '{}'", String.join("", commands));
 
-        final Process process = new ProcessBuilder() //
-                .command(commands)
-                .directory(idpHome)
-                .redirectErrorStream(true)
-                .start();
+        try {
+            Process process = new ProcessBuilder() //
+                    .command(commands)
+                    .directory(idpHome)
+                    .redirectErrorStream(true)
+                    .start();
+            logProcess(process, "Install local plugin :");
+        } catch (final IOException e) {
+            log.error("Unable to install local plugin : {}", e.getMessage());
+            throw new RuntimeException(e);
+        }
+    }
 
-        logProcess(process, "Install local plugin :");
+    /**
+     * Install local plugin prerelease.
+     * 
+     * The truststore must exist in the {@link pathToTruststores} directory.
+     * 
+     * @param plugin
+     *            the plugin ID
+     * @param fileName
+     *            the name of the downloaded plugin in the downloads directory
+     * @throws IOException
+     *             if an error occurs
+     */
+    public void installLocalPluginPrerelease(@Nonnull final String plugin, @Nonnull final String fileName)
+            throws IOException {
+        installLocalPlugin(plugin, fileName, pathToTruststores.resolve(plugin).resolve("truststore.asc"));
+    }
+
+    /**
+     * Install local plugin snapshot.
+     * 
+     * Validates using SHIBBOLETH_SNAPSHOT_PGP_KEYS in the {@link pathToTruststores} directory.
+     * 
+     * @param plugin
+     *            the plugin ID
+     * @param fileName
+     *            the name of the downloaded plugin in the downloads directory
+     * @throws IOException
+     *             if an error occurs
+     */
+    public void installLocalPluginSnapshot(@Nonnull final String plugin, @Nonnull final String fileName)
+            throws IOException {
+        installLocalPlugin(plugin, fileName, pathToTruststores.resolve("SHIBBOLETH_SNAPSHOT_PGP_KEYS"));
+    }
+
+    /**
+     * Install plugin snapshot.
+     * 
+     * Downloads the Maven distribution artifact for the plugin.
+     * 
+     * @param pluginId
+     *            the plugin ID
+     * @param pluginSnapshotVersion
+     *            the version of the plugin distribution Maven artifact
+     * @param pluginArtifactId
+     *            the artifactId of the plugin distribution Maven artifact
+     */
+    public void installPluginSnapshot(@Nonnull final String pluginId, //
+            @Nonnull final String pluginSnapshotVersion, @Nonnull final String pluginArtifactId) {
+        try {
+            final PluginSnapshotSupport snapshotSupport = new PluginSnapshotSupport() //
+                    .setPluginId(pluginId)
+                    .setPluginVersion(pluginSnapshotVersion)
+                    .setPluginArtifactId(pluginArtifactId);
+
+            final URL baseURL = snapshotSupport.getBaseURL();
+
+            final String pluginSnapshotFilename = snapshotSupport.getLatestSnapshotFilename();
+
+            download(baseURL.toString(), pluginSnapshotFilename);
+
+            download(baseURL.toString(), pluginSnapshotFilename + ".asc");
+
+            installLocalPluginSnapshot(pluginId, pluginSnapshotFilename);
+
+            assertPluginsAreInstalled(pluginId);
+
+        } catch (final URISyntaxException e) {
+            throw new RuntimeException(e);
+        } catch (MalformedURLException e) {
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     /**
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/plugins/JDBCStorageServicePluginTest.java b/src/test/java/net/shibboleth/idp/integration/tests/plugins/JDBCStorageServicePluginTest.java
index 47c9dd2..76708af 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/plugins/JDBCStorageServicePluginTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/plugins/JDBCStorageServicePluginTest.java
@@ -27,9 +27,7 @@ public class JDBCStorageServicePluginTest extends BasePluginTest {
     @Test
     public void testJDBCStorageServicePluginInstallation() throws Exception {
 
-        final String[] plugins = idpVersion.startsWith("4")
-                ? new String[] { "net.shibboleth.idp.plugin.storage.jdbc" }
-                : new String[] { "net.shibboleth.plugin.storage.jdbc" };
+        final String[] plugins = new String[] { "net.shibboleth.plugin.storage.jdbc" };
 
         assertPluginsAreAvailable(plugins);
 
@@ -44,4 +42,25 @@ public class JDBCStorageServicePluginTest extends BasePluginTest {
         assertPluginsAreOnStatusPage(plugins);
     }
 
+    @Test
+    public void testJDBCStorageServicePluginSnapshotInstallation() throws Exception {
+
+        final String pluginId = "net.shibboleth.plugin.storage.jdbc";
+
+        // TODO this version is fragile - will need to be manually updated
+        final String pluginSnapshotVersion = "2.0.2-SNAPSHOT";
+
+        final String pluginArtifactId = "java-plugin-jdbc-storage";
+
+        installPluginSnapshot(pluginId, pluginSnapshotVersion, pluginArtifactId);
+
+        assertPluginsAreInstalled(pluginId);
+
+        buildWAR();
+
+        startServer();
+
+        assertPluginsAreOnStatusPage(pluginId);
+    }
+
 }
\ No newline at end of file
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/util/PluginSnapshotSupport.java b/src/test/java/net/shibboleth/idp/integration/tests/util/PluginSnapshotSupport.java
new file mode 100644
index 0000000..abfcae3
--- /dev/null
+++ b/src/test/java/net/shibboleth/idp/integration/tests/util/PluginSnapshotSupport.java
@@ -0,0 +1,134 @@
+
+package net.shibboleth.idp.integration.tests.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.annotation.Nonnull;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Support for installing IdP Plugin snapshots.
+ */
+public class PluginSnapshotSupport {
+
+    @Nonnull
+    /** Class logger. */
+    private final Logger log = LoggerFactory.getLogger(PluginSnapshotSupport.class);
+
+    @Nonnull
+    /** Base URL of snapshot repository, defaults to "https://build.shibboleth.net/maven/snapshots" */
+    public String snapshotRepositoryBaseURL = "https://build.shibboleth.net/maven/snapshots";
+
+    @Nonnull
+    /** Plugin ID, for example, defaults to "net.shibboleth.plugin.storage.jdbc" */
+    private String pluginId = "net.shibboleth.plugin.storage.jdbc";
+
+    @Nonnull
+    /** Version of the plugin distribution Maven artifact, for example, defaults to "2.0.2-SNAPSHOT" */
+    private String pluginVersion = "2.0.2-SNAPSHOT";
+
+    @Nonnull
+    /** ArtifactId of the plugin distribution Maven artifact, for example, defaults to "java-plugin-jdbc-storage" */
+    private String pluginArtifactId = "java-plugin-jdbc-storage";
+
+    /**
+     * Set the plugin ID.
+     * 
+     * @param pluginId
+     *            plugin ID
+     * @return this instance
+     */
+    public PluginSnapshotSupport setPluginId(@Nonnull final String pluginId) {
+        this.pluginId = pluginId;
+        return this;
+    }
+
+    /**
+     * Set the artifactID of the plugin distribution Maven artifact.
+     * 
+     * @param pluginArtifactId
+     *            artifactID of the plugin distribution Maven artifact
+     * @return this instance
+     */
+    public PluginSnapshotSupport setPluginArtifactId(@Nonnull final String pluginArtifactId) {
+        this.pluginArtifactId = pluginArtifactId;
+        return this;
+    }
+
+    /**
+     * Set the version of the plugin distribution Maven artifact.
+     * 
+     * @param pluginVersion
+     *            version of the plugin distribution Maven artifact
+     * @return this instance
+     */
+    public PluginSnapshotSupport setPluginVersion(@Nonnull final String pluginVersion) {
+        this.pluginVersion = pluginVersion;
+        return this;
+    }
+
+    /**
+     * Get the base URL of the plugin distribution Maven artifact.
+     * 
+     * For example :
+     * "https://build.shibboleth.net/maven/snapshots/net/shibboleth/plugin/storage/jdbc/java-plugin-jdbc-storage/2.0.2-SNAPSHOT/"
+     * 
+     * @return the base URL of the plugin distribution Maven artifact
+     * 
+     * @throws MalformedURLException
+     *             if an error occurs
+     * @throws URISyntaxException
+     *             if an error occurs
+     */
+    public URL getBaseURL() throws MalformedURLException, URISyntaxException {
+        final String groupPath = pluginId.replace(".", "/");
+        final String str = String.join("/", snapshotRepositoryBaseURL, groupPath, pluginArtifactId, pluginVersion) + "/";
+        return new URI(str).toURL();
+    }
+
+    /**
+     * Get the filename of the latest snapshot of the plugin distribution Maven artifact.
+     * 
+     * Retrieves the base URL and returns the name of the last artifact ending in .tar.gz.
+     * 
+     * @return the filename of the latest snapshot of the plugin distribution Maven artifact
+     * 
+     * @throws RuntimeException
+     *             if an error occurs
+     */
+    public String getLatestSnapshotFilename() {
+        final Pattern pattern = Pattern.compile("<a href=\".*?\">(.*?\\.tar\\.gz)</a");
+        try {
+            final URL url = getBaseURL();
+            String fileName = null;
+            try (final BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) {
+                String line;
+                while ((line = br.readLine()) != null) {
+                    // log.trace(line);
+                    final Matcher matcher = pattern.matcher(line);
+                    if (matcher.find()) {
+                        fileName = matcher.group(1);
+                        log.debug("Latest snapshot is '{}' for '{}' '{}'", fileName, pluginArtifactId, pluginVersion);
+                    }
+                }
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            return fileName;
+        } catch (MalformedURLException e) {
+            throw new RuntimeException(e);
+        } catch (URISyntaxException e1) {
+            throw new RuntimeException(e1);
+        }
+    }
+}
diff --git a/src/test/resources/net/shibboleth/idp/integration/tests/truststores/SHIBBOLETH_SNAPSHOT_PGP_KEYS b/src/test/resources/net/shibboleth/idp/integration/tests/truststores/SHIBBOLETH_SNAPSHOT_PGP_KEYS
new file mode 100644
index 0000000..8b2e123
--- /dev/null
+++ b/src/test/resources/net/shibboleth/idp/integration/tests/truststores/SHIBBOLETH_SNAPSHOT_PGP_KEYS
@@ -0,0 +1,67 @@
+This file contains the PGP keys for Shibboleth Project non-production SNAPSHOT builds.
+
+To import these keys into your keyring:
+
+    pgp < SHIBBOLETH_SNAPSHOT_PGP_KEYS
+or  gpg --import SHIBBOLETH_SNAPSHOT_PGP_KEYS
+
+pub   rsa4096 2023-08-04 [SC] [expires: 2025-08-07]
+      6163AF5AE367B6B157A57C21E07C0FEA698F7D71
+uid           [ unknown] Shibboleth-Jenkins-2023-08-04 (Non-production signing key for SNAPSHOT builds by the Shibboleth Project Jenkins CI Service.) <jenkins at shibboleth.net>
+sub   rsa4096 2023-08-04 [E] [expires: 2025-08-07]
+
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
+mQINBGTNKdsBEACx2PJv58cG5hWPh4uvdPT64xek2JBjzfD67dk1926Hq3N3wxw5
+q+0Bth1G+qn50KfhNxtsnrLPpcXWzWsXEzjL+w52qNjcho9ktefZ1YnnBhgfbMjX
+w0yrQUBbMJgx3tUrpwcKeNKrgVWyJ5fOSBnCl2PZjgBVThtzRMOTvib0Cvx9ey4i
+dKLwSIleCD0VHcQ6NJaAvbv0ycgqb72NA/MLK/4RQf2nGpjqRCBw+4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mYbOzaZHBMZOGjzZaTpkl2BCd3nx0xnA15Imas
+fyRrpUFWlABqSs2gCZO+FiqVK7CG4VvCsBjhABEBAAGJAjwEGAEIACYCGwwWIQRh
+Y69a42e2sVelfCHgfA/qaY99cQUCZrNTEAUJA8dctQAKCRDgfA/qaY99cdQaEACn
++2RRNqmMBVqzszzc9oP7gm7KfTyfdaj55oXJRVk/i/6nNMlqDwmh6YEUOmsMNGqT
++K9wHldhJZjXrlLYcpF5JW4oIq7mmjFZ9txyXYgLurmMNjm/E84a+sJKbueCV22j
+9Gxt5Cr14Xt5rmADBPBK0rwnjgCqfL1rDJ2PXvJQBIgmXAz8a3/Zs/com1Cv7Pkh
+K0LQsEPhdlUhS7mKKzbQ4mhdCX/5Mlz8P7cg08uI0sjuqeWnllQbySyXSgcZ6w7m
+vqqbnOGhHrrXZlAPLGEUemLcQwjCw31ZaIDKOEhN3CVRqIK8WyuCJDhu5e0S+pni
+yAU7SXhbab0XWQI1JZhIvok/btdy5wmcRzjU2VvtSEOt29bHvWSTGEl7VeJtcDOg
+oWyZnFA7dhAS/495DOQ2Lou6ffLUXwJexGQ7uYVedD+bn7B60rYzc6PBi53J1lfA
+Qow7xSNO13w6Hhxo57p39c+gEoKfePGqYVrmLNVi4MQGWJ8BdotNdcn8mCwrV5xX
+C/fq1ff9U3Ic6/fuzL+sZCNY/mont/ovLmoI0u88TVXkGkEVSLLSpu2SPh+2xEDn
+kJ+kGVwJU3MG+bcnjanteEXbfJwKdRJJVM1BzpUlz+R8xEy6zvN7++OJEmEHyF8T
+AA/Cs+V1xPQChyFXOBtQ7uxLiFOihsjWJEFW98OSUQ==
+=mU7D
+-----END PGP PUBLIC KEY BLOCK-----
+

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


More information about the commits mailing list