jUnit test for a bug in the Attribute Resolver. Recursive attribute dependencies...
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 22 Aug 2003 17:24:15 +0000 (17:24 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Fri, 22 Aug 2003 17:24:15 +0000 (17:24 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@739 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

data/resolver12.xml [new file with mode: 0644]
tests/edu/internet2/middleware/shibboleth/aa/attrresolv/ResolverTests.java

diff --git a/data/resolver12.xml b/data/resolver12.xml
new file mode 100644 (file)
index 0000000..356f8d1
--- /dev/null
@@ -0,0 +1,18 @@
+<AttributeResolver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mace:shibboleth:resolver:1.0" xsi:schemaLocation="urn:mace:shibboleth:resolver:1.0 shibboleth-resolver-1.0.xsd">
+       
+       <SimpleAttributeDefinition id="urn:mace:dir:attribute-def:eduPersonScopedAffiliation" smartScope="example.edu">
+               <AttributeDependency requires="urn:mace:dir:attribute-def:eduPersonAffiliation"/>
+       </SimpleAttributeDefinition>
+       
+       <SimpleAttributeDefinition id="urn:mace:shibboleth:test:eduPersonAffiliation">
+               <AttributeDependency requires="urn:mace:dir:attribute-def:eduPersonAffiliation"/>
+       </SimpleAttributeDefinition>
+
+       <SimpleAttributeDefinition id="urn:mace:dir:attribute-def:eduPersonAffiliation">
+               <DataConnectorDependency requires="echo"/>
+       </SimpleAttributeDefinition>
+       
+       <CustomDataConnector id="echo" cacheTime="1800000"
+               class="edu.internet2.middleware.shibboleth.aa.attrresolv.provider.SampleConnector" />
+
+</AttributeResolver>
\ No newline at end of file
index ad8a9e6..16978a9 100644 (file)
@@ -415,6 +415,47 @@ public class ResolverTests extends TestCase {
                        fail("Error creating SAML Attribute: " + e.getMessage());
                }
        }
+       public void testMultiLevelAttributeDependency() {
+
+               try {
+                       Properties props = new Properties();
+                       File file = new File("data/resolver12.xml");
+                       props.setProperty(
+                               "edu.internet2.middleware.shibboleth.aa.attrresolv.AttributeResolver.ResolverConfig",
+                               file.toURL().toString());
+
+                       AttributeResolver ar = new AttributeResolver(props);
+
+                       AAAttributeSet inputAttributes =
+                               new AAAttributeSet(
+                                       new AAAttribute[] {
+                                               new AAAttribute("urn:mace:dir:attribute-def:eduPersonScopedAffiliation"),
+                                               new AAAttribute("urn:mace:dir:attribute-def:eduPersonAffiliation"),
+                                               new AAAttribute("urn:mace:shibboleth:test:eduPersonAffiliation")});
+
+                       AAAttributeSet outputAttributes =
+                               new AAAttributeSet(
+                                       new AAAttribute[] {
+                                               new AAAttribute(
+                                                       "urn:mace:dir:attribute-def:eduPersonScopedAffiliation",
+                                                       new Object[] { "member@example.edu" },
+                                                       new ScopedStringValueHandler("example.edu")),
+                                               new AAAttribute("urn:mace:dir:attribute-def:eduPersonAffiliation", new Object[] { "member" }),
+                                               new AAAttribute("urn:mace:shibboleth:test:eduPersonAffiliation", new Object[] { "member" })
+                                       });
+
+                       ar.resolveAttributes(new PrincipalImpl("mytestuser"), "shar.example.edu", inputAttributes);
+
+                       assertEquals("Attribute Resolver returned unexpected attribute set.", inputAttributes, outputAttributes);
+
+               } catch (AttributeResolverException e) {
+                       fail("Couldn't load attribute resolver: " + e.getMessage());
+               } catch (MalformedURLException e) {
+                       fail("Error in test specification: " + e.getMessage());
+               } catch (SAMLException e) {
+                       fail("Error creating SAML Attribute: " + e.getMessage());
+               }
+       }
 
 
 }