From 7728a2571a5e3694d52c7614d64258fa3ca445f9 Mon Sep 17 00:00:00 2001 From: Thomas Kuschan Date: Wed, 5 Jun 2024 13:50:19 +0200 Subject: [PATCH] Add test for auth with session cookie --- .../Integration/Requests/AuthRequestTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/Integration/Requests/AuthRequestTest.php b/tests/Integration/Requests/AuthRequestTest.php index 768655b4..bfb7e863 100644 --- a/tests/Integration/Requests/AuthRequestTest.php +++ b/tests/Integration/Requests/AuthRequestTest.php @@ -28,6 +28,28 @@ public function testAuthWithEmailAndPassword(): void $this->assertNotNull($cookie); } + public function testAuthWithSessionCookie(): void + { + $auth = IntegrationTestData::get()->authenticateUser(); + $userId = $auth->userId; + $this->assertNotNull($userId); + + $cookie = CTConfig::getSessionCookieString(); + $this->assertNotNull($cookie); + + // clear config + CTConfig::clearConfig(); + CTConfig::setApiUrl(IntegrationTestData::get()->getApiUrl()); + + // verify that we are not logged in now + $this->assertFalse(CTConfig::validateAuthentication()); + + // login using the cookie + $auth = CTConfig::authWithSessionCookie($cookie); + $this->assertSame($userId, $auth->userId); + $this->assertTrue(CTConfig::validateAuthentication()); + } + public function testAuthWithUserIdAndLoginToken() { $auth = IntegrationTestData::get()->authenticateUser();