Unit tests for #6977
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
7a4c0c668b
commit
8660b9f0af
1 changed files with 26 additions and 0 deletions
|
@ -138,6 +138,32 @@ class LoggerTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider userAndPasswordData
|
||||||
|
*/
|
||||||
|
public function testDetectclosure($user, $password) {
|
||||||
|
$a = function($user, $password) {
|
||||||
|
throw new \Exception('test');
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
$a($user, $password);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logger->logException($e);
|
||||||
|
}
|
||||||
|
$logLines = $this->getLogs();
|
||||||
|
|
||||||
|
foreach($logLines as $logLine) {
|
||||||
|
$log = explode('\n', $logLine);
|
||||||
|
unset($log[1]); // Remove `testDetectclosure(` because we are not testing this here, but the closure on stack trace 0
|
||||||
|
$logLine = implode('\n', $log);
|
||||||
|
|
||||||
|
$this->assertNotContains($user, $logLine);
|
||||||
|
$this->assertNotContains($password, $logLine);
|
||||||
|
$this->assertContains('{closure}(*** sensitive parameters replaced ***)', $logLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function dataGetLogClass() {
|
public function dataGetLogClass() {
|
||||||
return [
|
return [
|
||||||
['file', \OC\Log\File::class],
|
['file', \OC\Log\File::class],
|
||||||
|
|
Loading…
Reference in a new issue