Fixed some tests.

This commit is contained in:
Roland Hedberg 2013-01-31 12:16:25 +01:00
parent 8057954688
commit 0ba327d6eb
4 changed files with 21 additions and 13 deletions

View File

@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from saml2 import BINDING_SOAP, BINDING_URI from saml2 import BINDING_SOAP, BINDING_URI
from saml2 import BINDING_HTTP_REDIRECT from saml2 import BINDING_HTTP_REDIRECT
from saml2 import BINDING_HTTP_POST from saml2 import BINDING_HTTP_POST
@ -98,7 +101,7 @@ CONFIG = {
"attribute_map_dir" : "attributemaps", "attribute_map_dir" : "attributemaps",
"organization": { "organization": {
"name": "Exempel AB", "name": "Exempel AB",
"display_name": [("Exempel AB","se"),("Example Co.","en")], "display_name": [("Exempel ÄB","se"),("Example Co.","en")],
"url":"http://www.example.com/roland", "url":"http://www.example.com/roland",
}, },
"contact_person": [{ "contact_person": [{

View File

@ -20,6 +20,7 @@ from saml2.extension import idpdisc
from saml2.extension import dri from saml2.extension import dri
from saml2.extension import mdattr from saml2.extension import mdattr
from saml2.extension import ui from saml2.extension import ui
from saml2.s_utils import UnknownPrincipal
import xmldsig import xmldsig
import xmlenc import xmlenc
@ -123,7 +124,11 @@ def test_incommon_1():
idps = mds.with_descriptor("idpsso") idps = mds.with_descriptor("idpsso")
print idps.keys() print idps.keys()
assert len(idps) == 53 # !!!!???? < 10% assert len(idps) == 53 # !!!!???? < 10%
assert mds.single_sign_on_service('urn:mace:incommon:uiuc.edu') == [] try:
_ = mds.single_sign_on_service('urn:mace:incommon:uiuc.edu')
except UnknownPrincipal:
pass
idpsso = mds.single_sign_on_service('urn:mace:incommon:alaska.edu') idpsso = mds.single_sign_on_service('urn:mace:incommon:alaska.edu')
assert len(idpsso) == 1 assert len(idpsso) == 1
print idpsso print idpsso

View File

@ -6,12 +6,11 @@ from saml2.saml import AUTHN_PASSWORD
from saml2.samlp import response_from_string from saml2.samlp import response_from_string
from saml2.server import Server from saml2.server import Server
from saml2.ident import IdentDB
from saml2 import samlp, saml, client, config from saml2 import samlp, saml, client, config
from saml2 import s_utils from saml2 import s_utils
from saml2 import sigver from saml2 import sigver
from saml2 import time_util from saml2 import time_util
from saml2.s_utils import OtherError from saml2.s_utils import OtherError, UnsupportedBinding
from saml2.s_utils import do_attribute_statement, factory from saml2.s_utils import do_attribute_statement, factory
from saml2.soap import make_soap_enveloped_saml_thingy from saml2.soap import make_soap_enveloped_saml_thingy
from saml2 import BINDING_HTTP_POST, BINDING_HTTP_REDIRECT from saml2 import BINDING_HTTP_POST, BINDING_HTTP_REDIRECT
@ -208,6 +207,7 @@ class TestServer1():
print attribute_statement print attribute_statement
assert len(attribute_statement.attribute) == 5 assert len(attribute_statement.attribute) == 5
# Pick out one attribute # Pick out one attribute
attr = None
for attr in attribute_statement.attribute: for attr in attribute_statement.attribute:
if attr.friendly_name == "edupersonentitlement": if attr.friendly_name == "edupersonentitlement":
break break
@ -400,13 +400,12 @@ class TestServer2():
def teardown_class(self): def teardown_class(self):
self.server.close_shelve_db() self.server.close_shelve_db()
def test_do_aa_reponse(self): def test_do_attribute_reponse(self):
aa_policy = self.server.config.getattr("policy", "idp") aa_policy = self.server.config.getattr("policy", "idp")
print aa_policy.__dict__ print aa_policy.__dict__
response = self.server.create_aa_response("aaa", response = self.server.create_attribute_response(IDENTITY.copy(), "aaa",
"http://example.com/sp/", "http://example.com/sp/",
"urn:mace:example.com:sp:1", "urn:mace:example.com:sp:1")
IDENTITY.copy())
assert response is not None assert response is not None
assert response.destination == "http://example.com/sp/" assert response.destination == "http://example.com/sp/"
@ -455,7 +454,8 @@ class TestServerLogout():
bindings = [BINDING_HTTP_REDIRECT] bindings = [BINDING_HTTP_REDIRECT]
response = server.create_logout_response(request, bindings) response = server.create_logout_response(request, bindings)
binding, destination = server.pick_binding("single_logout_service", binding, destination = server.pick_binding("single_logout_service",
None, "spsso", request) bindings, "spsso",
request)
http_args = server.apply_binding(binding, "%s" % response, destination, http_args = server.apply_binding(binding, "%s" % response, destination,
"relay_state", response=True) "relay_state", response=True)

View File

@ -67,7 +67,7 @@ class TestClient:
req = self.client.create_attribute_query( req = self.client.create_attribute_query(
"https://idp.example.com/idp/", "https://idp.example.com/idp/",
"E8042FB4-4D5B-48C3-8E14-8EDD852790DD", "E8042FB4-4D5B-48C3-8E14-8EDD852790DD",
nameid_format=saml.NAMEID_FORMAT_PERSISTENT, format=saml.NAMEID_FORMAT_PERSISTENT,
id="id1") id="id1")
reqstr = "%s" % req.to_string() reqstr = "%s" % req.to_string()
@ -109,7 +109,7 @@ class TestClient:
("urn:oid:1.2.840.113549.1.9.1", ("urn:oid:1.2.840.113549.1.9.1",
"urn:oasis:names:tc:SAML:2.0:attrname-format:uri"):None, "urn:oasis:names:tc:SAML:2.0:attrname-format:uri"):None,
}, },
nameid_format=saml.NAMEID_FORMAT_PERSISTENT, format=saml.NAMEID_FORMAT_PERSISTENT,
id="id1") id="id1")
print req.to_string() print req.to_string()
@ -143,7 +143,7 @@ class TestClient:
req = self.client.create_attribute_query( req = self.client.create_attribute_query(
"https://aai-demo-idp.switch.ch/idp/shibboleth", "https://aai-demo-idp.switch.ch/idp/shibboleth",
"_e7b68a04488f715cda642fbdd90099f5", "_e7b68a04488f715cda642fbdd90099f5",
nameid_format=saml.NAMEID_FORMAT_TRANSIENT, format=saml.NAMEID_FORMAT_TRANSIENT,
id="id1") id="id1")
assert isinstance(req, samlp.AttributeQuery) assert isinstance(req, samlp.AttributeQuery)
@ -198,7 +198,7 @@ class TestClient:
ar_str = "%s" % self.client.create_authn_request( ar_str = "%s" % self.client.create_authn_request(
"http://www.example.com/sso", "http://www.example.com/sso",
"urn:mace:example.com:it:tek", # vo "urn:mace:example.com:it:tek", # vo
nameid_format=NAMEID_FORMAT_PERSISTENT, format=NAMEID_FORMAT_PERSISTENT,
id="666") id="666")
ar = samlp.authn_request_from_string(ar_str) ar = samlp.authn_request_from_string(ar_str)