summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-08-05 14:09:55 +0200
committerGitHub <noreply@github.com>2022-08-05 14:09:55 +0200
commitcbd5cef2cccded7806067cb22549a1d50d35cd59 (patch)
treeed58169e35606e49a72e211e3b997c31337f4f51 /tests/lib
parent5f40bd106ed81d681167e747f0d62dede8bf3672 (diff)
parent6941c91531b78a6898abe85ab74225b892bf8b06 (diff)
downloadnextcloud-server-cbd5cef2cccded7806067cb22549a1d50d35cd59.tar.gz
nextcloud-server-cbd5cef2cccded7806067cb22549a1d50d35cd59.zip
Merge pull request #33398 from nextcloud/enh/noid/sensitive-methods-apps
allow apps to specify methods carrying sensitive parameters
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Log/ExceptionSerializerTest.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/lib/Log/ExceptionSerializerTest.php b/tests/lib/Log/ExceptionSerializerTest.php
index 70ac80d13e3..209214a6832 100644
--- a/tests/lib/Log/ExceptionSerializerTest.php
+++ b/tests/lib/Log/ExceptionSerializerTest.php
@@ -48,6 +48,10 @@ class ExceptionSerializerTest extends TestCase {
throw new \Exception('my exception');
}
+ private function customMagicAuthThing(string $login, string $parole): void {
+ throw new \Exception('expected custom auth exception');
+ }
+
/**
* this test ensures that the serializer does not overwrite referenced
* variables. It is crafted after a scenario we experienced: the DAV server
@@ -65,4 +69,16 @@ class ExceptionSerializerTest extends TestCase {
$this->assertSame(ExceptionSerializer::SENSITIVE_VALUE_PLACEHOLDER, $serializedData['Trace'][0]['args'][0]);
}
}
+
+ public function testSerializerWithRegisteredMethods() {
+ $this->serializer->enlistSensitiveMethods(self::class, ['customMagicAuthThing']);
+ try {
+ $this->customMagicAuthThing('u57474', 'Secret');
+ } catch (\Exception $e) {
+ $serializedData = $this->serializer->serializeException($e);
+ $this->assertSame('customMagicAuthThing', $serializedData['Trace'][0]['function']);
+ $this->assertSame(ExceptionSerializer::SENSITIVE_VALUE_PLACEHOLDER, $serializedData['Trace'][0]['args'][0]);
+ $this->assertFalse(isset($serializedData['Trace'][0]['args'][1]));
+ }
+ }
}