Added jUnit test for bug where ARP engine was sometimes returning attributes with...
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 28 Oct 2003 17:34:39 +0000 (17:34 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 28 Oct 2003 17:34:39 +0000 (17:34 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@779 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

tests/edu/internet2/middleware/shibboleth/aa/arp/ArpTests.java

index 46da1e5..31f8175 100755 (executable)
@@ -610,6 +610,7 @@ public class ArpTests extends TestCase {
                        arpApplicationTest21(repository, props, parser);
                        arpApplicationTest22(repository, props, parser);
                        arpApplicationTest23(repository, props, parser);
+                       arpApplicationTest24(repository, props, parser);
 
                } catch (Exception e) {
                        e.printStackTrace();
@@ -1951,5 +1952,61 @@ public class ArpTests extends TestCase {
 
                assertEquals("ARP application test 23: ARP not applied as expected.", inputSet, releaseSet);
        }
+       
+       /**
+        * ARPs: A site ARP only
+        * Target: Specific shar, Specific resource
+        * Attribute: No matches on specific values should yield no attribute
+        */
+       void arpApplicationTest24(ArpRepository repository, Properties props, DOMParser parser) throws Exception {
+
+               //Gather the Input
+               String rawArp =
+                       "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+                               + "<AttributeReleasePolicy xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:mace:shibboleth:arp:1.0\" xsi:schemaLocation=\"urn:mace:shibboleth:arp:1.0 shibboleth-arp-1.0.xsd\">"
+                               + "                     <Rule>"
+                               + "                             <Target>"
+                               + "                                     <Requester>shar.example.edu</Requester>"
+                               + "                                     <Resource>http://www.example.edu/</Resource>"
+                               + "                             </Target>"
+                               + "                             <Attribute name=\"urn:mace:dir:attribute-def:eduPersonAffiliation\">"
+                               + "                                     <AnyValue release=\"permit\" />"
+                               + "                             </Attribute>"
+                               + "                             <Attribute name=\"urn:mace:dir:attribute-def:eduPersonEntitlement\">"
+                               + "                                     <Value release=\"permit\">urn:x:foo</Value>"
+                               + "                             </Attribute>"
+                               + "                     </Rule>"
+                               + "     </AttributeReleasePolicy>";
+
+               Principal principal1 = new AuthNPrincipal("Test2Principal");
+               URL url1 = new URL("http://www.example.edu/index.html");
+               AAAttributeSet inputSet =
+                       new AAAttributeSet(
+                               new AAAttribute[] {
+                                       new AAAttribute(
+                                               "urn:mace:dir:attribute-def:eduPersonEntitlement",
+                                               new Object[] { "urn:x:bar", "urn:x:adagio"}),
+                                       new AAAttribute(
+                                               "urn:mace:dir:attribute-def:eduPersonAffiliation",
+                                               new Object[] { "member" })
+               });
+               AAAttributeSet releaseSet =
+                       new AAAttributeSet(
+                               new AAAttribute(
+                                       "urn:mace:dir:attribute-def:eduPersonAffiliation",
+                                       new Object[] { "member" }));
+
+               //Setup the engine
+               parser.parse(new InputSource(new StringReader(rawArp)));
+               Arp siteArp = new Arp();
+               siteArp.marshall(parser.getDocument().getDocumentElement());
+               repository.update(siteArp);
+               ArpEngine engine = new ArpEngine(repository, props);
+
+               //Apply the ARP
+               engine.filterAttributes(inputSet, principal1, "shar.example.edu", url1);
+
+               assertEquals("ARP application test 24: ARP not applied as expected.", inputSet, releaseSet);
+       }
 
 }