7
7
from saml2 .ident import IdentDB
8
8
from saml2 .assertion import Policy
9
9
10
- def _eq (l1 ,l2 ):
10
+ from pathutils import full_path
11
+
12
+
13
+ def _eq (l1 , l2 ):
11
14
return set (l1 ) == set (l2 )
12
15
16
+
13
17
CONFIG = IdPConfig ().load ({
14
- "entityid" : "urn:mace:example.com:idp:2" ,
15
- "name" : "test" ,
18
+ "entityid" : "urn:mace:example.com:idp:2" ,
19
+ "name" : "test" ,
16
20
"service" : {
17
21
"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
+ },
21
25
"policy" : {
22
26
"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" ,
26
31
"nameid_format" : NAMEID_FORMAT_PERSISTENT
27
32
}
28
33
}
29
34
}
30
35
},
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" ,
34
39
"common_identifier" : "uid" ,
35
40
},
36
- "http://vo.example.org/design" :{
37
- "nameid_format" : NAMEID_FORMAT_PERSISTENT ,
41
+ "http://vo.example.org/design" : {
42
+ "nameid_format" : NAMEID_FORMAT_PERSISTENT ,
38
43
"common_identifier" : "uid" ,
39
44
}
40
45
}
@@ -53,13 +58,14 @@ def _eq(l1,l2):
53
58
"""
54
59
55
60
56
- class TestIdentifier () :
61
+ class TestIdentifier :
57
62
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" )
63
69
64
70
def test_persistent_1 (self ):
65
71
policy = Policy ({
@@ -80,9 +86,9 @@ def test_persistent_1(self):
80
86
assert nameid .sp_name_qualifier == "urn:mace:example.com:sp:1"
81
87
assert nameid .format == NAMEID_FORMAT_PERSISTENT
82
88
83
- id = self .id .find_local_id (nameid )
89
+ id_ = self .id .find_local_id (nameid )
84
90
85
- assert id == "foobar"
91
+ assert id_ == "foobar"
86
92
87
93
def test_persistent_2 (self ):
88
94
userid = 'foobar'
@@ -161,7 +167,6 @@ def test_vo_2(self):
161
167
assert nameid .format == NAMEID_FORMAT_PERSISTENT
162
168
assert nameid .text != "foobar01"
163
169
164
-
165
170
def test_persistent_nameid (self ):
166
171
sp_id = "urn:mace:umu.se:sp"
167
172
nameid = self .id .persistent_nameid ("abcd0001" , sp_id )
@@ -187,6 +192,5 @@ def test_transient_nameid(self):
187
192
assert nameid .text .strip () != nameid2 .text .strip ()
188
193
189
194
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