@@ -59,7 +59,7 @@ def update_callback(self):
5959 ("X-Idp-Groups" , "admin" , "GET" , 401 , "X-User" ),
6060 ("X-Idp-Groups" , "users" , "GET" , 200 , None ),
6161 ("X-Idp-Groups" , "noexist,testnoexist,users" , "GET" , 200 , None ),
62- ("X-Idp-Groups" , "noexist testnoexist users" , "GET" , 200 , None ),
62+ # ("X-Idp-Groups", "noexist testnoexist users", "GET", 200, None),
6363 ("X-Idp-Groups" , "noexist, testnoexist, users" , "GET" , 200 , None ),
6464 ("Authorization" , "Basic Ym9iOnBhc3N3b3Jk" , "GET" , 200 , "Authorization" ),
6565 ("Authorization" , "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZGVudGl0eSI6ImJvYiJ9."
@@ -205,3 +205,33 @@ def owner_loader():
205205 caller = getattr (c , method .lower ())
206206 rv = caller ("/item" )
207207 assert rv .status_code == status
208+
209+
210+ @pytest .mark .parametrize (
211+ "header_string, expected_list" ,
212+ [
213+ ("noexist,testnoexist,users " , ["noexist" , "testnoexist" , "users" ]),
214+ ("noexist, testnoexist, users" , ["noexist" , "testnoexist" , "users" ]),
215+ ("noexist, testnoexist, users" , ["noexist" , "testnoexist" , "users" ]),
216+ ("somegroup, group with space" , ["somegroup" , "group with space" ]),
217+ ("group with space" , ["group with space" ])
218+ ]
219+ )
220+ def test_sanitize_group_headers (header_string , expected_list ):
221+ header_list = CasbinEnforcer .sanitize_group_headers (header_string )
222+ assert header_list == expected_list
223+
224+
225+ @pytest .mark .parametrize (
226+ "header_string, expected_list" ,
227+ [
228+ ("noexist testnoexist users " , ["noexist" , "testnoexist" , "users" ]),
229+ ("noexist testnoexist users" , ["noexist" , "testnoexist" , "users" ]),
230+ ("noexist, testnoexist, users" , ["noexist," , "testnoexist," , "users" ]),
231+ ("somegroup, group with space" , ["somegroup," , "group" , "with" , "space" ]),
232+ ("group with space" , ["group" , "with" , "space" ])
233+ ]
234+ )
235+ def test_sanitize_group_headers_with_whitespace (header_string , expected_list ):
236+ header_list = CasbinEnforcer .sanitize_group_headers (header_string , ' ' )
237+ assert header_list == expected_list
0 commit comments