[java-metadata-aggregator] branch main updated: MDA-255 - Default noChildrenAProcessingError to true
Ian Young
ian at iay.org.uk
Thu Apr 27 11:12:56 UTC 2023
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch main
in repository java-metadata-aggregator.
View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=963f441a33591838f46adab6be12403cbe2a370e
The following commit(s) were added to refs/heads/main by this push:
new 963f441 MDA-255 - Default noChildrenAProcessingError to true
963f441 is described below
commit 963f441a33591838f46adab6be12403cbe2a370e
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu Apr 27 12:12:49 2023 +0100
MDA-255 - Default noChildrenAProcessingError to true
https://shibboleth.atlassian.net/browse/MDA-255
---
.../dom/saml/EntitiesDescriptorAssemblerStage.java | 19 +++++--
.../saml/EntitiesDescriptorAssemblerStageTest.java | 62 ++++++++++++++++------
2 files changed, 61 insertions(+), 20 deletions(-)
diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java
index 4b5ed9a..f249c9e 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStage.java
@@ -58,10 +58,19 @@ public class EntitiesDescriptorAssemblerStage extends AbstractStage<Element> {
private static final @Nonnull Logger LOG = LoggerFactory.getLogger(EntitiesDescriptorAssemblerStage.class);
/**
- * Whether attempting to turn an empty item collection, which would result in a schema-invalid childless
- * EntitiesDescriptor, should be treated as processing error. Default value: <code>false</code>
+ * Whether attempting to turn an empty item collection into an <code>EntitiesDescriptor</code>
+ * should be treated as a processing error.
+ *
+ * <p>
+ * Note that regardless of this setting, a childless <code>EntitiesDescriptor</code>
+ * will <em>not</em> be produced. It would in any case be schema-invalid.
+ * </p>
+ *
+ * <p>
+ * Default value: <code>true</code>
+ * </p>
*/
- @GuardedBy("this") private boolean noChildrenAProcessingError;
+ @GuardedBy("this") private boolean noChildrenAProcessingError = true;
/** Strategy used to order a collection of Items. The default strategy performs no ordering. */
@Nonnull @GuardedBy("this")
@@ -75,7 +84,7 @@ public class EntitiesDescriptorAssemblerStage extends AbstractStage<Element> {
* Gets whether attempting to turn an empty item collection, which would result in a schema-invalid childless
* EntitiesDescriptor, should be treated as processing error.
*
- * @return whether attempting to turn an empty item collection should be treated as processing error
+ * @return whether attempting to process an empty item collection should be treated as processing error
*/
public final synchronized boolean isNoChildrenAProcessingError() {
return noChildrenAProcessingError;
@@ -85,7 +94,7 @@ public class EntitiesDescriptorAssemblerStage extends AbstractStage<Element> {
* Sets whether attempting to turn an empty item collection, which would result in a schema-invalid childless
* EntitiesDescriptor, should be treated as processing error.
*
- * @param isError whether attempting to turn an empty item collection should be treated as processing error
+ * @param isError whether attempting to process an empty item collection should be treated as processing error
*/
public synchronized void setNoChildrenAProcessingError(final boolean isError) {
checkSetterPreconditions();
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStageTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStageTest.java
index 8101c2d..bd1860a 100644
--- a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStageTest.java
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntitiesDescriptorAssemblerStageTest.java
@@ -31,15 +31,30 @@ import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.dom.DOMElementItem;
import net.shibboleth.metadata.dom.testing.BaseDOMTest;
import net.shibboleth.metadata.pipeline.ItemOrderingStrategy;
+import net.shibboleth.metadata.pipeline.StageProcessingException;
-/** Unit test for the {@link EntitiesDescriptorAssemblerStage} class. */
public class EntitiesDescriptorAssemblerStageTest extends BaseDOMTest {
- /** Constructor sets class under test. */
public EntitiesDescriptorAssemblerStageTest() {
super(EntitiesDescriptorAssemblerStage.class);
}
+ protected @Nonnull List<Item<Element>> buildMetadataCollection() throws Exception {
+ final ArrayList<Item<Element>> metadataCollection = new ArrayList<>();
+
+ Element descriptor = readXMLData("entity1.xml");
+ metadataCollection.add(new DOMElementItem(descriptor));
+
+ descriptor = readXMLData("entity2.xml");
+ metadataCollection.add(new DOMElementItem(descriptor));
+
+ Element fooElement = getParserPool().newDocument().createElement("foo");
+ assert fooElement != null;
+ metadataCollection.add(new DOMElementItem(fooElement));
+
+ return metadataCollection;
+ }
+
/**
* Basic test without use of the name property.
*
@@ -137,19 +152,36 @@ public class EntitiesDescriptorAssemblerStageTest extends BaseDOMTest {
Assert.assertEquals("urn:oasis:names:tc:SAML:2.0:metadata", nsattr);
}
- protected @Nonnull List<Item<Element>> buildMetadataCollection() throws Exception {
- final ArrayList<Item<Element>> metadataCollection = new ArrayList<>();
-
- Element descriptor = readXMLData("entity1.xml");
- metadataCollection.add(new DOMElementItem(descriptor));
-
- descriptor = readXMLData("entity2.xml");
- metadataCollection.add(new DOMElementItem(descriptor));
-
- Element fooElement = getParserPool().newDocument().createElement("foo");
- assert fooElement != null;
- metadataCollection.add(new DOMElementItem(fooElement));
+ @Test
+ public void noChildrenOK() throws Exception {
+ final var items = new ArrayList<Item<Element>>();
+ final var stage = new EntitiesDescriptorAssemblerStage();
+ stage.setId("test");
+ stage.setNoChildrenAProcessingError(false);
+ stage.initialize();
+ stage.execute(items);
+ stage.destroy();
+ Assert.assertEquals(items.size(), 0);
+ }
- return metadataCollection;
+ @Test(expectedExceptions = {StageProcessingException.class})
+ public void noChildrenBad() throws Exception {
+ final var items = new ArrayList<Item<Element>>();
+ final var stage = new EntitiesDescriptorAssemblerStage();
+ stage.setId("test");
+ stage.setNoChildrenAProcessingError(true);
+ stage.initialize();
+ stage.execute(items);
+ }
+
+ @Test(expectedExceptions = {StageProcessingException.class})
+ public void noChildrenDefault() throws Exception {
+ final var items = new ArrayList<Item<Element>>();
+ final var stage = new EntitiesDescriptorAssemblerStage();
+ stage.setId("test");
+ // Default changed in MDA-255
+ // stage.setNoChildrenAProcessingError(true);
+ stage.initialize();
+ stage.execute(items);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list