More jUnit tests for the attribute resolver.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 17 Apr 2003 19:44:21 +0000 (19:44 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 17 Apr 2003 19:44:21 +0000 (19:44 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@575 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

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

diff --git a/data/resolver8.xml b/data/resolver8.xml
new file mode 100644 (file)
index 0000000..039ed9d
--- /dev/null
@@ -0,0 +1,24 @@
+<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:eduPerson:1.0:eduPersonPrincipalName" smartScope="example.edu">
+               <DataConnectorDependency requires="echo"/>
+       </SimpleAttributeDefinition>
+       
+       <SimpleAttributeDefinition id="urn:mace:eduPerson:1.0:eduPersonEntitlement">
+               <DataConnectorDependency requires="echo2"/>
+       </SimpleAttributeDefinition>
+       
+       <SimpleAttributeDefinition id="urn:mace:eduPerson:1.0:eduPersonAffiliation">
+               <DataConnectorDependency requires="echo3"/>
+       </SimpleAttributeDefinition>
+       
+       <CustomDataConnector id="echo" cacheTime="1800000"
+               class="edu.internet2.middleware.shibboleth.aa.attrresolv.provider.SampleConnector" />
+       
+       <CustomDataConnector id="echo2" cacheTime="1800000"
+               class="edu.internet2.middleware.shibboleth.aa.attrresolv.provider.SampleConnector" />
+               
+       <CustomDataConnector id="echo3" cacheTime="1800000"
+               class="edu.internet2.middleware.shibboleth.aa.attrresolv.provider.SampleConnector" />
+
+</AttributeResolver>
\ No newline at end of file
diff --git a/data/resolver9.xml b/data/resolver9.xml
new file mode 100644 (file)
index 0000000..c64dcf7
--- /dev/null
@@ -0,0 +1,14 @@
+<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:eduPerson:1.0:eduPersonScopedAffiliation" smartScope="example.edu">
+               <AttributeDependency requires="urn:mace:eduPerson:1.0:eduPersonAffiliation"/>
+       </SimpleAttributeDefinition>
+
+       <SimpleAttributeDefinition id="urn:mace:eduPerson:1.0: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 2ff5e8f..1891bba 100644 (file)
@@ -274,4 +274,86 @@ public class ResolverTests extends TestCase {
                }
        }
 
+       public void testMultipleDataConnectors() {
+
+               try {
+                       Properties props = new Properties();
+                       File file = new File("data/resolver8.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:eduPerson:1.0:eduPersonPrincipalName"),
+                                               new AAAttribute("urn:mace:eduPerson:1.0:eduPersonAffiliation"),
+                                               new AAAttribute("urn:mace:eduPerson:1.0:eduPersonEntitlement")});
+
+                       AAAttributeSet outputAttributes =
+                               new AAAttributeSet(
+                                       new AAAttribute[] {
+                                               new AAAttribute(
+                                                       "urn:mace:eduPerson:1.0:eduPersonPrincipalName",
+                                                       new Object[] { "mytestuser@example.edu" },
+                                                       new ScopedStringValueHandler("example.edu")),
+                                               new AAAttribute("urn:mace:eduPerson:1.0:eduPersonAffiliation", new Object[] { "member" }),
+                                               new AAAttribute(
+                                                       "urn:mace:eduPerson:1.0:eduPersonEntitlement",
+                                                       new Object[] { "urn:mace:example.edu:exampleEntitlement" })
+                                               });
+
+                       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());
+               }
+       }
+       
+       public void testAttributeDependency() {
+
+               try {
+                       Properties props = new Properties();
+                       File file = new File("data/resolver9.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:eduPerson:1.0:eduPersonScopedAffiliation")});
+
+                       AAAttributeSet outputAttributes =
+                               new AAAttributeSet(
+                                       new AAAttribute[] {
+                                                new AAAttribute(
+                                                       "urn:mace:eduPerson:1.0:eduPersonScopedAffiliation",
+                                                       new Object[] { "member@example.edu" },
+                                                       new ScopedStringValueHandler("example.edu"))
+                                               });
+
+                       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());
+               }
+       }
+
+
 }