[java-idp-integration-tests COMMIT] in /trunk/src/test/java/net/shibboleth/idp/test: BaseIntegrationTest.java saml2/S...

noreply at shibboleth.net noreply at shibboleth.net
Thu Oct 23 13:30:00 EDT 2014


Author: tzeller
Date: Thu Oct 23 13:30:00 2014
New Revision: 30

URL: http://svn.shibboleth.net/view/java-idp-integration-tests?rev=30&view=rev
Log:
Fix bug in attribute release flow and add integration test.

Added:
    trunk/src/test/java/net/shibboleth/idp/test/saml2/SAML2UnsolicitedSSOIntegrationWithConsentTest.java   (with props)
Modified:
    trunk/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java

Modified: trunk/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
URL: http://svn.shibboleth.net/view/java-idp-integration-tests/trunk/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java?rev=30&r1=29&r2=30&view=diff
==============================================================================
--- trunk/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java (original)
+++ trunk/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java Thu Oct 23 13:30:00 2014
@@ -22,11 +22,16 @@
 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 net.shibboleth.idp.installer.PropertiesWithComments;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
 import net.shibboleth.utilities.java.support.xml.ParserPool;
 
 import org.opensaml.core.config.InitializationException;
@@ -35,6 +40,7 @@
 import org.opensaml.core.xml.io.UnmarshallerFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.core.io.FileSystemResource;
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterMethod;
@@ -48,7 +54,7 @@
 
     /** Directory in which distributions will be unpackaged. */
     @Nonnull public final static String TEST_DISTRIBUTIONS_DIRECTORY = "test-distributions";
-    
+
     /** IdP XML security manager property key. */
     @Nonnull public final static String IDP_XML_SECURITY_MANAGER_PROP_NAME = "idp.xml.securityManager";
 
@@ -63,6 +69,9 @@
 
     /** Path to idp.home. */
     @NonnullAfterInit protected Path pathToIdPHome;
+
+    /** Path to conf/idp.properties. */
+    @NonnullAfterInit protected Path pathToIdPProperties;
 
     /** Path to jetty.base. */
     @NonnullAfterInit protected Path pathToJettyBase;
@@ -134,6 +143,10 @@
         log.debug("Path to jetty.base '{}'", pathToJettyBase.toAbsolutePath());
         Assert.assertNotNull(pathToJettyBase, "Path to jetty.base not found");
         Assert.assertTrue(pathToJettyBase.toAbsolutePath().toFile().exists(), "Path to jetty.base '{}' not found");
+
+        // Path to conf/idp.properties
+        pathToIdPProperties = Paths.get(pathToIdPHome.toAbsolutePath().toString(), "conf", "idp.properties");
+        Assert.assertTrue(pathToIdPProperties.toFile().exists(), "Path to conf/idp.properties not found");
     }
 
     /**
@@ -159,8 +172,7 @@
      * 
      * @throws ComponentInitializationException if the server cannot be initialized
      */
-    @BeforeMethod public void startJettyServer()
-            throws ComponentInitializationException {
+    @BeforeMethod public void startJettyServer() throws ComponentInitializationException {
         server = new JettyServerProcess(pathToJettyBase, pathToJettyHome);
         server.initialize();
         server.start();
@@ -175,4 +187,40 @@
         }
     }
 
+    /**
+     * Replace a property in conf/idp.properties.
+     * 
+     * @param key property key
+     * @param value property value
+     * @throws IOException if an I/O error occurs
+     */
+    public void replaceIdPProperty(@Nonnull @NotEmpty final String key, @Nonnull @NotEmpty final String value)
+            throws IOException {
+        Constraint.isNotNull(StringSupport.trimOrNull(key), "Replacement property key cannot be null nor empty");
+        Constraint.isNotNull(StringSupport.trimOrNull(value), "Replacement property value cannot be null nor empty");
+
+        log.debug("Replacing idp property '{}' with '{}'", key, value);
+
+        final FileSystemResource idpPropertiesResource =
+                new FileSystemResource(pathToIdPProperties.toAbsolutePath().toString());
+
+        final PropertiesWithComments pwc = new PropertiesWithComments();
+        pwc.load(idpPropertiesResource.getInputStream());
+        pwc.replaceProperty(key, value);
+        pwc.store(idpPropertiesResource.getOutputStream());
+    }
+
+    /**
+     * Restore conf/idp.properties from dist/conf/idp.properties.dist.
+     * 
+     * @throws IOException if an I/O error occurs
+     */
+    public void restoreIdPProperties() throws IOException {
+        final Path pathToIdPPropertiesDist =
+                Paths.get(pathToIdPHome.toAbsolutePath().toString(), "dist", "conf", "idp.properties.dist");

[... 7 lines stripped ...]


More information about the commits mailing list