diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2024-06-25 15:16:40 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2024-08-07 09:02:10 +0200 |
commit | 2b38d6ae7e0602d164bb26affa8a877b818e9cb5 (patch) | |
tree | 4917f090e30515b8c27f4eec5ae2492cfae1af40 /tests | |
parent | fbbc10466b79caea0b9d1f718d4abdd021df241c (diff) | |
download | nextcloud-server-2b38d6ae7e0602d164bb26affa8a877b818e9cb5.tar.gz nextcloud-server-2b38d6ae7e0602d164bb26affa8a877b818e9cb5.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 83768ef49aa..6c1536f4769 100644 --- a/tests/lib/Session/CryptoSessionDataTest.php +++ b/tests/lib/Session/CryptoSessionDataTest.php @@ -20,7 +20,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 ae4a1b64dc0..f5d9685039d 100644 --- a/tests/lib/Session/MemoryTest.php +++ b/tests/lib/Session/MemoryTest.php @@ -11,10 +11,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 236da2a1dcc..84af7f552a7 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -114,7 +114,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); @@ -132,7 +132,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'); @@ -151,7 +151,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()) @@ -228,7 +228,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()) @@ -270,7 +270,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']); @@ -313,7 +313,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']); @@ -350,7 +350,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']); @@ -387,7 +387,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); @@ -607,7 +607,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']); @@ -696,7 +696,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']); @@ -760,7 +760,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']); @@ -812,7 +812,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']); @@ -872,7 +872,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]) @@ -885,7 +885,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()); |