]> source.dussan.org Git - nextcloud-server.git/commitdiff
Unit tests for #6977 7672/head
authorJoas Schilling <coding@schilljs.com>
Fri, 27 Oct 2017 09:46:20 +0000 (11:46 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 3 Jan 2018 09:46:30 +0000 (10:46 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
tests/lib/LoggerTest.php

index da9cedc9f56d808562db67b1fbf844e711b8e00d..3a30bbd1d3b224b30cbead6cc5293bbc5a33992a 100644 (file)
@@ -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],