diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2017-10-30 17:53:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-30 17:53:02 +0100 |
commit | 062aadba0612fe5eca98d88fd2313a6786e0c814 (patch) | |
tree | 68941c2d1c2596184479eb78c549838545e14611 | |
parent | d18a60de3902236505aaa0e289c01cd1c6deb594 (diff) | |
parent | 8660b9f0afa37983b66895a78a0f41417365efe0 (diff) | |
download | nextcloud-server-062aadba0612fe5eca98d88fd2313a6786e0c814.tar.gz nextcloud-server-062aadba0612fe5eca98d88fd2313a6786e0c814.zip |
Merge pull request #6981 from nextcloud/unit-tests-for-6977
Unit tests for #6977
-rw-r--r-- | tests/lib/LoggerTest.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php index da9cedc9f56..3a30bbd1d3b 100644 --- a/tests/lib/LoggerTest.php +++ b/tests/lib/LoggerTest.php @@ -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() { return [ ['file', \OC\Log\File::class], |