[java-metadata-aggregator COMMIT] in /trunk/aggregator-pipeline/src: main/java/net/shibboleth/metadata/dom/saml/Entit...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Apr 10 05:59:54 EDT 2013
Author: iay
Date: Wed Apr 10 05:59:54 2013
New Revision: 235
URL: http://svn.shibboleth.net/view/java-metadata-aggregator?rev=235&view=rev
Log:
MDA-87 EntitiesDescriptorAssemblerStage does not declare namespace prefix
Modified:
trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java
trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStageTest.java
Modified: trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java
URL: http://svn.shibboleth.net/view/java-metadata-aggregator/trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java?rev=235&r1=234&r2=235&view=diff
==============================================================================
--- trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java (original)
+++ trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java Wed Apr 10 05:59:54 2013
@@ -36,6 +36,7 @@
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import net.shibboleth.utilities.java.support.xml.AttributeSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
+import net.shibboleth.utilities.java.support.xml.NamespaceSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -152,6 +153,8 @@
final Element entitiesDescriptor =
ElementSupport.constructElement(entitiesDescriptorDocument,
SamlMetadataSupport.ENTITIES_DESCRIPTOR_NAME);
+ NamespaceSupport.appendNamespaceDeclaration(entitiesDescriptor,
+ entitiesDescriptor.getNamespaceURI(), entitiesDescriptor.getPrefix());
entitiesDescriptorDocument.appendChild(entitiesDescriptor);
addDescriptorName(entitiesDescriptor);
Modified: trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStageTest.java
URL: http://svn.shibboleth.net/view/java-metadata-aggregator/trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStageTest.java?rev=235&r1=234&r2=235&view=diff
==============================================================================
--- trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStageTest.java (original)
+++ trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStageTest.java Wed Apr 10 05:59:54 2013
@@ -26,6 +26,7 @@
import net.shibboleth.metadata.dom.DomElementItem;
import net.shibboleth.metadata.dom.saml.EntitiesDescriptorAssemblerStage.ItemOrderingStrategy;
+import org.junit.Assert;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
@@ -103,6 +104,30 @@
assertXmlIdentical(readTestRelativeXmlData(EntitiesDescriptorAssemblerStage.class,
"entitiesDescriptor2Reversed.xml"), result);
}
+
+ /**
+ * Test for MDA-87, which turns out to be due to not constructing the document element
+ * with an appropriate namespace declaration.
+ *
+ * @throws Exception if anything goes wrong
+ */
+ @Test
+ public void testMda87() throws Exception {
+ Collection<DomElementItem> metadataCollection = buildMetadataCollection();
+ EntitiesDescriptorAssemblerStage stage = new EntitiesDescriptorAssemblerStage();
+ stage.setId("foo");
+ stage.initialize();
+ stage.execute(metadataCollection);
+
+ Element result = metadataCollection.iterator().next().unwrap();
+
+ Assert.assertEquals(result.getLocalName(), "EntitiesDescriptor");
+ Assert.assertEquals(result.getPrefix(), "md");
+ Assert.assertEquals(result.getNamespaceURI(), "urn:oasis:names:tc:SAML:2.0:metadata");
+
+ String nsattr = result.getAttributeNS("http://www.w3.org/2000/xmlns/", "md");
+ Assert.assertEquals("urn:oasis:names:tc:SAML:2.0:metadata", nsattr);
+ }
protected Collection<DomElementItem> buildMetadataCollection() throws Exception {
ArrayList<DomElementItem> metadataCollection = new ArrayList<DomElementItem>();
More information about the commits
mailing list