[java-opensaml COMMIT] /trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/SAML2HTT...

noreply at shibboleth.net noreply at shibboleth.net
Fri Feb 6 21:53:20 EST 2015


Author: putmanb
Date: Fri Feb  6 21:53:20 2015
New Revision: 4215

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4215&view=rev
Log:
Fix unit test that broke now that encoder templates use an HTML 5 DOCTYPE.

Modified:
    trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/SAML2HTTPPostSimpleSignSecurityHandlerTest.java

Modified: trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/SAML2HTTPPostSimpleSignSecurityHandlerTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/SAML2HTTPPostSimpleSignSecurityHandlerTest.java?rev=4215&r1=4214&r2=4215&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/SAML2HTTPPostSimpleSignSecurityHandlerTest.java (original)
+++ trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/binding/security/impl/SAML2HTTPPostSimpleSignSecurityHandlerTest.java Fri Feb  6 21:53:20 2015
@@ -23,9 +23,13 @@
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 
+import javax.xml.XMLConstants;
+
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.xml.BasicParserPool;
 import net.shibboleth.utilities.java.support.xml.ElementSupport;
 import net.shibboleth.utilities.java.support.xml.XMLParserException;
 
@@ -411,11 +415,20 @@
      * @param request
      * @param htmlContentString
      * @throws XMLParserException
-     */
-    private void populateRequest(MockHttpServletRequest request, String htmlContentString) throws XMLParserException {
+     * @throws ComponentInitializationException 
+     */
+    private void populateRequest(MockHttpServletRequest request, String htmlContentString) throws XMLParserException, ComponentInitializationException {
         request.setContent(htmlContentString.getBytes());
-
-        Document doc = parserPool.parse(new ByteArrayInputStream(htmlContentString.getBytes()));
+        
+        // Encoder template now carries HTML 5 DOCTYPE, so have to use a parser pool that allows this.
+        HashMap<String, Boolean> features = new HashMap<>();
+        features.put(XMLConstants.FEATURE_SECURE_PROCESSING, false);
+        features.put("http://apache.org/xml/features/disallow-doctype-decl", false);
+        BasicParserPool pp = new BasicParserPool();
+        pp.setBuilderFeatures(features);
+        pp.initialize();
+
+        Document doc = pp.parse(new ByteArrayInputStream(htmlContentString.getBytes()));
         // html
         Element current = doc.getDocumentElement();
         // head
@@ -429,7 +442,7 @@
         current = ElementSupport.getFirstChildElement(current);
         // list of form input fields
         List<Element> inputs =
-                ElementSupport.getChildElementsByTagNameNS(current, "http://www.w3.org/1999/xhtml", "input");
+                ElementSupport.getChildElementsByTagNameNS(current, null, "input");
         for (Element element : inputs) {
             String name = element.getAttributeNS(null, "name");
             String value = element.getAttributeNS(null, "value");



More information about the commits mailing list