Skip to content

Commit 36a5f5a

Browse files
committed
test: add test for maskSensitiveData() and trace data key
1 parent 6b624d6 commit 36a5f5a

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/system/Debug/ExceptionsTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,36 @@ public function testMaskSensitiveData(): void
196196
$this->assertSame(['password' => '******************'], $newTrace[0]['args'][2]);
197197
$this->assertSame(['password' => '******************'], $newTrace[0]['args'][3]['default']);
198198
}
199+
200+
public function testMaskSensitiveDataTraceDataKey(): void
201+
{
202+
$maskSensitiveData = $this->getPrivateMethodInvoker($this->exception, 'maskSensitiveData');
203+
204+
$trace = [
205+
0 => [
206+
'file' => '/var/www/CodeIgniter4/app/Controllers/Home.php',
207+
'line' => 15,
208+
'function' => 'f',
209+
'class' => 'App\\Controllers\\Home',
210+
'type' => '->',
211+
'args' => [
212+
],
213+
],
214+
1 => [
215+
'file' => '/var/www/CodeIgniter4/system/CodeIgniter.php',
216+
'line' => 932,
217+
'function' => 'index',
218+
'class' => 'App\\Controllers\\Home',
219+
'type' => '->',
220+
'args' => [
221+
],
222+
],
223+
];
224+
$keysToMask = ['file'];
225+
$path = '';
226+
227+
$newTrace = $maskSensitiveData($trace, $keysToMask, $path);
228+
229+
$this->assertSame('/var/www/CodeIgniter4/app/Controllers/Home.php', $newTrace[0]['file']);
230+
}
199231
}

0 commit comments

Comments
 (0)