@@ -225,3 +225,70 @@ def _test_users_ldap_groups_not_user_type(self):
225
225
self .env ["res.users" ].sudo ().authenticate (
226
226
self .env .cr .dbname , "users_ldap_groups-username" , "password" , {}
227
227
)
228
+
229
+ def test_users_ldap_groups_ldap_returns_binary_data (self ):
230
+ self ._create_ldap_config (
231
+ groups = [
232
+ {
233
+ "ldap_attribute" : "name" ,
234
+ "operator" : "contains" ,
235
+ "value" : "hello3" ,
236
+ "group_id" : self .group_system .id ,
237
+ },
238
+ {
239
+ "ldap_attribute" : "name" ,
240
+ "operator" : "contains" ,
241
+ "value" : "hello" ,
242
+ "group_id" : self .group_user .id ,
243
+ },
244
+ {
245
+ "ldap_attribute" : "name" ,
246
+ "operator" : "contains" ,
247
+ "value" : "hello2" ,
248
+ "group_id" : self .group_contains .id ,
249
+ },
250
+ {
251
+ "ldap_attribute" : "name" ,
252
+ "operator" : "equals" ,
253
+ "value" : "hello" ,
254
+ "group_id" : self .group_equals .id ,
255
+ },
256
+ {
257
+ "ldap_attribute" : "" ,
258
+ "operator" : "query" ,
259
+ "value" : "is not run because of patching" ,
260
+ "group_id" : self .group_query .id ,
261
+ },
262
+ ],
263
+ only_ldap_groups = True ,
264
+ )
265
+ with mock .patch (
266
+ _company_ldap_class + "._connect" ,
267
+ return_value = FakeLdapConnection (
268
+ {
269
+ "dc=users_ldap_groups,dc=example,dc=com" : {
270
+ "cn" : [b"User Name" ],
271
+ "name" : [b"hello" , b"hello2" ],
272
+ "thumbnailPhoto" : [
273
+ b"GIF89a\x01 \x00 \x01 \x00 \x00 \xff \x00 ,"
274
+ b"\x00 \x00 \x00 \x00 \x01 \x00 \x01 \x00 \x00 \x02 \x00 ;"
275
+ ],
276
+ }
277
+ }
278
+ ),
279
+ ), mock_cursor (self .cr ):
280
+ user_id = (
281
+ self .env ["res.users" ]
282
+ .sudo ()
283
+ .authenticate (
284
+ self .env .cr .dbname , "users_ldap_groups-username" , "password" , {}
285
+ )
286
+ )
287
+ # this asserts group mappings from demo data
288
+ user = self .env ["res.users" ].sudo ().browse (user_id )
289
+ groups = user .groups_id
290
+ self .assertIn (self .group_contains , groups )
291
+ self .assertIn (self .group_user , groups )
292
+ self .assertNotIn (self .group_equals , groups )
293
+ self .assertIn (self .group_query , groups )
294
+ self .assertNotIn (self .group_system , groups )
0 commit comments