@@ -25,6 +25,7 @@ def enforcer(app_fixture):
2525 s .add (CasbinRule (ptype = "p" , v0 = "data2_admin" , v1 = "/item" , v2 = "GET" ))
2626 s .add (CasbinRule (ptype = "g" , v0 = "alice" , v1 = "data2_admin" ))
2727 s .add (CasbinRule (ptype = "g" , v0 = "users" , v1 = "data2_admin" ))
28+ s .add (CasbinRule (ptype = "g" , v0 = "group with space" , v1 = "data2_admin" ))
2829 s .commit ()
2930 s .close ()
3031
@@ -57,10 +58,12 @@ def update_callback(self):
5758 ("X-User" , "bob" , "POST" , 401 , None ),
5859 ("X-User" , "bob" , "DELETE" , 401 , None ),
5960 ("X-Idp-Groups" , "admin" , "GET" , 401 , "X-User" ),
60- ("X-Idp-Groups" , "users" , "GET" , 200 , None ),
61+ ("X-Idp-Groups" , "group with space, users" , "GET" , 200 , None ),
6162 ("X-Idp-Groups" , "noexist,testnoexist,users" , "GET" , 200 , None ),
6263 # ("X-Idp-Groups", "noexist testnoexist users", "GET", 200, None),
6364 ("X-Idp-Groups" , "noexist, testnoexist, users" , "GET" , 200 , None ),
65+ ("X-Idp-Groups" , "group with space" , "GET" , 200 , None ),
66+ ("X-Idp-Groups" , "somegroup, group with space" , "GET" , 200 , None ),
6467 ("Authorization" , "Basic Ym9iOnBhc3N3b3Jk" , "GET" , 200 , "Authorization" ),
6568 ("Authorization" , "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZGVudGl0eSI6ImJvYiJ9."
6669 "LM-CqxAM2MtT2uT3AO69rZ3WJ81nnyMQicizh4oqBwk" , "GET" , 200 , None ),
@@ -214,7 +217,8 @@ def owner_loader():
214217 ("noexist, testnoexist, users" , ["noexist" , "testnoexist" , "users" ]),
215218 ("noexist, testnoexist, users" , ["noexist" , "testnoexist" , "users" ]),
216219 ("somegroup, group with space" , ["somegroup" , "group with space" ]),
217- ("group with space" , ["group with space" ])
220+ ("group with space" , ["group with space" ]),
221+ ("group 'with, space" , ["group 'with" , "space" ])
218222 ]
219223)
220224def test_sanitize_group_headers (header_string , expected_list ):
@@ -229,6 +233,13 @@ def test_sanitize_group_headers(header_string, expected_list):
229233 ("noexist testnoexist users" , ["noexist" , "testnoexist" , "users" ]),
230234 ("noexist, testnoexist, users" , ["noexist," , "testnoexist," , "users" ]),
231235 ("somegroup, group with space" , ["somegroup," , "group" , "with" , "space" ]),
236+ ('"agroup" "delimited by" "spaces"' , ["agroup" , "delimited by" , "spaces" ]),
237+ ("'agroup' 'delimited by' 'spaces'" , ["agroup" , "delimited by" , "spaces" ]),
238+ ("group'with space" , ["group'with" , "space" ]),
239+ ("group' with space" , ["group'" , "with" , "space" ]),
240+ ("'group with' space" , ["'group" , "with'" , "space" ]), # quotes must be used on all groups, not only in 1
241+ ('"group with space"' , ["group with space" ]),
242+ ("'group with space'" , ["group with space" ]),
232243 ("group with space" , ["group" , "with" , "space" ])
233244 ]
234245)
0 commit comments