File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,4 +147,53 @@ public function testRenderBacktrace(): void
147147 );
148148 }
149149 }
150+
151+ public function testMaskSensitiveData (): void
152+ {
153+ $ maskSensitiveData = $ this ->getPrivateMethodInvoker ($ this ->exception , 'maskSensitiveData ' );
154+
155+ $ trace = [
156+ 0 => [
157+ 'file ' => '/var/www/CodeIgniter4/app/Controllers/Home.php ' ,
158+ 'line ' => 15 ,
159+ 'function ' => 'f ' ,
160+ 'class ' => 'App \\Controllers \\Home ' ,
161+ 'type ' => '-> ' ,
162+ 'args ' => [
163+ 0 => (object ) [
164+ 'password ' => 'secret1 ' ,
165+ ],
166+ 1 => (object ) [
167+ 'default ' => [
168+ 'password ' => 'secret2 ' ,
169+ ],
170+ ],
171+ 2 => [
172+ 'password ' => 'secret3 ' ,
173+ ],
174+ 3 => [
175+ 'default ' => ['password ' => 'secret4 ' ],
176+ ],
177+ ],
178+ ],
179+ 1 => [
180+ 'file ' => '/var/www/CodeIgniter4/system/CodeIgniter.php ' ,
181+ 'line ' => 932 ,
182+ 'function ' => 'index ' ,
183+ 'class ' => 'App \\Controllers \\Home ' ,
184+ 'type ' => '-> ' ,
185+ 'args ' => [
186+ ],
187+ ],
188+ ];
189+ $ keysToMask = ['password ' ];
190+ $ path = '' ;
191+
192+ $ newTrace = $ maskSensitiveData ($ trace , $ keysToMask , $ path );
193+
194+ $ this ->assertSame (['password ' => '****************** ' ], (array ) $ newTrace [0 ]['args ' ][0 ]);
195+ $ this ->assertSame (['password ' => '****************** ' ], $ newTrace [0 ]['args ' ][1 ]->default );
196+ $ this ->assertSame (['password ' => '****************** ' ], $ newTrace [0 ]['args ' ][2 ]);
197+ $ this ->assertSame (['password ' => '****************** ' ], $ newTrace [0 ]['args ' ][3 ]['default ' ]);
198+ }
150199}
You can’t perform that action at this time.
0 commit comments