[java-idp-integration-tests] branch main updated: Enable backchannel when testing Tomcat
Tom Zeller
tzeller at dragonacea.biz
Tue May 2 22:21:55 UTC 2023
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=ff6adbdd0fff13b30845c4699adfbc678fa809d8
The following commit(s) were added to refs/heads/main by this push:
new ff6adbd Enable backchannel when testing Tomcat
ff6adbd is described below
commit ff6adbdd0fff13b30845c4699adfbc678fa809d8
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Tue May 2 17:21:38 2023 -0500
Enable backchannel when testing Tomcat
---
.../idp/integration/tests/BaseIntegrationTest.java | 59 ++++++++++++++++++++++
.../saml2/SAML2AttributeQueryIntegrationTest.java | 36 +++++++++++++
2 files changed, 95 insertions(+)
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 959b492..36690f5 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/BaseIntegrationTest.java
@@ -2499,4 +2499,63 @@ public abstract class BaseIntegrationTest {
logProcess(process, "modules :");
}
+ /**
+ * Uncomment a comment starting with the given string.
+ *
+ * For example, the following :
+ *
+ * <pre>
+ * {@code
+ * <!-- Here is a comment
+ * multi-line comment
+ * to be uncommented
+ * -->
+ * }
+ * </pre>
+ *
+ * would be replaced with :
+ *
+ * <pre>
+ * {@code
+ * multi-line comment
+ * to be uncommented
+ * }
+ * </pre>
+ *
+ * when the commentText is "Here is a comment".
+ *
+ * @param pathToFile
+ * path to the file
+ * @param commentText
+ * prefix indicating start of text to be uncommented
+ * @throws IOException
+ */
+ public static void uncommentAfter(@Nonnull final Path pathToFile, @Nonnull @NotEmpty final String commentText)
+ throws IOException {
+
+ final Charset charset = StandardCharsets.UTF_8;
+
+ String content = new String(Files.readAllBytes(pathToFile), charset);
+
+ final String regex = "<!-- " + commentText + "\\s*(.*?)\\s*-->";
+
+ final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
+
+ final Matcher matcher = pattern.matcher(content);
+
+ if (matcher.find()) {
+
+ final String found = matcher.group();
+
+ final String toUncomment = matcher.group(1);
+
+ LoggerFactory.getLogger(BaseIntegrationTest.class)
+ .debug("Replacing \n '{}' \n with \n '{}' \n in file '{}'", found, toUncomment, pathToFile);
+
+ content = content.replace(found, toUncomment);
+ }
+
+ Files.write(pathToFile, content.getBytes(charset));
+ }
+
}
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/saml2/SAML2AttributeQueryIntegrationTest.java b/src/test/java/net/shibboleth/idp/integration/tests/saml2/SAML2AttributeQueryIntegrationTest.java
index fbc547a..4deb805 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/saml2/SAML2AttributeQueryIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/saml2/SAML2AttributeQueryIntegrationTest.java
@@ -20,8 +20,10 @@ package net.shibboleth.idp.integration.tests.saml2;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -249,6 +251,40 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
uncommentFile(pathToSubjectC14nXML, toUncomment);
}
+ /**
+ * Enable the SOAP endpoint.
+ *
+ * When using Jetty, the SOAP endpoint is enabled by default.
+ *
+ * When using Tomcat, copy the trustany JAR to lib/ and uncomment the connector
+ * in conf/server.xml.
+ *
+ * @throws IOException
+ */
+ @BeforeClass
+ protected void enableSOAPEndpoint() throws IOException {
+
+ // Tomcat
+ if (pathToTomcatBase != null) {
+
+ // Copy trustany JAR to CATALINA_BASE/lib
+ final Path pathToSource = pathToTomcatBase.resolve(Paths.get("lib-extras", "trustany-ssl-1.0.0.jar"));
+ Assert.assertTrue(pathToSource.toFile().exists());
+
+ final Path pathToTarget = pathToTomcatBase.resolve(Paths.get("lib", "trustany-ssl-1.0.0.jar"));
+ Assert.assertFalse(pathToTarget.toFile().exists());
+
+ Files.move(pathToSource, pathToTarget, StandardCopyOption.ATOMIC_MOVE);
+
+ // Add connector definition to CATALINA_BASE/conf/server.xml
+ final Path pathToServerXml = pathToTomcatBase.resolve(Paths.get("conf", "server.xml"));
+
+ final String toUncomment = "Define dedicated SOAP connector for back-channel requests";
+
+ BaseIntegrationTest.uncommentAfter(pathToServerXml, toUncomment);
+ }
+ }
+
/**
* Set path to client TLS certificate resource. A <code>null</code> path clears the request parameter.
*
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list