Name change on function. Changed number of arguments on Identifier. A couple of more tests
This commit is contained in:
@@ -54,8 +54,7 @@ NAME_ID_POLICY_2 = """<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
class TestIdentifier():
|
||||
def setup_class(self):
|
||||
self.id = Identifier("subject.db", CONFIG["entityid"],
|
||||
CONFIG.vo_conf)
|
||||
self.id = Identifier("subject.db", CONFIG.vo_conf)
|
||||
|
||||
def test_persistent_1(self):
|
||||
policy = Policy({
|
||||
@@ -74,7 +73,7 @@ class TestIdentifier():
|
||||
assert _eq(nameid.keys(), ['text', 'sp_provided_id',
|
||||
'sp_name_qualifier', 'name_qualifier', 'format'])
|
||||
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
|
||||
|
||||
nameid_2 = self.id.construct_nameid(policy, "foobar",
|
||||
|
||||
@@ -22,7 +22,9 @@ def _eq(l1,l2):
|
||||
class TestResponse:
|
||||
def setup_class(self):
|
||||
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(
|
||||
"id12", # in_response_to
|
||||
|
||||
@@ -17,7 +17,8 @@ def _eq(l1,l2):
|
||||
class TestAuthnResponse:
|
||||
def setup_class(self):
|
||||
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(
|
||||
"id12", # in_response_to
|
||||
|
||||
@@ -14,10 +14,48 @@ from saml2 import BINDING_HTTP_POST
|
||||
from py.test import raises
|
||||
import shelve
|
||||
import re
|
||||
import os
|
||||
|
||||
def _eq(l1,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():
|
||||
def setup_class(self):
|
||||
self.server = Server("idp.config")
|
||||
@@ -165,7 +203,9 @@ class TestServer1():
|
||||
assert response["sp_entity_id"] == "urn:mace:example.com:saml:roland:sp"
|
||||
|
||||
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(
|
||||
"id12", # in_response_to
|
||||
"http://localhost:8087/", # consumer_url
|
||||
@@ -273,7 +313,9 @@ class TestServer1():
|
||||
assert len(astate.attribute) == 3
|
||||
|
||||
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(
|
||||
"id12", # in_response_to
|
||||
|
||||
Reference in New Issue
Block a user