[java-identity-provider COMMIT] /trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseVa...

noreply at shibboleth.net noreply at shibboleth.net
Fri Dec 19 18:11:27 EST 2014


Author: tzeller
Date: Fri Dec 19 18:11:27 2014
New Revision: 7191

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7191&view=rev
Log:
Fix tests, including Java 8 tests, by ignoring the order of attributes in assertions by the response validator. This assumes that the order of attributes in assertions is not guaranteed.

Modified:
    trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java

Modified: trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java?rev=7191&r1=7190&r2=7191&view=diff
==============================================================================
--- trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java (original)
+++ trunk/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java Fri Dec 19 18:11:27 2014
@@ -18,7 +18,9 @@
 package net.shibboleth.idp.test.flows.saml2;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -611,9 +613,16 @@
         Assert.assertFalse(attributes.isEmpty());
         Assert.assertEquals(attributes.size(), usedAttributeDesignators ? expectedDesignatedAttributes.size() : expectedAttributes.size());
 
+        // Ignore attribute ordering
+        final Map<String, Attribute> actualAttributes = new HashMap<>();
+        for(final Attribute attribute : attributes) {
+            actualAttributes.put(attribute.getName(), attribute);
+        }
+        
         for (int i = 0; i < (usedAttributeDesignators ? expectedDesignatedAttributes.size() : expectedAttributes.size()); i++) {
             final Attribute expectedAttribute = usedAttributeDesignators ? expectedDesignatedAttributes.get(i) : expectedAttributes.get(i);
-            final Attribute actualAttribute = attributes.get(i);
+            final Attribute actualAttribute = actualAttributes.get(expectedAttribute.getName());
+            Assert.assertNotNull(actualAttribute);
             assertAttributeName(actualAttribute, expectedAttribute.getName(), expectedAttribute.getNameFormat(),
                     expectedAttribute.getFriendlyName());
             assertAttributeValue(actualAttribute, ((XSAny) expectedAttribute.getAttributeValues().get(0)).getTextContent());



More information about the commits mailing list