diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2024-06-25 15:16:40 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-08-07 10:44:58 +0000 |
commit | 0a0c07cec141a5590f407627c808691d5688ffa7 (patch) | |
tree | bd4ade929b830e562598a8f3a6877af073dc837d /tests | |
parent | eec226d3e2bb24d7078ec7c032b741bec08a7e78 (diff) | |
download | nextcloud-server-0a0c07cec141a5590f407627c808691d5688ffa7.tar.gz nextcloud-server-0a0c07cec141a5590f407627c808691d5688ffa7.zip |
fix(session): Log when session_* calls are slow
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Session/CryptoSessionDataTest.php | 2 | ||||
-rw-r--r-- | tests/lib/Session/MemoryTest.php | 4 | ||||
-rw-r--r-- | tests/lib/User/SessionTest.php | 28 |
3 files changed, 17 insertions, 17 deletions
diff --git a/tests/lib/Session/CryptoSessionDataTest.php b/tests/lib/Session/CryptoSessionDataTest.php index 10bc62e099c..491630e0573 100644 --- a/tests/lib/Session/CryptoSessionDataTest.php +++ b/tests/lib/Session/CryptoSessionDataTest.php @@ -34,7 +34,7 @@ class CryptoSessionDataTest extends Session { protected function setUp(): void { parent::setUp(); - $this->wrappedSession = new \OC\Session\Memory($this->getUniqueID()); + $this->wrappedSession = new \OC\Session\Memory(); $this->crypto = $this->createMock(ICrypto::class); $this->crypto->expects($this->any()) ->method('encrypt') diff --git a/tests/lib/Session/MemoryTest.php b/tests/lib/Session/MemoryTest.php index fab7292ae00..54e73bb1884 100644 --- a/tests/lib/Session/MemoryTest.php +++ b/tests/lib/Session/MemoryTest.php @@ -12,10 +12,10 @@ namespace Test\Session; class MemoryTest extends Session { protected function setUp(): void { parent::setUp(); - $this->instance = new \OC\Session\Memory($this->getUniqueID()); + $this->instance = new \OC\Session\Memory(); } - + public function testThrowsExceptionOnGetId() { $this->expectException(\OCP\Session\Exceptions\SessionNotAvailableException::class); diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index 619f6b3b874..ad4eaccd9de 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -115,7 +115,7 @@ class SessionTest extends \Test\TestCase { * @dataProvider isLoggedInData */ public function testIsLoggedIn($isLoggedIn) { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $manager = $this->createMock(Manager::class); @@ -133,7 +133,7 @@ class SessionTest extends \Test\TestCase { } public function testSetUser() { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $session->expects($this->once()) ->method('set') ->with('user_id', 'foo'); @@ -152,7 +152,7 @@ class SessionTest extends \Test\TestCase { } public function testLoginValidPasswordEnabled() { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $session->expects($this->once()) ->method('regenerateId'); $this->tokenProvider->expects($this->once()) @@ -229,7 +229,7 @@ class SessionTest extends \Test\TestCase { public function testLoginValidPasswordDisabled() { $this->expectException(LoginException::class); - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $session->expects($this->never()) ->method('set'); $session->expects($this->once()) @@ -271,7 +271,7 @@ class SessionTest extends \Test\TestCase { } public function testLoginInvalidPassword() { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $managerMethods = get_class_methods(Manager::class); //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); @@ -314,7 +314,7 @@ class SessionTest extends \Test\TestCase { } public function testPasswordlessLoginNoLastCheckUpdate(): void { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $managerMethods = get_class_methods(Manager::class); // Keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); @@ -351,7 +351,7 @@ class SessionTest extends \Test\TestCase { } public function testLoginLastCheckUpdate(): void { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $managerMethods = get_class_methods(Manager::class); // Keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); @@ -388,7 +388,7 @@ class SessionTest extends \Test\TestCase { } public function testLoginNonExisting() { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $manager = $this->createMock(Manager::class); $userSession = new Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher); @@ -608,7 +608,7 @@ class SessionTest extends \Test\TestCase { } public function testRememberLoginValidToken() { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $managerMethods = get_class_methods(Manager::class); //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); @@ -697,7 +697,7 @@ class SessionTest extends \Test\TestCase { } public function testRememberLoginInvalidSessionToken() { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $managerMethods = get_class_methods(Manager::class); //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); @@ -761,7 +761,7 @@ class SessionTest extends \Test\TestCase { } public function testRememberLoginInvalidToken() { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $managerMethods = get_class_methods(Manager::class); //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); @@ -813,7 +813,7 @@ class SessionTest extends \Test\TestCase { } public function testRememberLoginInvalidUser() { - $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); + $session = $this->createMock(Memory::class); $managerMethods = get_class_methods(Manager::class); //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); @@ -873,7 +873,7 @@ class SessionTest extends \Test\TestCase { return $users[$uid]; }); - $session = new Memory(''); + $session = new Memory(); $session->set('user_id', 'foo'); $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) @@ -886,7 +886,7 @@ class SessionTest extends \Test\TestCase { $this->assertEquals($users['foo'], $userSession->getUser()); - $session2 = new Memory(''); + $session2 = new Memory(); $session2->set('user_id', 'bar'); $userSession->setSession($session2); $this->assertEquals($users['bar'], $userSession->getUser()); |