From e3273bc49fa4574d22e5724a5cff040d8aa8588d Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Wed, 16 Jun 2021 11:41:15 +0100 Subject: [PATCH] Add Tests --- .../Account/AccountCustomClientTest.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index 77a4f93686..e3d5587d55 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -424,4 +424,39 @@ class AccountCustomClientTest extends Scope return []; } + + public function testGetSessionByID() { + $session = $this->testCreateAnonymousAccount(); + + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/current', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session, + ])); + + $this->assertEquals($response['headers']['status-code'], 200); + $this->assertEquals($response['body']['provider'], 'anonymous'); + + $sessionID = $response['body']['$id']; + + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/'.$sessionID, array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session, + ])); + + $this->assertEquals($response['headers']['status-code'], 200); + $this->assertEquals($response['body']['provider'], 'anonymous'); + + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/97823askjdkasd80921371980', array_merge([ + 'origin' => 'http://localhost', + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session, + ])); + + $this->assertEquals($response['headers']['status-code'], 404); + } } \ No newline at end of file