Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2022-07-29 13:07:41 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2022-07-29 13:07:41 +0300
commit6941c91531b78a6898abe85ab74225b892bf8b06 (patch)
treede9ed75bb90002275f08814733a5d4b1378dff81
parent2a6f46e6891ee82b613be6151d2f51583c45c2bf (diff)
add unit test for ExceptionSerializerenh/noid/sensitive-methods-apps
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-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]));
+ }
+ }
}