Added attribute resolver test.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 16 Apr 2003 21:49:31 +0000 (21:49 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 16 Apr 2003 21:49:31 +0000 (21:49 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@572 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

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

diff --git a/data/resolver7.xml b/data/resolver7.xml
new file mode 100644 (file)
index 0000000..3f4d30c
--- /dev/null
@@ -0,0 +1,10 @@
+<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="myAffiliation" sourceName="eduPersonAffiliation">
+               <DataConnectorDependency requires="echo"/>
+       </SimpleAttributeDefinition>
+       
+       <CustomDataConnector id="echo"
+               class="edu.internet2.middleware.shibboleth.aa.attrresolv.provider.SampleConnector" />
+
+</AttributeResolver>
\ No newline at end of file
index 25564ad..2ff5e8f 100644 (file)
@@ -229,20 +229,49 @@ public class ResolverTests extends TestCase {
        
        public void testFailToLoadCircularDependenciesDeeper() {
 
-                       try {
-                               Properties props = new Properties();
-                               File file = new File("data/resolver6.xml");
-                               props.setProperty(
-                                       "edu.internet2.middleware.shibboleth.aa.attrresolv.AttributeResolver.ResolverConfig",
-                                       file.toURL().toString());
-
-                               AttributeResolver ar = new AttributeResolver(props);
-                               fail("Attribute Resolver loaded even when no only PlugIns with circular dependencies were configured.");
-                       } catch (AttributeResolverException e) {
-                               //This exception should be thrown, ignoring
-                       } catch (MalformedURLException e) {
-                               fail("Error in test specification: " + e.getMessage());
-                       }
+               try {
+                       Properties props = new Properties();
+                       File file = new File("data/resolver6.xml");
+                       props.setProperty(
+                               "edu.internet2.middleware.shibboleth.aa.attrresolv.AttributeResolver.ResolverConfig",
+                               file.toURL().toString());
+
+                       AttributeResolver ar = new AttributeResolver(props);
+                       fail("Attribute Resolver loaded even when no only PlugIns with circular dependencies were configured.");
+               } catch (AttributeResolverException e) {
+                       //This exception should be thrown, ignoring
+               } catch (MalformedURLException e) {
+                       fail("Error in test specification: " + e.getMessage());
                }
+       }
+
+       public void testSourceNameMapping() {
+
+               try {
+                       Properties props = new Properties();
+                       File file = new File("data/resolver7.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("myAffiliation")});
+
+                       AAAttributeSet outputAttributes =
+                               new AAAttributeSet(new AAAttribute[] { new AAAttribute("myAffiliation", 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());
+               }
+       }
 
 }