fix linting issues AccountBase.php
This commit is contained in:
parent
5a5c11ac16
commit
e95be7d922
|
@ -6,9 +6,9 @@ use Tests\E2E\Client;
|
|||
|
||||
trait AccountBase
|
||||
{
|
||||
public function testCreateAccount():array
|
||||
public function testCreateAccount(): array
|
||||
{
|
||||
$email = uniqid().'user@localhost.test';
|
||||
$email = uniqid() . 'user@localhost.test';
|
||||
$password = 'password';
|
||||
$name = 'User Name';
|
||||
|
||||
|
@ -98,7 +98,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateAccount
|
||||
*/
|
||||
public function testCreateAccountSession($data):array
|
||||
public function testCreateAccountSession($data): array
|
||||
{
|
||||
$email = $data['email'] ?? '';
|
||||
$password = $data['password'] ?? '';
|
||||
|
@ -118,7 +118,7 @@ trait AccountBase
|
|||
$this->assertEquals($response['headers']['status-code'], 201);
|
||||
|
||||
$sessionId = $response['body']['$id'];
|
||||
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
|
||||
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
|
@ -128,7 +128,7 @@ trait AccountBase
|
|||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]), [
|
||||
'email' => $email.'x',
|
||||
'email' => $email . 'x',
|
||||
'password' => $password,
|
||||
]);
|
||||
|
||||
|
@ -140,7 +140,7 @@ trait AccountBase
|
|||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]), [
|
||||
'email' => $email,
|
||||
'password' => $password.'x',
|
||||
'password' => $password . 'x',
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 401);
|
||||
|
@ -165,7 +165,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateAccountSession
|
||||
*/
|
||||
public function testGetAccount($data):array
|
||||
public function testGetAccount($data): array
|
||||
{
|
||||
$email = $data['email'] ?? '';
|
||||
$name = $data['name'] ?? '';
|
||||
|
@ -178,7 +178,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
|
@ -200,7 +200,7 @@ trait AccountBase
|
|||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/account', [
|
||||
'content-type' => 'application/json',
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session.'xx',
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session . 'xx',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]);
|
||||
|
||||
|
@ -212,7 +212,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateAccountSession
|
||||
*/
|
||||
public function testGetAccountPrefs($data):array
|
||||
public function testGetAccountPrefs($data): array
|
||||
{
|
||||
$session = $data['session'] ?? '';
|
||||
|
||||
|
@ -223,7 +223,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
|
@ -248,7 +248,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateAccountSession
|
||||
*/
|
||||
public function testGetAccountSessions($data):array
|
||||
public function testGetAccountSessions($data): array
|
||||
{
|
||||
$session = $data['session'] ?? '';
|
||||
$sessionId = $data['sessionId'] ?? '';
|
||||
|
@ -260,7 +260,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
|
@ -269,7 +269,7 @@ trait AccountBase
|
|||
$this->assertCount(2, $response['body']);
|
||||
$this->assertEquals(1, $response['body']['total']);
|
||||
$this->assertEquals($sessionId, $response['body']['sessions'][0]['$id']);
|
||||
|
||||
|
||||
$this->assertEquals('Windows', $response['body']['sessions'][0]['osName']);
|
||||
$this->assertEquals('WIN', $response['body']['sessions'][0]['osCode']);
|
||||
$this->assertEquals('10', $response['body']['sessions'][0]['osVersion']);
|
||||
|
@ -306,7 +306,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateAccountSession
|
||||
*/
|
||||
public function testGetAccountLogs($data):array
|
||||
public function testGetAccountLogs($data): array
|
||||
{
|
||||
sleep(10);
|
||||
$session = $data['session'] ?? '';
|
||||
|
@ -319,7 +319,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
|
@ -375,7 +375,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'limit' => 1
|
||||
]);
|
||||
|
@ -392,7 +392,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'offset' => 1
|
||||
]);
|
||||
|
@ -409,7 +409,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'limit' => 1,
|
||||
'offset' => 1
|
||||
|
@ -441,7 +441,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateAccountSession
|
||||
*/
|
||||
public function testUpdateAccountName($data):array
|
||||
public function testUpdateAccountName($data): array
|
||||
{
|
||||
$email = $data['email'] ?? '';
|
||||
$session = $data['session'] ?? '';
|
||||
|
@ -454,7 +454,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'name' => $newName
|
||||
]);
|
||||
|
@ -482,7 +482,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
]);
|
||||
|
||||
|
@ -492,7 +492,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'name' => 'ocSRq1d3QphHivJyUmYY7WMnrxyjdk5YvVwcDqx2zS0coxESN8RmsQwLWw5Whnf0WbVohuFWTRAaoKgCOO0Y0M7LwgFnZmi8881Y72222222222222222222222222222'
|
||||
]);
|
||||
|
@ -507,7 +507,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testUpdateAccountName
|
||||
*/
|
||||
public function testUpdateAccountPassword($data):array
|
||||
public function testUpdateAccountPassword($data): array
|
||||
{
|
||||
$email = $data['email'] ?? '';
|
||||
$password = $data['password'] ?? '';
|
||||
|
@ -520,7 +520,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'password' => 'new-password',
|
||||
'oldPassword' => $password,
|
||||
|
@ -554,15 +554,14 @@ trait AccountBase
|
|||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 401);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
]);
|
||||
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 400);
|
||||
|
||||
/**
|
||||
|
@ -572,7 +571,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'password' => 'new-password',
|
||||
'oldPassword' => $password,
|
||||
|
@ -580,13 +579,13 @@ trait AccountBase
|
|||
$this->assertEquals($response['headers']['status-code'], 401);
|
||||
|
||||
/**
|
||||
* Existing user tries to update password without passing old password -> SHOULD FAIL
|
||||
* Existing user tries to update password without passing old password -> SHOULD FAIL
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'password' => 'new-password'
|
||||
]);
|
||||
|
@ -600,9 +599,9 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testUpdateAccountPassword
|
||||
*/
|
||||
public function testUpdateAccountEmail($data):array
|
||||
public function testUpdateAccountEmail($data): array
|
||||
{
|
||||
$newEmail = uniqid().'new@localhost.test';
|
||||
$newEmail = uniqid() . 'new@localhost.test';
|
||||
$session = $data['session'] ?? '';
|
||||
|
||||
/**
|
||||
|
@ -612,7 +611,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'email' => $newEmail,
|
||||
'password' => 'new-password',
|
||||
|
@ -640,7 +639,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
]);
|
||||
|
||||
|
@ -667,8 +666,8 @@ trait AccountBase
|
|||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $data['email']);
|
||||
$this->assertEquals($response['body']['name'], $data['name'],);
|
||||
|
||||
$this->assertEquals($response['body']['name'], $data['name']);
|
||||
|
||||
|
||||
$data['email'] = $newEmail;
|
||||
|
||||
|
@ -678,9 +677,9 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testUpdateAccountEmail
|
||||
*/
|
||||
public function testUpdateAccountPrefs($data):array
|
||||
public function testUpdateAccountPrefs($data): array
|
||||
{
|
||||
$newEmail = uniqid().'new@localhost.test';
|
||||
$newEmail = uniqid() . 'new@localhost.test';
|
||||
$session = $data['session'] ?? '';
|
||||
|
||||
/**
|
||||
|
@ -690,7 +689,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'prefs' => [
|
||||
'prefKey1' => 'prefValue1',
|
||||
|
@ -714,35 +713,35 @@ trait AccountBase
|
|||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 401);
|
||||
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'prefs' => '{}'
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 400);
|
||||
|
||||
|
||||
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'prefs' => '[]'
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 400);
|
||||
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'prefs' => '{"test": "value"}'
|
||||
]);
|
||||
|
@ -758,7 +757,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'prefs' => $prefsObject
|
||||
]);
|
||||
|
@ -772,7 +771,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'prefs' => $prefsObject
|
||||
]);
|
||||
|
@ -785,7 +784,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testUpdateAccountPrefs
|
||||
*/
|
||||
public function testCreateAccountVerification($data):array
|
||||
public function testCreateAccountVerification($data): array
|
||||
{
|
||||
$email = $data['email'] ?? '';
|
||||
$name = $data['name'] ?? '';
|
||||
|
@ -798,8 +797,8 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
|
||||
]), [
|
||||
'url' => 'http://localhost/verification',
|
||||
]);
|
||||
|
@ -817,15 +816,15 @@ trait AccountBase
|
|||
|
||||
$verification = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256);
|
||||
|
||||
$expireTime = strpos($lastEmail['text'], 'expire='.$response['body']['expire'], 0);
|
||||
$expireTime = strpos($lastEmail['text'], 'expire=' . $response['body']['expire'], 0);
|
||||
|
||||
$this->assertNotFalse($expireTime);
|
||||
|
||||
$secretTest = strpos($lastEmail['text'], 'secret='.$response['body']['secret'], 0);
|
||||
|
||||
$secretTest = strpos($lastEmail['text'], 'secret=' . $response['body']['secret'], 0);
|
||||
|
||||
$this->assertNotFalse($secretTest);
|
||||
|
||||
$userIDTest = strpos($lastEmail['text'], 'userId='.$response['body']['userId'], 0);
|
||||
$userIDTest = strpos($lastEmail['text'], 'userId=' . $response['body']['userId'], 0);
|
||||
|
||||
$this->assertNotFalse($userIDTest);
|
||||
|
||||
|
@ -836,7 +835,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'url' => 'localhost/verification',
|
||||
]);
|
||||
|
@ -847,7 +846,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'url' => 'http://remotehost/verification',
|
||||
]);
|
||||
|
@ -862,12 +861,12 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateAccountVerification
|
||||
*/
|
||||
public function testUpdateAccountVerification($data):array
|
||||
public function testUpdateAccountVerification($data): array
|
||||
{
|
||||
$id = $data['id'] ?? '';
|
||||
$session = $data['session'] ?? '';
|
||||
$verification = $data['verification'] ?? '';
|
||||
|
||||
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
|
@ -875,14 +874,14 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'userId' => $id,
|
||||
'secret' => $verification,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
@ -890,7 +889,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'userId' => 'ewewe',
|
||||
'secret' => $verification,
|
||||
|
@ -902,7 +901,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'userId' => $id,
|
||||
'secret' => 'sdasdasdasd',
|
||||
|
@ -916,7 +915,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testUpdateAccountVerification
|
||||
*/
|
||||
public function testDeleteAccountSession($data):array
|
||||
public function testDeleteAccountSession($data): array
|
||||
{
|
||||
$email = $data['email'] ?? '';
|
||||
$password = $data['password'] ?? '';
|
||||
|
@ -935,7 +934,7 @@ trait AccountBase
|
|||
]);
|
||||
|
||||
$sessionNewId = $response['body']['$id'];
|
||||
$sessionNew = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
|
||||
$sessionNew = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 201);
|
||||
|
||||
|
@ -943,16 +942,16 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $sessionNew,
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/account/sessions/'.$sessionNewId, array_merge([
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/account/sessions/' . $sessionNewId, array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $sessionNew,
|
||||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 204);
|
||||
|
@ -961,7 +960,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
|
@ -973,7 +972,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $sessionNew,
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 401);
|
||||
|
@ -984,7 +983,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testUpdateAccountVerification
|
||||
*/
|
||||
public function testDeleteAccountSessionCurrent($data):array
|
||||
public function testDeleteAccountSessionCurrent($data): array
|
||||
{
|
||||
$email = $data['email'] ?? '';
|
||||
$password = $data['password'] ?? '';
|
||||
|
@ -1001,14 +1000,14 @@ trait AccountBase
|
|||
'password' => $password,
|
||||
]);
|
||||
|
||||
$sessionNew = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
|
||||
$sessionNew = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 201);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/account', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $sessionNew,
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]);
|
||||
|
||||
|
@ -1017,7 +1016,7 @@ trait AccountBase
|
|||
$response = $this->client->call(Client::METHOD_DELETE, '/account/sessions/current', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $sessionNew,
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]);
|
||||
|
||||
|
@ -1029,7 +1028,7 @@ trait AccountBase
|
|||
$response = $this->client->call(Client::METHOD_GET, '/account', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $sessionNew,
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
]);
|
||||
|
||||
|
@ -1041,7 +1040,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testUpdateAccountVerification
|
||||
*/
|
||||
public function testDeleteAccountSessions($data):array
|
||||
public function testDeleteAccountSessions($data): array
|
||||
{
|
||||
$session = $data['session'] ?? '';
|
||||
|
||||
|
@ -1052,7 +1051,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 204);
|
||||
|
@ -1083,7 +1082,7 @@ trait AccountBase
|
|||
'password' => $password,
|
||||
]);
|
||||
|
||||
$data['session'] = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
|
||||
$data['session'] = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -1091,7 +1090,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testDeleteAccountSession
|
||||
*/
|
||||
public function testCreateAccountRecovery($data):array
|
||||
public function testCreateAccountRecovery($data): array
|
||||
{
|
||||
$email = $data['email'] ?? '';
|
||||
$name = $data['name'] ?? '';
|
||||
|
@ -1121,15 +1120,15 @@ trait AccountBase
|
|||
|
||||
$recovery = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256);
|
||||
|
||||
$expireTime = strpos($lastEmail['text'], 'expire='.$response['body']['expire'], 0);
|
||||
$expireTime = strpos($lastEmail['text'], 'expire=' . $response['body']['expire'], 0);
|
||||
|
||||
$this->assertNotFalse($expireTime);
|
||||
|
||||
$secretTest = strpos($lastEmail['text'], 'secret='.$response['body']['secret'], 0);
|
||||
|
||||
$secretTest = strpos($lastEmail['text'], 'secret=' . $response['body']['secret'], 0);
|
||||
|
||||
$this->assertNotFalse($secretTest);
|
||||
|
||||
$userIDTest = strpos($lastEmail['text'], 'userId='.$response['body']['userId'], 0);
|
||||
$userIDTest = strpos($lastEmail['text'], 'userId=' . $response['body']['userId'], 0);
|
||||
|
||||
$this->assertNotFalse($userIDTest);
|
||||
|
||||
|
@ -1177,12 +1176,12 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateAccountRecovery
|
||||
*/
|
||||
public function testUpdateAccountRecovery($data):array
|
||||
public function testUpdateAccountRecovery($data): array
|
||||
{
|
||||
$id = $data['id'] ?? '';
|
||||
$recovery = $data['recovery'] ?? '';
|
||||
$newPassowrd = 'test-recovery';
|
||||
|
||||
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
|
@ -1198,7 +1197,7 @@ trait AccountBase
|
|||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
@ -1235,18 +1234,18 @@ trait AccountBase
|
|||
]), [
|
||||
'userId' => $id,
|
||||
'secret' => $recovery,
|
||||
'password' => $newPassowrd.'x',
|
||||
'password' => $newPassowrd . 'x',
|
||||
'passwordAgain' => $newPassowrd,
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function testCreateMagicUrl():array
|
||||
public function testCreateMagicUrl(): array
|
||||
{
|
||||
$email = \time().'user@appwrite.io';
|
||||
$email = \time() . 'user@appwrite.io';
|
||||
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
|
@ -1274,15 +1273,15 @@ trait AccountBase
|
|||
|
||||
$token = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256);
|
||||
|
||||
$expireTime = strpos($lastEmail['text'], 'expire='.$response['body']['expire'], 0);
|
||||
$expireTime = strpos($lastEmail['text'], 'expire=' . $response['body']['expire'], 0);
|
||||
|
||||
$this->assertNotFalse($expireTime);
|
||||
|
||||
$secretTest = strpos($lastEmail['text'], 'secret='.$response['body']['secret'], 0);
|
||||
$secretTest = strpos($lastEmail['text'], 'secret=' . $response['body']['secret'], 0);
|
||||
|
||||
$this->assertNotFalse($secretTest);
|
||||
|
||||
$userIDTest = strpos($lastEmail['text'], 'userId='.$response['body']['userId'], 0);
|
||||
$userIDTest = strpos($lastEmail['text'], 'userId=' . $response['body']['userId'], 0);
|
||||
|
||||
$this->assertNotFalse($userIDTest);
|
||||
|
||||
|
@ -1333,7 +1332,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateMagicUrl
|
||||
*/
|
||||
public function testCreateSessionWithMagicUrl($data):array
|
||||
public function testCreateSessionWithMagicUrl($data): array
|
||||
{
|
||||
$id = $data['id'] ?? '';
|
||||
$token = $data['token'] ?? '';
|
||||
|
@ -1358,13 +1357,13 @@ trait AccountBase
|
|||
$this->assertNotEmpty($response['body']['userId']);
|
||||
|
||||
$sessionId = $response['body']['$id'];
|
||||
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
|
||||
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
|
@ -1409,7 +1408,7 @@ trait AccountBase
|
|||
/**
|
||||
* @depends testCreateSessionWithMagicUrl
|
||||
*/
|
||||
public function testUpdateAccountPasswordWithMagicUrl($data):array
|
||||
public function testUpdateAccountPasswordWithMagicUrl($data): array
|
||||
{
|
||||
$email = $data['email'] ?? '';
|
||||
$session = $data['session'] ?? '';
|
||||
|
@ -1421,7 +1420,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'password' => 'new-password'
|
||||
]);
|
||||
|
@ -1454,15 +1453,15 @@ trait AccountBase
|
|||
]));
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 401);
|
||||
|
||||
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
]);
|
||||
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 400);
|
||||
|
||||
/**
|
||||
|
@ -1472,7 +1471,7 @@ trait AccountBase
|
|||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'password' => 'new-password',
|
||||
'oldPassword' => 'wrong-password',
|
||||
|
@ -1480,13 +1479,13 @@ trait AccountBase
|
|||
$this->assertEquals($response['headers']['status-code'], 401);
|
||||
|
||||
/**
|
||||
* Existing user tries to update password without passing old password -> SHOULD FAIL
|
||||
* Existing user tries to update password without passing old password -> SHOULD FAIL
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
]), [
|
||||
'password' => 'new-password'
|
||||
]);
|
||||
|
@ -1496,5 +1495,4 @@ trait AccountBase
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue