1
0
Fork 0
mirror of synced 2024-06-27 02:31:04 +12:00

Fix tests

This commit is contained in:
Jake Barnby 2024-02-26 01:05:14 +13:00
parent 2ccfd89681
commit 675dec48b3
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
2 changed files with 11 additions and 13 deletions

View file

@ -291,7 +291,7 @@ class AccountCustomClientTest extends Scope
$this->assertNotEmpty($response['body']['logs']);
$this->assertCount(3, $response['body']['logs']);
$this->assertIsNumeric($response['body']['total']);
$this->assertEquals("session.create", $response['body']['logs'][2]['event']);
$this->assertEquals("user.create", $response['body']['logs'][2]['event']);
$this->assertEquals(filter_var($response['body']['logs'][2]['ip'], FILTER_VALIDATE_IP), $response['body']['logs'][2]['ip']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['logs'][2]['time']));
@ -313,10 +313,6 @@ class AccountCustomClientTest extends Scope
$this->assertEquals('--', $response['body']['logs'][1]['countryCode']);
$this->assertEquals('Unknown', $response['body']['logs'][1]['countryName']);
$this->assertEquals("user.create", $response['body']['logs'][3]['event']);
$this->assertEquals(filter_var($response['body']['logs'][3]['ip'], FILTER_VALIDATE_IP), $response['body']['logs'][3]['ip']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['logs'][2]['time']));
$this->assertEquals('Windows', $response['body']['logs'][2]['osName']);
$this->assertEquals('WIN', $response['body']['logs'][2]['osCode']);
$this->assertEquals('10', $response['body']['logs'][2]['osVersion']);
@ -368,7 +364,7 @@ class AccountCustomClientTest extends Scope
$this->assertEquals($responseOffset['headers']['status-code'], 200);
$this->assertIsArray($responseOffset['body']['logs']);
$this->assertNotEmpty($responseOffset['body']['logs']);
$this->assertCount(3, $responseOffset['body']['logs']);
$this->assertCount(2, $responseOffset['body']['logs']);
$this->assertIsNumeric($responseOffset['body']['total']);
$this->assertEquals($response['body']['logs'][1], $responseOffset['body']['logs'][0]);
@ -2242,12 +2238,15 @@ class AccountCustomClientTest extends Scope
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['expire']));
\sleep(15);
\sleep(5);
$smsRequest = $this->getLastRequest();
$message = $smsRequest['data']['message'];
$token = substr($message, 0, 6);
return \array_merge($data, [
'token' => $smsRequest['data']['secret']
'token' => $token
]);
}

View file

@ -62,7 +62,9 @@ class AccountCustomServerTest extends Scope
$this->assertNotEmpty($response['body']['secret']);
$this->assertNotFalse(\DateTime::createFromFormat('Y-m-d\TH:i:s.uP', $response['body']['expire']));
// already logged in
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -72,11 +74,8 @@ class AccountCustomServerTest extends Scope
'password' => $password,
]);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertEquals(401, $response['headers']['status-code']);
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],