[java-identity-provider] 03/04: IDP-1593 Test and fix null-ness in Organization
Rod Widdowson
rdw at steadingsoftware.com
Sun Apr 19 10:54:23 EDT 2020
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=f1b69010a09303e146730eb1fec7e8222fc4aac4
commit f1b69010a09303e146730eb1fec7e8222fc4aac4
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Apr 19 14:53:48 2020 +0100
IDP-1593 Test and fix null-ness in Organization
https://issues.shibboleth.net/jira/browse/IDP-1593
---
.../idp/saml/metadata/OrganizationUIInfo.java | 12 ++++++++++--
.../idp/saml/metadata/OrganizationUIInfoTest.java | 17 ++++++++++++++---
.../src/test/resources/OrganizationUIInfoBad.xml | 18 ++++++++++++++++++
3 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/metadata/OrganizationUIInfo.java b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/metadata/OrganizationUIInfo.java
index 60998dc..95eff55 100644
--- a/idp-saml-api/src/main/java/net/shibboleth/idp/saml/metadata/OrganizationUIInfo.java
+++ b/idp-saml-api/src/main/java/net/shibboleth/idp/saml/metadata/OrganizationUIInfo.java
@@ -52,7 +52,11 @@ public class OrganizationUIInfo {
private final Predicate<LocalizedName> nullLanguageString = new Predicate<>() {
public boolean test(final LocalizedName u) {
if (u.getXMLLang() == null) {
- LOG.warn("String with value {} has no language associated, ignoring", u.getValue());
+ LOG.warn("String with value {} in <Organization> has no language associated, ignoring.", u.getValue());
+ return false;
+ }
+ if (u.getValue()== null) {
+ LOG.warn("Ignoring empty string in <Organization/>");
return false;
}
return true;
@@ -63,7 +67,11 @@ public class OrganizationUIInfo {
private final Predicate<LocalizedURI> nullLanguageURL = new Predicate<>() {
public boolean test(final LocalizedURI u) {
if (u.getXMLLang() == null) {
- LOG.warn("URI with value {} has no language associated, ignoring", u.getURI());
+ LOG.warn("URI with value {} in <Organization> has no language associated, ignoring.", u.getURI());
+ return false;
+ }
+ if (u.getURI() == null) {
+ LOG.warn("Ignoring empty URUI in <Organization/>", u.getURI());
return false;
}
return true;
diff --git a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/metadata/OrganizationUIInfoTest.java b/idp-saml-api/src/test/java/net/shibboleth/idp/saml/metadata/OrganizationUIInfoTest.java
index e4ba13e..0c61c73 100644
--- a/idp-saml-api/src/test/java/net/shibboleth/idp/saml/metadata/OrganizationUIInfoTest.java
+++ b/idp-saml-api/src/test/java/net/shibboleth/idp/saml/metadata/OrganizationUIInfoTest.java
@@ -35,14 +35,25 @@ import net.shibboleth.utilities.java.support.xml.XMLParserException;
public class OrganizationUIInfoTest extends XMLObjectBaseTestCase {
@Test public void test() throws XMLParserException, UnmarshallingException {
-
+
final Organization acs = unmarshallElement("/OrganizationUIInfo.xml", true);
final OrganizationUIInfo info = new OrganizationUIInfo(acs);
-
+
assertEquals(info.getOrganizationNames().size(), 2);
assertEquals(info.getOrganizationNames().get(Locale.forLanguageTag("en")), "org");
assertEquals(info.getOrganizationDisplayNames().size(), 1);
assertEquals(info.getOrganizationUrls().size(), 1);
-
}
+
+ @Test public void testBad() throws XMLParserException, UnmarshallingException {
+
+ final Organization acs = unmarshallElement("/OrganizationUIInfoBad.xml", true);
+ final OrganizationUIInfo info = new OrganizationUIInfo(acs);
+
+ assertEquals(info.getOrganizationNames().size(), 1);
+ assertEquals(info.getOrganizationNames().get(Locale.forLanguageTag("en")), "OrgName");
+ assertEquals(info.getOrganizationDisplayNames().size(), 1);
+ assertEquals(info.getOrganizationUrls().size(), 1);
+ }
+
}
diff --git a/idp-saml-api/src/test/resources/OrganizationUIInfoBad.xml b/idp-saml-api/src/test/resources/OrganizationUIInfoBad.xml
new file mode 100644
index 0000000..05c9aa2
--- /dev/null
+++ b/idp-saml-api/src/test/resources/OrganizationUIInfoBad.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Organization xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:oasis:names:tc:SAML:2.0:metadata
+http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd" >
+ <OrganizationName xml:lang="">org</OrganizationName>
+ <OrganizationName xml:lang="fr"></OrganizationName>
+ <OrganizationName xml:lang="en">OrgName</OrganizationName>
+ <OrganizationName >ODN</OrganizationName>
+ <OrganizationDisplayName xml:lang="en">odn</OrganizationDisplayName>
+ <OrganizationDisplayName >odn</OrganizationDisplayName>
+ <OrganizationDisplayName xml:lang="">odn</OrganizationDisplayName>
+ <OrganizationDisplayName xml:lang="fr"></OrganizationDisplayName>
+ <OrganizationURL xml:lang="en">url</OrganizationURL>
+ <OrganizationURL >url</OrganizationURL>
+ <OrganizationURL xml:lang="">url</OrganizationURL>
+ <OrganizationURL xml:lang="fr"></OrganizationURL>
+</Organization>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list