Skip to content

Commit

Permalink
Add test for auth with session cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
devdot committed Jun 5, 2024
1 parent b45da1f commit 153565e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Integration/Requests/AuthRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 153565e

Please sign in to comment.