77from saml2 .ident import IdentDB
88from saml2 .assertion import Policy
99
10- def _eq (l1 ,l2 ):
10+ from pathutils import full_path
11+
12+
13+ def _eq (l1 , l2 ):
1114 return set (l1 ) == set (l2 )
1215
16+
1317CONFIG = IdPConfig ().load ({
14- "entityid" : "urn:mace:example.com:idp:2" ,
15- "name" : "test" ,
18+ "entityid" : "urn:mace:example.com:idp:2" ,
19+ "name" : "test" ,
1620 "service" : {
1721 "idp" : {
18- "endpoints" : {
19- "single_sign_on_service" : ["http://idp.example.org/" ],
20- },
22+ "endpoints" : {
23+ "single_sign_on_service" : ["http://idp.example.org/" ],
24+ },
2125 "policy" : {
2226 "default" : {
23- "lifetime" : {"minutes" :15 },
24- "attribute_restrictions" : None , # means all I have
25- "name_form" : "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
27+ "lifetime" : {"minutes" : 15 },
28+ "attribute_restrictions" : None , # means all I have
29+ "name_form" :
30+ "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ,
2631 "nameid_format" : NAMEID_FORMAT_PERSISTENT
2732 }
2833 }
2934 }
3035 },
31- "virtual_organization" : {
32- "http://vo.example.org/biomed" :{
33- "nameid_format" : "urn:oid:2.16.756.1.2.5.1.1.1-NameID" ,
36+ "virtual_organization" : {
37+ "http://vo.example.org/biomed" : {
38+ "nameid_format" : "urn:oid:2.16.756.1.2.5.1.1.1-NameID" ,
3439 "common_identifier" : "uid" ,
3540 },
36- "http://vo.example.org/design" :{
37- "nameid_format" : NAMEID_FORMAT_PERSISTENT ,
41+ "http://vo.example.org/design" : {
42+ "nameid_format" : NAMEID_FORMAT_PERSISTENT ,
3843 "common_identifier" : "uid" ,
3944 }
4045 }
@@ -53,13 +58,14 @@ def _eq(l1,l2):
5358"""
5459
5560
56- class TestIdentifier () :
61+ class TestIdentifier :
5762 def setup_class (self ):
58- try :
59- os .remove ("subject.db.db" )
60- except :
61- pass
62- self .id = IdentDB ("subject.db" , "example.com" , "example" )
63+ for extension in ('.db' , '.dir' , '.dat' , '.bak' ):
64+ try :
65+ os .remove (full_path ("subject.db{}" .format (extension )))
66+ except (OSError , IOError ):
67+ pass
68+ self .id = IdentDB (full_path ("subject.db" ), "example.com" , "example" )
6369
6470 def test_persistent_1 (self ):
6571 policy = Policy ({
@@ -80,9 +86,9 @@ def test_persistent_1(self):
8086 assert nameid .sp_name_qualifier == "urn:mace:example.com:sp:1"
8187 assert nameid .format == NAMEID_FORMAT_PERSISTENT
8288
83- id = self .id .find_local_id (nameid )
89+ id_ = self .id .find_local_id (nameid )
8490
85- assert id == "foobar"
91+ assert id_ == "foobar"
8692
8793 def test_persistent_2 (self ):
8894 userid = 'foobar'
@@ -161,7 +167,6 @@ def test_vo_2(self):
161167 assert nameid .format == NAMEID_FORMAT_PERSISTENT
162168 assert nameid .text != "foobar01"
163169
164-
165170 def test_persistent_nameid (self ):
166171 sp_id = "urn:mace:umu.se:sp"
167172 nameid = self .id .persistent_nameid ("abcd0001" , sp_id )
@@ -187,6 +192,5 @@ def test_transient_nameid(self):
187192 assert nameid .text .strip () != nameid2 .text .strip ()
188193
189194 def teardown_class (self ):
190- if os .path .exists ("subject.db" ):
191- os .unlink ("subject.db" )
192-
195+ if os .path .exists (full_path ("subject.db" )):
196+ os .unlink (full_path ("subject.db" ))
0 commit comments