[java-metadata-aggregator] branch main updated: MDA-299 - Fix port check so that it can occur in isolation

Ian Young ian at iay.org.uk
Thu Feb 1 15:10:36 UTC 2024


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=90477f06b9752876e45b39e0c04fc0cec5e097bd

The following commit(s) were added to refs/heads/main by this push:
     new 90477f0  MDA-299 - Fix port check so that it can occur in isolation
90477f0 is described below

commit 90477f06b9752876e45b39e0c04fc0cec5e097bd
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu Feb 1 15:10:32 2024 +0000

    MDA-299 - Fix port check so that it can occur in isolation
    
    https://shibboleth.atlassian.net/browse/MDA-299
---
 .../validate/url/EmptyPortURLValidator.java        |  2 +-
 .../validate/url/EmptyPortURLValidatorTest.java    | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/validate/url/EmptyPortURLValidator.java b/mda-framework/src/main/java/net/shibboleth/metadata/validate/url/EmptyPortURLValidator.java
index 78955b1..321596c 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/validate/url/EmptyPortURLValidator.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/validate/url/EmptyPortURLValidator.java
@@ -32,7 +32,7 @@ public class EmptyPortURLValidator extends BaseValidator implements Validator<UR
     public @Nonnull Action validate(final @Nonnull URL url, final @Nonnull Item<?> item,
             final @Nonnull String stageId) throws StageProcessingException {
         final String authority = url.getAuthority();
-        if (authority != null) {
+        if (authority != null && !authority.isEmpty()) {
             if (authority.charAt(authority.length() - 1) == ':') {
                 addError("libxml2: port present but empty", item, stageId);
                 return Action.DONE;
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/validate/url/EmptyPortURLValidatorTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/validate/url/EmptyPortURLValidatorTest.java
new file mode 100644
index 0000000..9256d4f
--- /dev/null
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/validate/url/EmptyPortURLValidatorTest.java
@@ -0,0 +1,22 @@
+package net.shibboleth.metadata.validate.url;
+
+import java.net.URL;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import net.shibboleth.metadata.testing.MockItem;
+import net.shibboleth.metadata.validate.Validator.Action;
+
+public class EmptyPortURLValidatorTest {
+    @Test
+    public void testEmptyAuthority() throws Exception {
+        final var val = new EmptyPortURLValidator();
+        val.setId("test");
+        val.initialize();
+        final var item = new MockItem("item");
+        final var res = val.validate(new URL("https:///whatever"), item, "stage");
+        Assert.assertEquals(res, Action.CONTINUE);
+        val.destroy();
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list