From d70eab70c7a06ff7ae50566a7338ca181e91759c Mon Sep 17 00:00:00 2001 From: wassa Date: Thu, 16 Jan 2003 20:26:40 +0000 Subject: [PATCH] Added tests to the ARP filtering test suite for (multiple attributes) & (multiple rule matches).. git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@403 ab3bd59b-922f-494d-bb5f-6f0a3c29deca --- .../middleware/shibboleth/aa/arp/ArpTests.java | 138 ++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/src/edu/internet2/middleware/shibboleth/aa/arp/ArpTests.java b/src/edu/internet2/middleware/shibboleth/aa/arp/ArpTests.java index 5de29f0..ba66a82 100755 --- a/src/edu/internet2/middleware/shibboleth/aa/arp/ArpTests.java +++ b/src/edu/internet2/middleware/shibboleth/aa/arp/ArpTests.java @@ -479,6 +479,8 @@ public class ArpTests extends TestCase { arpApplicationTest14(repository, props, parser); arpApplicationTest15(repository, props, parser); arpApplicationTest16(repository, props, parser); + arpApplicationTest17(repository, props, parser); + arpApplicationTest18(repository, props, parser); } catch (Exception e) { e.printStackTrace(); @@ -1327,6 +1329,142 @@ public class ArpTests extends TestCase { new HashSet(Arrays.asList(new ArpAttribute[0]))); } + /** + * ARPs: A site ARP only + * Target: Multiple matching rules + * Attribute: various + */ + void arpApplicationTest17(ArpRepository repository, Properties props, DOMParser parser) + throws Exception { + + //Gather the Input + String rawArp = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " shar1.example.edu" + + " " + + " " + + " " + + " faculty@example.edu" + + " " + + " " + + " " + + " " + + " shar[1-9]\\.example\\.edu" + + " ^https?://.+\\.example\\.edu/.*$" + + " " + + " " + + " " + + " " + + " " + + " "; + + Principal principal1 = new AAPrincipal("TestPrincipal"); + URL url1 = new URL("https://www.example.edu/index.html"); + TestAttribute testAttribute1 = + new TestAttribute( + "urn:mace:eduPerson:1.0:eduPersonAffiliation", + new Object[] { "member@example.edu", "faculty@example.edu" }); + TestAttribute testAttribute2 = + new TestAttribute( + "urn:mace:eduPerson:1.0:eduPersonPrincipalName", + new Object[] { "wassa@columbia.edu" }); + TestAttribute filteredAttribute1 = + new TestAttribute( + "urn:mace:eduPerson:1.0:eduPersonAffiliation", + new Object[] { "member@example.edu" }); + + //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 + ArpAttribute[] releaseAttributes = + engine.filterAttributes( + new ArpAttribute[] { testAttribute1, testAttribute2 }, + principal1, + "shar1.example.edu", + url1); + + assertEquals( + "ARP application test 17: ARP not applied as expected.", + new HashSet(Arrays.asList(releaseAttributes)), + new HashSet(Arrays.asList(new ArpAttribute[] { testAttribute2, filteredAttribute1 } ))); + } + + /** + * ARPs: A site ARP only + * Target: Any + * Attribute: Any value release of two attributes in one rule + */ + void arpApplicationTest18(ArpRepository repository, Properties props, DOMParser parser) throws Exception { + + //Gather the Input + String rawArp = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " "; + + Principal principal1 = new AAPrincipal("TestPrincipal"); + URL url1 = new URL("http://www.example.edu/"); + TestAttribute testAttribute1 = + new TestAttribute( + "urn:mace:eduPerson:1.0:eduPersonAffiliation", + new Object[] { "member@example.edu", "faculty@example.edu" }); + TestAttribute testAttribute2 = + new TestAttribute( + "urn:mace:eduPerson:1.0:eduPersonPrincipalName", + new Object[] { "mehoehn@example.edu" }); + + //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 + ArpAttribute[] releaseAttributes = + engine.filterAttributes( + new ArpAttribute[] { testAttribute1, testAttribute2 }, + principal1, + "shar.example.edu", + url1); + + assertEquals( + "ARP application test 18: ARP not applied as expected.", + new HashSet(Arrays.asList(releaseAttributes)), + new HashSet(Arrays.asList(new ArpAttribute[] { testAttribute1, testAttribute2 }))); + } + + + + + public class TestAttribute implements ArpAttribute { private String name; private Object[] values; -- 1.7.10.4