From 675dec48b347e61d359db399345a4a44463047a8 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 26 Feb 2024 01:05:14 +1300 Subject: [PATCH] Fix tests --- .../Services/Account/AccountCustomClientTest.php | 15 +++++++-------- .../Services/Account/AccountCustomServerTest.php | 9 ++++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index aea0cf917..56cc126cb 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -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 ]); } diff --git a/tests/e2e/Services/Account/AccountCustomServerTest.php b/tests/e2e/Services/Account/AccountCustomServerTest.php index e65e57453..e29110cf4 100644 --- a/tests/e2e/Services/Account/AccountCustomServerTest.php +++ b/tests/e2e/Services/Account/AccountCustomServerTest.php @@ -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'],