5
5
from attribute_statement_data import *
6
6
7
7
from pathutils import full_path
8
- from saml2 .attribute_converter import AttributeConverterNOOP , to_local
8
+ from saml2 .attribute_converter import AttributeConverterNOOP
9
+ from saml2 .attribute_converter import to_local
9
10
10
11
11
12
def _eq (l1 ,l2 ):
@@ -58,11 +59,8 @@ def test_ava_fro_2(self):
58
59
ava .update (ac .fro (ats ))
59
60
60
61
print ava .keys ()
61
- assert _eq (ava .keys (),['uid' , 'swissedupersonuniqueid' ,
62
- 'swissedupersonhomeorganizationtype' ,
63
- 'eduPersonEntitlement' , 'eduPersonAffiliation' ,
64
- 'sn' , 'mail' , 'swissedupersonhomeorganization' ,
65
- 'givenName' ])
62
+ assert _eq (ava .keys (), ['eduPersonEntitlement' , 'eduPersonAffiliation' ,
63
+ 'uid' , 'mail' , 'givenName' , 'sn' ])
66
64
67
65
def test_to_attrstat_1 (self ):
68
66
ava = { "givenName" : "Roland" , "sn" : "Hedberg" }
@@ -131,22 +129,22 @@ def test_to_local_name(self):
131
129
132
130
assert _eq (lan , ['sn' , 'givenName' , 'title' ])
133
131
134
- def test_ava_fro_1 (self ):
135
-
136
- attr = [saml .Attribute (friendly_name = "surName" ,
137
- name = "urn:oid:2.5.4.4" ,
138
- name_format = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ),
139
- saml .Attribute (friendly_name = "efternamn" ,
140
- name = "urn:oid:2.5.4.42" ,
141
- name_format = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ),
142
- saml .Attribute (friendly_name = "titel" ,
143
- name = "urn:oid:2.5.4.12" ,
144
- name_format = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" )]
145
-
146
- result = attribute_converter .ava_fro (self .acs , attr )
147
-
148
- print result
149
- assert result == {'givenName' : [], 'sn' : [], 'title' : []}
132
+ # def test_ava_fro_1(self):
133
+ #
134
+ # attr = [saml.Attribute(friendly_name="surName",
135
+ # name="urn:oid:2.5.4.4",
136
+ # name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
137
+ # saml.Attribute(friendly_name="efternamn",
138
+ # name="urn:oid:2.5.4.42",
139
+ # name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
140
+ # saml.Attribute(friendly_name="titel",
141
+ # name="urn:oid:2.5.4.12",
142
+ # name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")]
143
+ #
144
+ # result = attribute_converter.ava_fro(self.acs, attr)
145
+ #
146
+ # print result
147
+ # assert result == {'givenName': [], 'sn': [], 'title': []}
150
148
151
149
def test_to_local_name_from_basic (self ):
152
150
attr = [saml .Attribute (
@@ -172,6 +170,21 @@ def test_unspecified_name_format(self):
172
170
ava = to_local (self .acs , ats )
173
171
assert ava == {'user_id' : ['bob' ], 'NameID' : ['bobsnameagain' ]}
174
172
173
+ def test_mixed_attributes_1 (self ):
174
+ ats = saml .attribute_statement_from_string (STATEMENT_MIXED )
175
+ ava = to_local (self .acs , ats )
176
+ assert ava == {'eduPersonAffiliation' : ['staff' ],
177
+ 'givenName' : ['Roland' ], 'sn' : ['Hedberg' ],
178
+ 'uid' : ['demouser' ], 'user_id' : ['bob' ]}
179
+
180
+ # Allow unknown
181
+ ava = to_local (self .acs , ats , True )
182
+ assert ava == {'eduPersonAffiliation' : ['staff' ],
183
+ 'givenName' : ['Roland' ], 'sn' : ['Hedberg' ],
184
+ 'swissEduPersonHomeOrganizationType' : ['others' ],
185
+ 'uid' : ['demouser' ], 'urn:example:com:foo' : ['Thing' ],
186
+ 'user_id' : ['bob' ]}
187
+
175
188
176
189
def test_noop_attribute_conversion ():
177
190
ava = {"urn:oid:2.5.4.4" : "Roland" , "urn:oid:2.5.4.42" : "Hedberg" }
@@ -193,5 +206,5 @@ def test_noop_attribute_conversion():
193
206
if __name__ == "__main__" :
194
207
t = TestAC ()
195
208
t .setup_class ()
196
- t .test_ava_fro_2 ()
209
+ t .test_mixed_attributes_1 ()
197
210
#test_noop_attribute_conversion()
0 commit comments