1717 redacts_from_meta_single_context /1 ,
1818 handles_missing_attributes /1 ,
1919 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
2123]).
2224
2325% %====================================================================
@@ -33,7 +35,9 @@ all() ->
3335 redacts_from_meta_single_context ,
3436 handles_missing_attributes ,
3537 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
3741 ].
3842
3943init_per_suite (Config ) ->
@@ -262,3 +266,56 @@ can_redact_all_attributes_multi_context(_) ->
262266 <<" _meta" >> := #{<<" redactedAttributes" >> := [<<" anAttribute" >>, <<" nested" >>]}
263267 }
264268 } = 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