Name change on function. Changed number of arguments on Identifier. A couple of more tests

This commit is contained in:
Roland Hedberg
2010-10-13 16:29:58 +02:00
parent 3cbe3074fc
commit 98e87c986f
4 changed files with 51 additions and 7 deletions

View File

@@ -54,8 +54,7 @@ NAME_ID_POLICY_2 = """<?xml version="1.0" encoding="utf-8"?>
class TestIdentifier(): class TestIdentifier():
def setup_class(self): def setup_class(self):
self.id = Identifier("subject.db", CONFIG["entityid"], self.id = Identifier("subject.db", CONFIG.vo_conf)
CONFIG.vo_conf)
def test_persistent_1(self): def test_persistent_1(self):
policy = Policy({ policy = Policy({
@@ -74,7 +73,7 @@ class TestIdentifier():
assert _eq(nameid.keys(), ['text', 'sp_provided_id', assert _eq(nameid.keys(), ['text', 'sp_provided_id',
'sp_name_qualifier', 'name_qualifier', 'format']) 'sp_name_qualifier', 'name_qualifier', 'format'])
assert _eq(nameid.keyswv(), ['format', 'text', 'sp_name_qualifier']) assert _eq(nameid.keyswv(), ['format', 'text', 'sp_name_qualifier'])
assert nameid.sp_name_qualifier == CONFIG["entityid"] assert nameid.sp_name_qualifier == "urn:mace:example.com:sp:1"
assert nameid.format == NAMEID_FORMAT_PERSISTENT assert nameid.format == NAMEID_FORMAT_PERSISTENT
nameid_2 = self.id.construct_nameid(policy, "foobar", nameid_2 = self.id.construct_nameid(policy, "foobar",

View File

@@ -22,7 +22,9 @@ def _eq(l1,l2):
class TestResponse: class TestResponse:
def setup_class(self): def setup_class(self):
server = Server("idp.config") server = Server("idp.config")
name_id = server.ident.temporary_nameid() name_id = server.ident.transient_nameid(
"urn:mace:example.com:saml:roland:sp",
"id12")
self._resp_ = server.do_response( self._resp_ = server.do_response(
"id12", # in_response_to "id12", # in_response_to

View File

@@ -17,7 +17,8 @@ def _eq(l1,l2):
class TestAuthnResponse: class TestAuthnResponse:
def setup_class(self): def setup_class(self):
server = Server("idp.config") server = Server("idp.config")
name_id = server.ident.temporary_nameid() name_id = server.ident.transient_nameid(
"urn:mace:example.com:saml:roland:sp","id12")
self._resp_ = server.do_response( self._resp_ = server.do_response(
"id12", # in_response_to "id12", # in_response_to

View File

@@ -14,10 +14,48 @@ from saml2 import BINDING_HTTP_POST
from py.test import raises from py.test import raises
import shelve import shelve
import re import re
import os
def _eq(l1,l2): def _eq(l1,l2):
return set(l1) == set(l2) return set(l1) == set(l2)
class TestIdentifier():
def setup_class(self):
self.ident = Identifier("foobar.db")
def test_persistent_nameid(self):
sp_id = "urn:mace:umu.se:sp"
nameid = self.ident.persistent_nameid(sp_id, "abcd0001")
remote_id = nameid.text.strip()
print remote_id
print self.ident.map
local = self.ident.local_name(sp_id, remote_id)
assert local == "abcd0001"
assert self.ident.local_name(sp_id, "pseudo random string") == None
assert self.ident.local_name(sp_id+":x", remote_id) == None
# Always get the same
nameid2 = self.ident.persistent_nameid(sp_id, "abcd0001")
assert nameid.text.strip() == nameid2.text.strip()
def test_transient_nameid(self):
sp_id = "urn:mace:umu.se:sp"
nameid = self.ident.transient_nameid(sp_id, "abcd0001")
remote_id = nameid.text.strip()
print remote_id
print self.ident.map
local = self.ident.local_name(sp_id, remote_id)
assert local == "abcd0001"
assert self.ident.local_name(sp_id, "pseudo random string") == None
assert self.ident.local_name(sp_id+":x", remote_id) == None
# Getting a new, means really getting a new !
nameid2 = self.ident.transient_nameid(sp_id, "abcd0001")
assert nameid.text.strip() != nameid2.text.strip()
def teardown_class(self):
os.unlink("foobar.db")
class TestServer1(): class TestServer1():
def setup_class(self): def setup_class(self):
self.server = Server("idp.config") self.server = Server("idp.config")
@@ -165,7 +203,9 @@ class TestServer1():
assert response["sp_entity_id"] == "urn:mace:example.com:saml:roland:sp" assert response["sp_entity_id"] == "urn:mace:example.com:saml:roland:sp"
def test_sso_response_with_identity(self): def test_sso_response_with_identity(self):
name_id = self.server.ident.temporary_nameid() name_id = self.server.ident.transient_nameid(
"urn:mace:example.com:saml:roland:sp",
"id12")
resp = self.server.do_response( resp = self.server.do_response(
"id12", # in_response_to "id12", # in_response_to
"http://localhost:8087/", # consumer_url "http://localhost:8087/", # consumer_url
@@ -273,7 +313,9 @@ class TestServer1():
assert len(astate.attribute) == 3 assert len(astate.attribute) == 3
def test_signed_response(self): def test_signed_response(self):
name_id = self.server.ident.temporary_nameid() name_id = self.server.ident.transient_nameid(
"urn:mace:example.com:saml:roland:sp",
"id12")
signed_resp = self.server.do_response( signed_resp = self.server.do_response(
"id12", # in_response_to "id12", # in_response_to