17
17
redacts_from_meta_single_context /1 ,
18
18
handles_missing_attributes /1 ,
19
19
can_redact_all_attributes_single_context /1 ,
20
- can_redact_all_attributes_multi_context /1
20
+ can_redact_all_attributes_multi_context /1 ,
21
+ can_redact_single_context_anonymous_attributes /1 ,
22
+ can_redact_multi_context_anonymous_attributes /1
21
23
]).
22
24
23
25
% %====================================================================
@@ -33,7 +35,9 @@ all() ->
33
35
redacts_from_meta_single_context ,
34
36
handles_missing_attributes ,
35
37
can_redact_all_attributes_single_context ,
36
- can_redact_all_attributes_multi_context
38
+ can_redact_all_attributes_multi_context ,
39
+ can_redact_single_context_anonymous_attributes ,
40
+ can_redact_multi_context_anonymous_attributes
37
41
].
38
42
39
43
init_per_suite (Config ) ->
@@ -262,3 +266,56 @@ can_redact_all_attributes_multi_context(_) ->
262
266
<<" _meta" >> := #{<<" redactedAttributes" >> := [<<" anAttribute" >>, <<" nested" >>]}
263
267
}
264
268
} = ldclient_context_filter :format_context_for_event (all , TestContext ).
269
+
270
+ can_redact_single_context_anonymous_attributes (_ ) ->
271
+ TestContext =
272
+ ldclient_context :set (name , <<" the-name" >>,
273
+ ldclient_context :set (anonymous , true ,
274
+ ldclient_context :set (<<" org" >>, <<" anAttribute" >>, <<" aValue" >>,
275
+ ldclient_context :set (<<" org" >>, <<" nested" >>, #{
276
+ <<" key1" >> => <<" value1" >>,
277
+ <<" key2" >> => <<" value2" >>
278
+ },
279
+ ldclient_context :new (<<" org-key" >>, <<" org" >>))))),
280
+ #{
281
+ <<" kind" >> := <<" org" >>,
282
+ <<" key" >> := <<" org-key" >>,
283
+ <<" anonymous" >> := true ,
284
+ <<" _meta" >> := #{
285
+ <<" redactedAttributes" >> := [
286
+ <<" name" >>,
287
+ <<" anAttribute" >>,
288
+ <<" nested" >>
289
+ ]
290
+ }
291
+ } = ldclient_context_filter :format_context_for_event_with_anonyous_redaction ([], TestContext ).
292
+
293
+ can_redact_multi_context_anonymous_attributes (_ ) ->
294
+ TestContext = ldclient_context :new_multi_from ([
295
+ ldclient_context :set (<<" org" >>, <<" anAttribute" >>, <<" aValue" >>,
296
+ ldclient_context :set (anonymous , true ,
297
+ ldclient_context :set (<<" org" >>, <<" nested" >>, #{
298
+ <<" key1" >> => <<" value1" >>,
299
+ <<" key2" >> => <<" value2" >>
300
+ },
301
+ ldclient_context :new (<<" org-key" >>, <<" org" >>)))),
302
+ ldclient_context :set (<<" user" >>, <<" anAttribute" >>, <<" aValue" >>,
303
+ ldclient_context :set (<<" user" >>, <<" nested" >>, #{
304
+ <<" key1" >> => <<" value1" >>,
305
+ <<" key2" >> => <<" value2" >>
306
+ },
307
+ ldclient_context :new (<<" user-key" >>, <<" user" >>)))
308
+ ]),
309
+ #{
310
+ <<" kind" >> := <<" multi" >>,
311
+ <<" org" >> := #{
312
+ <<" key" >> := <<" org-key" >>,
313
+ <<" anonymous" >> := true ,
314
+ <<" _meta" >> := #{<<" redactedAttributes" >> := [<<" anAttribute" >>, <<" nested" >>]}
315
+ },
316
+ <<" user" >> := #{
317
+ <<" key" >> := <<" user-key" >>,
318
+ <<" anAttribute" >> := <<" aValue" >>,
319
+ <<" nested" >> := #{<<" key1" >> := <<" value1" >>, <<" key2" >> := <<" value2" >>}
320
+ }
321
+ } = ldclient_context_filter :format_context_for_event_with_anonyous_redaction ([], TestContext ).
0 commit comments