File tree 3 files changed +33
-7
lines changed
3 files changed +33
-7
lines changed Original file line number Diff line number Diff line change 1
1
"""Just importing federated boosts our coverage."""
2
- from uw_saml2 .idp import federated
2
+ from uw_saml2 .idp import federated , attribute
3
+ import pytest
3
4
4
5
5
- def test_cascadia_employee ():
6
- id_attribute = 'urn:mace:washington.edu:dir:attribute-def:stu-validationID'
7
- assert federated .CascadiaEmployeeIdp .id_attribute == id_attribute
6
+ @pytest .mark .parametrize ('student,employee' , [
7
+ (['loser' ], ['winner' ]),
8
+ (['winner' ], None ),
9
+ (None , ['winner' ]),
10
+ ([], ['winner' ]),
11
+ (['winner' ], [])
12
+ ])
13
+ def test_cascadia_employee_attributes (student , employee ):
14
+ """
15
+ Cascadia Employees should come across as such, but our test one comes
16
+ through as a student. This checks that if either one is set, we get
17
+ a value for remote_user. It's still entirely possible for student to
18
+ win out.
19
+ """
20
+ prefix = 'urn:mace:washington.edu:dir:attribute-def'
21
+ attrs = {}
22
+ if student is not None :
23
+ attrs [f'{ prefix } :stu-validationID' ] = student
24
+ if employee is not None :
25
+ attrs [f'{ prefix } :emp-validationID' ] = employee
26
+ mapped_attrs = dict (attribute .map (attrs , federated .CascadiaEmployeeIdp ))
27
+ assert mapped_attrs ['remote_user' ] == 'winner'
8
28
9
29
10
30
def test_scca_dynamic_entity_id ():
Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ def __init__(self, name):
24
24
25
25
def map (self , values ):
26
26
"""Return only the first value in a list of values."""
27
- return values and values [0 ]
27
+ if not values :
28
+ return None
29
+ return values [0 ]
28
30
29
31
30
32
class List (Attribute ):
Original file line number Diff line number Diff line change @@ -32,8 +32,12 @@ class CascadiaEmployeeIdp(CascadiaStudentIdp):
32
32
The only difference between an Cascadia Employee and a Student are the
33
33
IdP's endpoint. Even the id_attribute of 'stu-validationID' remains.
34
34
"""
35
- sso_url = ('https://idp.employee.cascadia.edu'
36
- '/idp/profile/SAML2/Redirect/SSO' )
35
+ _idp_url = 'https://idp.employee.cascadia.edu'
36
+ _attribute_prefix = 'urn:mace:washington.edu:dir:attribute-def'
37
+ sso_url = f'{ _idp_url } /idp/profile/SAML2/Redirect/SSO'
38
+ attribute_map = {
39
+ f'{ _attribute_prefix } :emp-validationID' : 'remote_user'
40
+ }
37
41
38
42
39
43
class CollegenetIdp (IdpConfig ):
You can’t perform that action at this time.
0 commit comments