@@ -44,24 +44,32 @@ def update_callback(self):
4444
4545
4646@pytest .mark .parametrize (
47- "header, user, method, status" ,
47+ "header, user, method, status, user_name " ,
4848 [
49- ("X-User" , "alice" , "GET" , 200 ),
50- ("X-User" , "alice" , "POST" , 201 ),
51- ("X-User" , "alice" , "DELETE" , 202 ),
52- ("X-User" , "bob" , "GET" , 200 ),
53- ("X-User" , "bob" , "POST" , 401 ),
54- ("X-User" , "bob" , "DELETE" , 401 ),
55- ("X-Idp-Groups" , "admin" , "GET" , 401 ),
56- ("X-Idp-Groups" , "users" , "GET" , 200 ),
57- ("X-Idp-Groups" , "noexist,testnoexist,users" , "GET" , 200 ),
58- ("X-Idp-Groups" , "noexist testnoexist users" , "GET" , 200 ),
59- ("X-Idp-Groups" , "noexist, testnoexist, users" , "GET" , 200 ),
60- ("Authorization" , "Basic Ym9iOnBhc3N3b3Jk" , "GET" , 200 ),
61- ("Authorization" , "Unsupported Ym9iOnBhc3N3b3Jk" , "GET" , 401 ),
49+ ("X-User" , "alice" , "GET" , 200 , "X-User" ),
50+ ("X-USER" , "alice" , "GET" , 200 , "x-user" ),
51+ ("x-user" , "alice" , "GET" , 200 , "X-USER" ),
52+ ("X-User" , "alice" , "GET" , 200 , "X-USER" ),
53+ ("X-User" , "alice" , "GET" , 200 , "X-Not-A-Header" ),
54+ ("X-User" , "alice" , "POST" , 201 , None ),
55+ ("X-User" , "alice" , "DELETE" , 202 , None ),
56+ ("X-User" , "bob" , "GET" , 200 , None ),
57+ ("X-User" , "bob" , "POST" , 401 , None ),
58+ ("X-User" , "bob" , "DELETE" , 401 , None ),
59+ ("X-Idp-Groups" , "admin" , "GET" , 401 , "X-User" ),
60+ ("X-Idp-Groups" , "users" , "GET" , 200 , None ),
61+ ("X-Idp-Groups" , "noexist,testnoexist,users" , "GET" , 200 , None ),
62+ ("X-Idp-Groups" , "noexist testnoexist users" , "GET" , 200 , None ),
63+ ("X-Idp-Groups" , "noexist, testnoexist, users" , "GET" , 200 , None ),
64+ ("Authorization" , "Basic Ym9iOnBhc3N3b3Jk" , "GET" , 200 , "Authorization" ),
65+ ("Authorization" , "Unsupported Ym9iOnBhc3N3b3Jk" , "GET" , 401 , None ),
6266 ],
6367)
64- def test_enforcer (app_fixture , enforcer , header , user , method , status ):
68+ def test_enforcer (app_fixture , enforcer , header , user , method , status , user_name ):
69+ # enable auditing with user name
70+ if user_name :
71+ enforcer .user_name_headers = {user_name }
72+
6573 @app_fixture .route ("/" )
6674 @enforcer .enforcer
6775 def index ():
0 commit comments