1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00

feat: review comments

This commit is contained in:
Christy Jacob 2021-05-06 18:51:36 +05:30
parent eaac52b9b7
commit 80328f1dc7
2 changed files with 3 additions and 41 deletions

View file

@ -682,7 +682,7 @@ App::post('/v1/account/sessions/anonymous')
'emailVerification' => false,
'status' => Auth::USER_STATUS_UNACTIVATED,
'password' => null,
'passwordUpdate' => 0,
'passwordUpdate' => \time(),
'registration' => \time(),
'reset' => false,
'name' => null

View file

@ -264,7 +264,7 @@ class AccountCustomClientTest extends Scope
public function testUpdateAnonymousAccountPassword($session)
{
/**
* Anonymous account updates password without old password -> SHOULD PASS
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
'origin' => 'http://localhost',
@ -272,48 +272,10 @@ class AccountCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'password' => 'new-password',
'oldPassword' => '',
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsNumeric($response['body']['registration']);
/**
* Anonymous account tries to update password again without 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,
]), [
'password' => 'new-password'
]);
$this->assertEquals($response['headers']['status-code'], 401);
/**
* Anonymous account updates password with new and old password -> SHOULD PASS
*/
$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,
]), [
'password' => 'newer-password',
'oldPassword' => 'new-password',
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsNumeric($response['body']['registration']);
$this->assertEquals(400, $response['headers']['status-code']);
return $session;
}