1
0
Fork 0
mirror of synced 2024-06-01 10:29:48 +12:00

change test validations from strings to datetime

This commit is contained in:
fogelito 2022-07-12 19:44:58 +03:00
parent f384a3352b
commit f676a0bf9e
13 changed files with 82 additions and 73 deletions

View file

@ -3,6 +3,7 @@
namespace Tests\E2E\Services\Account;
use Tests\E2E\Client;
use Utopia\Database\DateTime;
trait AccountBase
{
@ -31,7 +32,7 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@ -184,7 +185,7 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@ -463,7 +464,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $newName);
@ -529,7 +530,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@ -619,7 +620,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $newEmail);
/**
@ -661,7 +662,7 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $data['email']);
$this->assertEquals($response['body']['name'], $data['name']);
@ -803,7 +804,7 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertIsString($response['body']['expire']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
$lastEmail = $this->getLastEmail();
@ -1105,7 +1106,7 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertIsString($response['body']['expire']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
$lastEmail = $this->getLastEmail();
@ -1258,7 +1259,7 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertIsString($response['body']['expire']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
$userId = $response['body']['userId'];
@ -1364,7 +1365,7 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertTrue($response['body']['emailVerification']);
@ -1424,7 +1425,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([

View file

@ -7,8 +7,8 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\DateTime;
use Utopia\Database\Database;
use function sleep;
class AccountCustomClientTest extends Scope
@ -447,7 +447,7 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@ -697,7 +697,7 @@ class AccountCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertIsString($response['body']['expire']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
$userId = $response['body']['userId'];
@ -785,7 +785,7 @@ class AccountCustomClientTest extends Scope
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['phone'], $number);
$this->assertTrue($response['body']['phoneVerification']);
@ -836,7 +836,7 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@ -878,7 +878,7 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['phone'], $newPhone);
/**
@ -927,7 +927,7 @@ class AccountCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertIsString($response['body']['expire']);
$this->assertEquals(true, DateTime::isValid($response['body']['expire']));
return $data;
}

View file

@ -4,6 +4,7 @@ namespace Tests\E2E\Services\Databases;
use Tests\E2E\Client;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
trait DatabasesBase
{
@ -1369,7 +1370,7 @@ trait DatabasesBase
$this->assertEquals($document['headers']['status-code'], 201);
$this->assertEquals($document['body']['title'], 'Thor: Ragnaroc');
$this->assertEquals($document['body']['releaseYear'], 2017);
$this->assertNotEquals($document['body']['$createdAt'], 5);
$this->assertEquals(true, DateTime::isValid($document['body']['$createdAt']));
$this->assertEquals('user:' . $this->getUser()['$id'], $document['body']['$read'][0]);
$this->assertEquals('user:' . $this->getUser()['$id'], $document['body']['$write'][0]);

View file

@ -9,6 +9,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
class FunctionsCustomServerTest extends Scope
{
@ -47,8 +48,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertNotEmpty($response1['body']['$id']);
$this->assertEquals('Test', $response1['body']['name']);
$this->assertEquals('php-8.0', $response1['body']['runtime']);
$this->assertIsString($response1['body']['$createdAt']);
$this->assertIsString($response1['body']['$updatedAt']);
$this->assertEquals(true, DateTime::isValid($response1['body']['$createdAt']));
$this->assertEquals(true, DateTime::isValid($response1['body']['$updatedAt']));
$this->assertEquals('', $response1['body']['deployment']);
$this->assertEquals([
'funcKey1' => 'funcValue1',
@ -248,8 +249,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $response1['headers']['status-code']);
$this->assertNotEmpty($response1['body']['$id']);
$this->assertEquals('Test1', $response1['body']['name']);
$this->assertIsString($response1['body']['$createdAt']);
$this->assertIsString($response1['body']['$updatedAt']);
$this->assertEquals(true, DateTime::isValid($response1['body']['$createdAt']));
$this->assertEquals(true, DateTime::isValid($response1['body']['$updatedAt']));
$this->assertEquals('', $response1['body']['deployment']);
$this->assertEquals([
'key4' => 'value4',
@ -294,7 +295,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(201, $deployment['headers']['status-code']);
$this->assertNotEmpty($deployment['body']['$id']);
$this->assertIsString($deployment['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($deployment['body']['$createdAt']));
$this->assertEquals('index.php', $deployment['body']['entrypoint']);
// Wait for deployment to build.
@ -343,7 +344,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(201, $largeTag['headers']['status-code']);
$this->assertNotEmpty($largeTag['body']['$id']);
$this->assertIsString($largeTag['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($largeTag['body']['$createdAt']));
$this->assertEquals('index.php', $largeTag['body']['entrypoint']);
$this->assertGreaterThan(10000, $largeTag['body']['size']);
@ -365,8 +366,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['$createdAt']);
$this->assertIsString($response['body']['$updatedAt']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$this->assertEquals(true, DateTime::isValid($response['body']['$updatedAt']));
$this->assertEquals($data['deploymentId'], $response['body']['deployment']);
/**
@ -487,7 +488,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertNotEmpty($execution['body']['$id']);
$this->assertNotEmpty($execution['body']['functionId']);
$this->assertIsString($execution['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($execution['body']['$createdAt']));
$this->assertEquals($data['functionId'], $execution['body']['functionId']);
$this->assertEquals('waiting', $execution['body']['status']);
$this->assertEquals(0, $execution['body']['statusCode']);
@ -504,7 +505,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertNotEmpty($execution['body']['$id']);
$this->assertNotEmpty($execution['body']['functionId']);
$this->assertIsString($execution['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($execution['body']['$createdAt']));
$this->assertEquals($data['functionId'], $execution['body']['functionId']);
$this->assertEquals('completed', $execution['body']['status']);
$this->assertEquals(200, $execution['body']['statusCode']);

View file

@ -4,6 +4,7 @@ namespace Tests\E2E\Services\Storage;
use CURLFile;
use Tests\E2E\Client;
use Utopia\Database\DateTime;
trait StorageBase
{
@ -41,7 +42,7 @@ trait StorageBase
]);
$this->assertEquals(201, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertIsString($file['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@ -102,7 +103,7 @@ trait StorageBase
$this->assertEquals(201, $largeFile['headers']['status-code']);
$this->assertNotEmpty($largeFile['body']['$id']);
$this->assertIsString($largeFile['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($largeFile['body']['$createdAt']));
$this->assertEquals('large-file.mp4', $largeFile['body']['name']);
$this->assertEquals('video/mp4', $largeFile['body']['mimeType']);
$this->assertEquals($totalSize, $largeFile['body']['sizeOriginal']);
@ -253,7 +254,7 @@ trait StorageBase
$this->assertEquals(200, $file1['headers']['status-code']);
$this->assertNotEmpty($file1['body']['$id']);
$this->assertIsString($file1['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($file1['body']['$createdAt']));
$this->assertEquals('logo.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
@ -547,7 +548,7 @@ trait StorageBase
$this->assertEquals(200, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertIsString($file['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);

View file

@ -10,6 +10,7 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\DateTime;
class StorageCustomClientTest extends Scope
{
@ -49,7 +50,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertIsString($file['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@ -138,7 +139,7 @@ class StorageCustomClientTest extends Scope
$this->assertNotEmpty($file['body']['$id']);
$this->assertContains('user:' . $this->getUser()['$id'], $file['body']['$read']);
$this->assertContains('user:' . $this->getUser()['$id'], $file['body']['$write']);
$this->assertIsString($file['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);

View file

@ -6,6 +6,7 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\Database\DateTime;
class StorageCustomServerTest extends Scope
{
@ -28,7 +29,7 @@ class StorageCustomServerTest extends Scope
]);
$this->assertEquals(201, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$this->assertIsString($bucket['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($bucket['body']['$createdAt']));
$this->assertIsArray($bucket['body']['$read']);
$this->assertIsArray($bucket['body']['$write']);
$this->assertIsArray($bucket['body']['allowedFileExtensions']);
@ -187,7 +188,7 @@ class StorageCustomServerTest extends Scope
]);
$this->assertEquals(200, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$this->assertIsString($bucket['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($bucket['body']['$createdAt']));
$this->assertIsArray($bucket['body']['$read']);
$this->assertIsArray($bucket['body']['$write']);
$this->assertIsArray($bucket['body']['allowedFileExtensions']);

View file

@ -4,6 +4,7 @@ namespace Tests\E2E\Services\Teams;
use Tests\E2E\Client;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
trait TeamsBase
{
@ -25,7 +26,7 @@ trait TeamsBase
$this->assertEquals('Arsenal', $response1['body']['name']);
$this->assertGreaterThan(-1, $response1['body']['total']);
$this->assertIsInt($response1['body']['total']);
$this->assertIsString($response1['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($response1['body']['$createdAt']));
$teamUid = $response1['body']['$id'];
$teamName = $response1['body']['name'];
@ -45,7 +46,7 @@ trait TeamsBase
$this->assertEquals('Manchester United', $response2['body']['name']);
$this->assertGreaterThan(-1, $response2['body']['total']);
$this->assertIsInt($response2['body']['total']);
$this->assertIsString($response2['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($response2['body']['$createdAt']));
$response3 = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
@ -60,8 +61,7 @@ trait TeamsBase
$this->assertEquals('Newcastle', $response3['body']['name']);
$this->assertGreaterThan(-1, $response3['body']['total']);
$this->assertIsInt($response3['body']['total']);
$this->assertIsString($response3['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($response3['body']['$createdAt']));
/**
* Test for FAILURE
*/
@ -96,7 +96,7 @@ trait TeamsBase
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsString($response['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
/**
* Test for FAILURE
@ -260,7 +260,7 @@ trait TeamsBase
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsString($response['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$response = $this->client->call(Client::METHOD_PUT, '/teams/' . $response['body']['$id'], array_merge([
'content-type' => 'application/json',
@ -275,7 +275,7 @@ trait TeamsBase
$this->assertEquals('Demo New', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsString($response['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
/**
* Test for FAILURE
@ -311,7 +311,7 @@ trait TeamsBase
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsString($response['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
$response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid, array_merge([
'content-type' => 'application/json',

View file

@ -3,6 +3,7 @@
namespace Tests\E2E\Services\Teams;
use Tests\E2E\Client;
use Utopia\Database\DateTime;
trait TeamsBaseClient
{
@ -110,7 +111,7 @@ trait TeamsBaseClient
$this->assertNotEmpty($response['body']['teamId']);
$this->assertNotEmpty($response['body']['teamName']);
$this->assertCount(2, $response['body']['roles']);
$this->assertIsString($response['body']['joined']);
$this->assertEquals(true, DateTime::isValid($response['body']['joined']));
$this->assertEquals(false, $response['body']['confirm']);
$lastEmail = $this->getLastEmail();
@ -244,7 +245,7 @@ trait TeamsBaseClient
$this->assertNotEmpty($response['body']['userId']);
$this->assertNotEmpty($response['body']['teamId']);
$this->assertCount(2, $response['body']['roles']);
$this->assertIsString($response['body']['joined']);
$this->assertEquals(true, DateTime::isValid($response['body']['joined']));
$this->assertEquals(true, $response['body']['confirm']);
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
$data['session'] = $session;
@ -267,7 +268,7 @@ trait TeamsBaseClient
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@ -301,7 +302,7 @@ trait TeamsBaseClient
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsString($response['body']['registration']);
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);

View file

@ -61,7 +61,7 @@ trait TeamsBaseServer
$this->assertNotEmpty($response['body']['userId']);
$this->assertNotEmpty($response['body']['teamId']);
$this->assertCount(2, $response['body']['roles']);
$this->assertIsString($response['body']['joined']);
$this->assertEquals(true, DateTime::isValid($response['body']['joined']));
$this->assertGreaterThan('2020-07-07 07:58:44', DateTime::getCurrentDateTime());
$this->assertEquals(true, $response['body']['confirm']);
@ -206,8 +206,7 @@ trait TeamsBaseServer
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsString($response['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
/** Delete User */
$user = $this->client->call(Client::METHOD_DELETE, '/users/' . $userUid, array_merge([
@ -232,6 +231,6 @@ trait TeamsBaseServer
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsString($response['body']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($response['body']['$createdAt']));
}
}

View file

@ -4,6 +4,7 @@ namespace Tests\E2E\Services\Webhooks;
use CURLFile;
use Tests\E2E\Client;
use Utopia\Database\DateTime;
trait WebhooksBase
{
@ -515,7 +516,7 @@ trait WebhooksBase
$this->assertIsArray($webhook['data']['$read']);
$this->assertIsArray($webhook['data']['$write']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertIsString($webhook['data']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['$createdAt']));
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@ -571,7 +572,7 @@ trait WebhooksBase
$this->assertIsArray($webhook['data']['$read']);
$this->assertIsArray($webhook['data']['$write']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertIsString($webhook['data']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['$createdAt']));
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@ -622,7 +623,7 @@ trait WebhooksBase
$this->assertIsArray($webhook['data']['$read']);
$this->assertIsArray($webhook['data']['$write']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertIsString($webhook['data']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['$createdAt']));
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@ -705,7 +706,7 @@ trait WebhooksBase
$this->assertEquals('Arsenal', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertIsString($webhook['data']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['$createdAt']));
/**
* Test for FAILURE
@ -750,7 +751,7 @@ trait WebhooksBase
$this->assertEquals('Demo New', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertIsString($webhook['data']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['$createdAt']));
/**
* Test for FAILURE
@ -799,7 +800,7 @@ trait WebhooksBase
$this->assertEquals('Chelsea', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertIsString($webhook['data']['$createdAt']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['$createdAt']));
/**
* Test for FAILURE
@ -860,7 +861,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['teamId']);
$this->assertCount(2, $webhook['data']['roles']);
$this->assertIsString($webhook['data']['joined']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['joined']));
$this->assertEquals(('server' === $this->getSide()), $webhook['data']['confirm']);
/**
@ -932,7 +933,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['teamId']);
$this->assertCount(2, $webhook['data']['roles']);
$this->assertIsString($webhook['data']['joined']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['joined']));
$this->assertEquals(('server' === $this->getSide()), $webhook['data']['confirm']);
}
}

View file

@ -6,6 +6,7 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\DateTime;
class WebhooksCustomClientTest extends Scope
{
@ -57,7 +58,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id']), true);
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $name);
$this->assertIsString($webhook['data']['registration']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['registration']));
$this->assertEquals($webhook['data']['status'], true);
$this->assertEquals($webhook['data']['email'], $email);
$this->assertEquals($webhook['data']['emailVerification'], false);
@ -133,7 +134,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $name);
$this->assertIsString($webhook['data']['registration']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['registration']));
$this->assertEquals($webhook['data']['status'], false);
$this->assertEquals($webhook['data']['email'], $email);
$this->assertEquals($webhook['data']['emailVerification'], false);
@ -193,7 +194,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id']), true);
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertIsString($webhook['data']['expire']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['expire']));
$this->assertEquals($webhook['data']['ip'], '127.0.0.1');
$this->assertNotEmpty($webhook['data']['osCode']);
$this->assertIsString($webhook['data']['osCode']);
@ -368,7 +369,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertIsString($webhook['data']['expire']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['expire']));
$this->assertEquals($webhook['data']['ip'], '127.0.0.1');
$this->assertNotEmpty($webhook['data']['osCode']);
$this->assertIsString($webhook['data']['osCode']);
@ -679,7 +680,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertIsString($webhook['data']['expire']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['expire']));
$data['secret'] = $webhook['data']['secret'];
@ -739,7 +740,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertIsString($webhook['data']['expire']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['expire']));
$data['secret'] = $webhook['data']['secret'];
@ -795,7 +796,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertIsString($webhook['data']['expire']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['expire']));
$data['secret'] = $webhook['data']['secret'];
@ -853,7 +854,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertIsString($webhook['data']['expire']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['expire']));
$data['secret'] = $webhook['data']['secret'];
@ -916,7 +917,7 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['teamId']);
$this->assertCount(2, $webhook['data']['roles']);
$this->assertIsString($webhook['data']['joined']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['joined']));
$this->assertEquals(true, $webhook['data']['confirm']);
/**

View file

@ -8,6 +8,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\CLI\Console;
use Utopia\Database\DateTime;
class WebhooksCustomServerTest extends Scope
{
@ -241,7 +242,7 @@ class WebhooksCustomServerTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $name);
$this->assertIsString($webhook['data']['registration']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['registration']));
$this->assertEquals($webhook['data']['status'], true);
$this->assertEquals($webhook['data']['email'], $email);
$this->assertEquals($webhook['data']['emailVerification'], false);
@ -332,7 +333,7 @@ class WebhooksCustomServerTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $data['name']);
$this->assertIsString($webhook['data']['registration']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['registration']));
$this->assertEquals($webhook['data']['status'], false);
$this->assertEquals($webhook['data']['email'], $data['email']);
$this->assertEquals($webhook['data']['emailVerification'], false);
@ -374,7 +375,7 @@ class WebhooksCustomServerTest extends Scope
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $data['name']);
$this->assertIsString($webhook['data']['registration']);
$this->assertEquals(true, DateTime::isValid($webhook['body']['registration']));
$this->assertEquals($webhook['data']['status'], false);
$this->assertEquals($webhook['data']['email'], $data['email']);
$this->assertEquals($webhook['data']['emailVerification'], false);