@@ -10,9 +10,9 @@ import { describe, expect, test as it } from "vitest";
1010import { schemaLogFilter } from "./schemaLogFilter" ;
1111
1212describe ( schemaLogFilter . name , ( ) => {
13- it ( "should filter sensitive trait-marked fields" , ( ) => {
14- const sensitiveString : StaticSimpleSchema = [ 0 , "ns" , "SensitiveString" , { sensitive : 1 } , 0 ] ;
13+ const sensitiveString : StaticSimpleSchema = [ 0 , "ns" , "SensitiveString" , { sensitive : 1 } , 0 ] ;
1514
15+ it ( "should filter sensitive trait-marked fields" , ( ) => {
1616 const schema : StaticStructureSchema = [
1717 3 ,
1818 "ns" ,
@@ -93,4 +93,36 @@ describe(schemaLogFilter.name, () => {
9393 } ,
9494 } ) ;
9595 } ) ;
96+
97+ it ( "should filter sensitive fields within list and map values" , ( ) => {
98+ const value : StaticStructureSchema = [
99+ 3 ,
100+ "ns" ,
101+ "Value" ,
102+ 0 ,
103+ [ "public" , "sensitive" ] ,
104+ [ 0 satisfies StringSchema , sensitiveString ] ,
105+ ] ;
106+ const schema : StaticStructureSchema = [
107+ 3 ,
108+ "ns" ,
109+ "Collections" ,
110+ 0 ,
111+ [ "list" , "map" ] ,
112+ [
113+ [ 1 , "ns" , "ValueList" , 0 , value ] ,
114+ [ 2 , "ns" , "ValueMap" , 0 , 0 satisfies StringSchema , value ] ,
115+ ] ,
116+ ] ;
117+
118+ expect (
119+ schemaLogFilter ( schema , {
120+ list : [ { public : "visible" , sensitive : "secret" } ] ,
121+ map : { key : { public : "visible" , sensitive : "secret" } } ,
122+ } )
123+ ) . toEqual ( {
124+ list : [ { public : "visible" , sensitive : "***SensitiveInformation***" } ] ,
125+ map : { key : { public : "visible" , sensitive : "***SensitiveInformation***" } } ,
126+ } ) ;
127+ } ) ;
96128} ) ;
0 commit comments