From 0ba327d6eb28dc1a13326da194df56f1af543253 Mon Sep 17 00:00:00 2001 From: Roland Hedberg Date: Thu, 31 Jan 2013 12:16:25 +0100 Subject: [PATCH] Fixed some tests. --- tests/idp_all_conf.py | 5 ++++- tests/test_30_mdstore.py | 7 ++++++- tests/test_50_server.py | 14 +++++++------- tests/test_51_client.py | 8 ++++---- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/idp_all_conf.py b/tests/idp_all_conf.py index b2d306b..aceea75 100644 --- a/tests/idp_all_conf.py +++ b/tests/idp_all_conf.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + from saml2 import BINDING_SOAP, BINDING_URI from saml2 import BINDING_HTTP_REDIRECT from saml2 import BINDING_HTTP_POST @@ -98,7 +101,7 @@ CONFIG = { "attribute_map_dir" : "attributemaps", "organization": { "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", }, "contact_person": [{ diff --git a/tests/test_30_mdstore.py b/tests/test_30_mdstore.py index 0f3befe..7400fe8 100644 --- a/tests/test_30_mdstore.py +++ b/tests/test_30_mdstore.py @@ -20,6 +20,7 @@ from saml2.extension import idpdisc from saml2.extension import dri from saml2.extension import mdattr from saml2.extension import ui +from saml2.s_utils import UnknownPrincipal import xmldsig import xmlenc @@ -123,7 +124,11 @@ def test_incommon_1(): idps = mds.with_descriptor("idpsso") print idps.keys() 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') assert len(idpsso) == 1 print idpsso diff --git a/tests/test_50_server.py b/tests/test_50_server.py index 511734e..eea9c8a 100644 --- a/tests/test_50_server.py +++ b/tests/test_50_server.py @@ -6,12 +6,11 @@ from saml2.saml import AUTHN_PASSWORD from saml2.samlp import response_from_string from saml2.server import Server -from saml2.ident import IdentDB from saml2 import samlp, saml, client, config from saml2 import s_utils from saml2 import sigver 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.soap import make_soap_enveloped_saml_thingy from saml2 import BINDING_HTTP_POST, BINDING_HTTP_REDIRECT @@ -208,6 +207,7 @@ class TestServer1(): print attribute_statement assert len(attribute_statement.attribute) == 5 # Pick out one attribute + attr = None for attr in attribute_statement.attribute: if attr.friendly_name == "edupersonentitlement": break @@ -400,13 +400,12 @@ class TestServer2(): def teardown_class(self): 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") print aa_policy.__dict__ - response = self.server.create_aa_response("aaa", + response = self.server.create_attribute_response(IDENTITY.copy(), "aaa", "http://example.com/sp/", - "urn:mace:example.com:sp:1", - IDENTITY.copy()) + "urn:mace:example.com:sp:1") assert response is not None assert response.destination == "http://example.com/sp/" @@ -455,7 +454,8 @@ class TestServerLogout(): bindings = [BINDING_HTTP_REDIRECT] response = server.create_logout_response(request, bindings) binding, destination = server.pick_binding("single_logout_service", - None, "spsso", request) + bindings, "spsso", + request) http_args = server.apply_binding(binding, "%s" % response, destination, "relay_state", response=True) diff --git a/tests/test_51_client.py b/tests/test_51_client.py index 83a70a4..fd563d9 100644 --- a/tests/test_51_client.py +++ b/tests/test_51_client.py @@ -67,7 +67,7 @@ class TestClient: req = self.client.create_attribute_query( "https://idp.example.com/idp/", "E8042FB4-4D5B-48C3-8E14-8EDD852790DD", - nameid_format=saml.NAMEID_FORMAT_PERSISTENT, + format=saml.NAMEID_FORMAT_PERSISTENT, id="id1") reqstr = "%s" % req.to_string() @@ -109,7 +109,7 @@ class TestClient: ("urn:oid:1.2.840.113549.1.9.1", "urn:oasis:names:tc:SAML:2.0:attrname-format:uri"):None, }, - nameid_format=saml.NAMEID_FORMAT_PERSISTENT, + format=saml.NAMEID_FORMAT_PERSISTENT, id="id1") print req.to_string() @@ -143,7 +143,7 @@ class TestClient: req = self.client.create_attribute_query( "https://aai-demo-idp.switch.ch/idp/shibboleth", "_e7b68a04488f715cda642fbdd90099f5", - nameid_format=saml.NAMEID_FORMAT_TRANSIENT, + format=saml.NAMEID_FORMAT_TRANSIENT, id="id1") assert isinstance(req, samlp.AttributeQuery) @@ -198,7 +198,7 @@ class TestClient: ar_str = "%s" % self.client.create_authn_request( "http://www.example.com/sso", "urn:mace:example.com:it:tek", # vo - nameid_format=NAMEID_FORMAT_PERSISTENT, + format=NAMEID_FORMAT_PERSISTENT, id="666") ar = samlp.authn_request_from_string(ar_str)