From bf93273fdef0877a4eb65a9843a7ecff988c2974 Mon Sep 17 00:00:00 2001 From: Roland Hedberg Date: Thu, 11 Mar 2010 20:55:33 +0100 Subject: [PATCH] Also IdP configuring, soon to be also for AAs --- tests/test_config.py | 63 ++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index 5edcce8..a1e709c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -47,12 +47,33 @@ sp2 = { "xmlsec_binary" : "/opt/local/bin/xmlsec1", } +IDP1 = { + "entityid" : "urn:mace:umu.se:saml:roland:idp", + "service": { + "idp":{ + "name" : "Rolands IdP", + "url" : "http://localhost:8088/", + "assertions":{ + "default": { + "attribute_restrictions": { + "givenName": None, + "surName": None, + "eduPersonAffiliation": ["(member|staff)"], + "mail": [".*@example.com"], + } + }, + "urn:mace:umu.se:saml:roland:sp": None + } + } + }, + "xmlsec_binary" : "/usr/local/bin/xmlsec1", +} + def _eq(l1,l2): return set(l1) == set(l2) def test_1(): - c = Config() - c.load(sp1) + c = Config().load(sp1) print c service = c["service"] @@ -67,8 +88,7 @@ def test_1(): assert sp["idp"].values() == ["http://localhost:8088/sso/"] def test_2(): - c = Config() - c.load(sp2) + c = Config().load(sp2) print c service = c["service"] @@ -131,23 +151,22 @@ def test_minimum(): c = Config().load(minimum) assert c != None - -def test_(): - minimum = { - "entityid" : "urn:mace:example.com:saml:roland:sp", - "service": { - "sp": { - "url" : "http://sp.example.org/", - "name" : "test", - "idp": { - "" : "https://example.com/idp/SSOService.php", - }, - } - }, - "xmlsec_binary" : "/usr/local/bin/xmlsec1", - } - - c = Config().load(minimum) - assert c != None +def test_idp(): + c = Config().load(IDP1) + print c + service = c["service"] + + assert service.keys() == ["idp"] + idp = service["idp"] + assert _eq(idp.keys(),['url', 'name', 'assertions']) + + assert idp["url"] == "http://localhost:8088/" + + default_attribute_restrictions = idp["assertions"]["default"][ + "attribute_restrictions"] + + assert default_attribute_restrictions[ + "eduPersonAffiliation"][0].match("staff") + \ No newline at end of file