@@ -25,6 +25,7 @@ def enforcer(app_fixture):
25
25
s .add (CasbinRule (ptype = "p" , v0 = "data2_admin" , v1 = "/item" , v2 = "GET" ))
26
26
s .add (CasbinRule (ptype = "g" , v0 = "alice" , v1 = "data2_admin" ))
27
27
s .add (CasbinRule (ptype = "g" , v0 = "users" , v1 = "data2_admin" ))
28
+ s .add (CasbinRule (ptype = "g" , v0 = "group with space" , v1 = "data2_admin" ))
28
29
s .commit ()
29
30
s .close ()
30
31
@@ -57,10 +58,12 @@ def update_callback(self):
57
58
("X-User" , "bob" , "POST" , 401 , None ),
58
59
("X-User" , "bob" , "DELETE" , 401 , None ),
59
60
("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 ),
61
62
("X-Idp-Groups" , "noexist,testnoexist,users" , "GET" , 200 , None ),
62
63
# ("X-Idp-Groups", "noexist testnoexist users", "GET", 200, None),
63
64
("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 ),
64
67
("Authorization" , "Basic Ym9iOnBhc3N3b3Jk" , "GET" , 200 , "Authorization" ),
65
68
("Authorization" , "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZGVudGl0eSI6ImJvYiJ9."
66
69
"LM-CqxAM2MtT2uT3AO69rZ3WJ81nnyMQicizh4oqBwk" , "GET" , 200 , None ),
@@ -214,7 +217,8 @@ def owner_loader():
214
217
("noexist, testnoexist, users" , ["noexist" , "testnoexist" , "users" ]),
215
218
("noexist, testnoexist, users" , ["noexist" , "testnoexist" , "users" ]),
216
219
("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" ])
218
222
]
219
223
)
220
224
def test_sanitize_group_headers (header_string , expected_list ):
@@ -229,6 +233,13 @@ def test_sanitize_group_headers(header_string, expected_list):
229
233
("noexist testnoexist users" , ["noexist" , "testnoexist" , "users" ]),
230
234
("noexist, testnoexist, users" , ["noexist," , "testnoexist," , "users" ]),
231
235
("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" ]),
232
243
("group with space" , ["group" , "with" , "space" ])
233
244
]
234
245
)
0 commit comments