remove static $dateValidator

This commit is contained in:
fogelito
2022-12-19 13:21:09 +02:00
parent bdc3e9f935
commit 91db596b42
16 changed files with 183 additions and 99 deletions
Generated
+11 -10
View File
@@ -874,6 +874,7 @@
"issues": "https://github.com/influxdata/influxdb-php/issues",
"source": "https://github.com/influxdata/influxdb-php/tree/1.15.2"
},
"abandoned": true,
"time": "2020-12-26T17:45:17+00:00"
},
{
@@ -2120,12 +2121,12 @@
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "703f5daa6341e3c7bf97e3ccd5ebae75198c5caf"
"reference": "08ee675eace0a4ab7ae779fec842a436e9cad3db"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/703f5daa6341e3c7bf97e3ccd5ebae75198c5caf",
"reference": "703f5daa6341e3c7bf97e3ccd5ebae75198c5caf",
"url": "https://api.github.com/repos/utopia-php/database/zipball/08ee675eace0a4ab7ae779fec842a436e9cad3db",
"reference": "08ee675eace0a4ab7ae779fec842a436e9cad3db",
"shasum": ""
},
"require": {
@@ -2167,7 +2168,7 @@
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/feat-technical-debt"
},
"time": "2022-12-13T15:36:09+00:00"
"time": "2022-12-19T07:31:10+00:00"
},
{
"name": "utopia-php/domains",
@@ -3700,16 +3701,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "9.2.21",
"version": "9.2.22",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "3f893e19712bb0c8bc86665d1562e9fd509c4ef0"
"reference": "e4bf60d2220b4baaa0572986b5d69870226b06df"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/3f893e19712bb0c8bc86665d1562e9fd509c4ef0",
"reference": "3f893e19712bb0c8bc86665d1562e9fd509c4ef0",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/e4bf60d2220b4baaa0572986b5d69870226b06df",
"reference": "e4bf60d2220b4baaa0572986b5d69870226b06df",
"shasum": ""
},
"require": {
@@ -3765,7 +3766,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.21"
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.22"
},
"funding": [
{
@@ -3773,7 +3774,7 @@
"type": "github"
}
],
"time": "2022-12-14T13:26:54+00:00"
"time": "2022-12-18T16:40:55+00:00"
},
{
"name": "phpunit/php-file-iterator",
+5 -3
View File
@@ -11,6 +11,7 @@ use CURLFile;
use Tests\E2E\Services\Functions\FunctionsBase;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\DatetimeValidator;
class UsageTest extends Scope
{
@@ -600,6 +601,7 @@ class UsageTest extends Scope
/** @depends testDatabaseStats */
public function testPrepareFunctionsStats(array $data): array
{
$dateValidator = new DatetimeValidator();
$headers = $data['headers'];
$functionId = '';
$executionTime = 0;
@@ -641,7 +643,7 @@ class UsageTest extends Scope
$this->assertEquals(202, $deployment['headers']['status-code']);
$this->assertNotEmpty($deployment['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($deployment['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($deployment['body']['$createdAt']));
$this->assertEquals('index.php', $deployment['body']['entrypoint']);
// Wait for deployment to build.
@@ -651,8 +653,8 @@ class UsageTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$updatedAt']));
$this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($response['body']['$updatedAt']));
$this->assertEquals($deploymentId, $response['body']['deployment']);
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', $headers, [
-2
View File
@@ -29,8 +29,6 @@ abstract class Scope extends TestCase
$this->client
->setEndpoint($this->endpoint)
;
self::$dateValidator = new DatetimeValidator();
}
protected function tearDown(): void
+25 -13
View File
@@ -6,6 +6,7 @@ use Appwrite\Tests\Retry;
use Tests\E2E\Client;
use Utopia\Database\Helpers\ID;
use Utopia\Database\DateTime;
use Utopia\Database\Validator\DatetimeValidator;
trait AccountBase
{
@@ -34,7 +35,8 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@@ -198,7 +200,8 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@@ -343,7 +346,8 @@ trait AccountBase
$this->assertIsNumeric($response['body']['total']);
$this->assertContains($response['body']['logs'][1]['event'], ["session.create"]);
$this->assertEquals($response['body']['logs'][1]['ip'], filter_var($response['body']['logs'][1]['ip'], FILTER_VALIDATE_IP));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['logs'][1]['time']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['logs'][1]['time']));
$this->assertEquals('Windows', $response['body']['logs'][1]['osName']);
$this->assertEquals('WIN', $response['body']['logs'][1]['osCode']);
@@ -365,7 +369,7 @@ trait AccountBase
$this->assertContains($response['body']['logs'][2]['event'], ["user.create"]);
$this->assertEquals($response['body']['logs'][2]['ip'], filter_var($response['body']['logs'][2]['ip'], FILTER_VALIDATE_IP));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['logs'][2]['time']));
$this->assertEquals(true, $dateValidator->isValid($response['body']['logs'][2]['time']));
$this->assertEquals('Windows', $response['body']['logs'][2]['osName']);
$this->assertEquals('WIN', $response['body']['logs'][2]['osCode']);
@@ -476,7 +480,8 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $newName);
@@ -543,7 +548,8 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@@ -633,7 +639,8 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $newEmail);
/**
@@ -675,7 +682,7 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $data['email']);
$this->assertEquals($response['body']['name'], $data['name']);
@@ -817,7 +824,8 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['expire']));
$lastEmail = $this->getLastEmail();
@@ -1119,7 +1127,8 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['expire']));
$lastEmail = $this->getLastEmail();
@@ -1273,7 +1282,8 @@ trait AccountBase
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['expire']));
$userId = $response['body']['userId'];
@@ -1379,7 +1389,8 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertTrue($response['body']['emailVerification']);
@@ -1439,7 +1450,8 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@@ -10,6 +10,7 @@ use Tests\E2E\Scopes\SideClient;
use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\DatetimeValidator;
use function sleep;
class AccountCustomClientTest extends Scope
@@ -448,7 +449,8 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@@ -699,7 +701,8 @@ class AccountCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['expire']));
$userId = $response['body']['userId'];
@@ -799,7 +802,8 @@ class AccountCustomClientTest extends Scope
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['phone'], $number);
$this->assertTrue($response['body']['phoneVerification']);
@@ -850,7 +854,8 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
@@ -892,7 +897,8 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['phone'], $newPhone);
/**
@@ -941,7 +947,8 @@ class AccountCustomClientTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEmpty($response['body']['secret']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['expire']));
\sleep(2);
@@ -6,6 +6,7 @@ use Tests\E2E\Client;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\DatetimeValidator;
trait DatabasesBase
{
@@ -1530,8 +1531,9 @@ trait DatabasesBase
$this->assertEquals($databaseId, $document['body']['$databaseId']);
$this->assertEquals($document['body']['title'], 'Thor: Ragnaroc');
$this->assertEquals($document['body']['releaseYear'], 2017);
$this->assertEquals(true, self::$dateValidator->isValid($document['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($document['body']['birthDay']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($document['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($document['body']['birthDay']));
$this->assertContains(Permission::read(Role::user($this->getUser()['$id'])), $document['body']['$permissions']);
$this->assertContains(Permission::update(Role::user($this->getUser()['$id'])), $document['body']['$permissions']);
$this->assertContains(Permission::delete(Role::user($this->getUser()['$id'])), $document['body']['$permissions']);
@@ -12,6 +12,7 @@ use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\DatetimeValidator;
class FunctionsCustomServerTest extends Scope
{
@@ -45,8 +46,9 @@ class FunctionsCustomServerTest extends Scope
$this->assertNotEmpty($response1['body']['$id']);
$this->assertEquals('Test', $response1['body']['name']);
$this->assertEquals('php-8.0', $response1['body']['runtime']);
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$updatedAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response1['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($response1['body']['$updatedAt']));
$this->assertEquals('', $response1['body']['deployment']);
$this->assertEquals([
'users.*.create',
@@ -328,8 +330,9 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $response1['headers']['status-code']);
$this->assertNotEmpty($response1['body']['$id']);
$this->assertEquals('Test1', $response1['body']['name']);
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$updatedAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response1['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($response1['body']['$updatedAt']));
$this->assertEquals('', $response1['body']['deployment']);
$this->assertEquals([
'users.*.update.name',
@@ -369,7 +372,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(202, $deployment['headers']['status-code']);
$this->assertNotEmpty($deployment['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($deployment['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($deployment['body']['$createdAt']));
$this->assertEquals('index.php', $deployment['body']['entrypoint']);
// Wait for deployment to build.
@@ -418,7 +422,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(202, $largeTag['headers']['status-code']);
$this->assertNotEmpty($largeTag['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($largeTag['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($largeTag['body']['$createdAt']));
$this->assertEquals('index.php', $largeTag['body']['entrypoint']);
$this->assertGreaterThan(10000, $largeTag['body']['size']);
@@ -440,8 +445,9 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$updatedAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($response['body']['$updatedAt']));
$this->assertEquals($data['deploymentId'], $response['body']['deployment']);
/**
@@ -606,7 +612,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(202, $execution['headers']['status-code']);
$this->assertNotEmpty($execution['body']['$id']);
$this->assertNotEmpty($execution['body']['functionId']);
$this->assertEquals(true, self::$dateValidator->isValid($execution['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($execution['body']['$createdAt']));
$this->assertEquals($data['functionId'], $execution['body']['functionId']);
$this->assertEquals('waiting', $execution['body']['status']);
$this->assertEquals(0, $execution['body']['statusCode']);
@@ -623,7 +630,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertNotEmpty($execution['body']['$id']);
$this->assertNotEmpty($execution['body']['functionId']);
$this->assertEquals(true, self::$dateValidator->isValid($execution['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($execution['body']['$createdAt']));
$this->assertEquals($data['functionId'], $execution['body']['functionId']);
$this->assertEquals('completed', $execution['body']['status']);
$this->assertEquals(200, $execution['body']['statusCode']);
+10 -5
View File
@@ -8,6 +8,7 @@ use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\DatetimeValidator;
trait StorageBase
{
@@ -52,7 +53,8 @@ trait StorageBase
]);
$this->assertEquals(201, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -120,7 +122,7 @@ trait StorageBase
$this->assertEquals(201, $largeFile['headers']['status-code']);
$this->assertNotEmpty($largeFile['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($largeFile['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->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']);
@@ -283,7 +285,8 @@ trait StorageBase
]);
$this->assertEquals(201, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -373,7 +376,8 @@ trait StorageBase
$this->assertEquals(200, $file1['headers']['status-code']);
$this->assertNotEmpty($file1['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($file1['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file1['body']['$createdAt']));
$this->assertEquals('logo.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
@@ -712,7 +716,8 @@ trait StorageBase
$this->assertEquals(200, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -17,6 +17,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\DatetimeValidator;
class StorageCustomClientTest extends Scope
{
@@ -63,7 +64,8 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -159,7 +161,8 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -245,7 +248,8 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -370,7 +374,8 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -548,7 +553,8 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -710,7 +716,8 @@ class StorageCustomClientTest extends Scope
$fileId = $file1['body']['$id'];
$this->assertEquals($file1['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, self::$dateValidator->isValid($file1['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file1['body']['$createdAt']));
$this->assertEquals('permissions.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
@@ -799,7 +806,8 @@ class StorageCustomClientTest extends Scope
$fileId = $file1['body']['$id'];
$this->assertEquals($file1['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, self::$dateValidator->isValid($file1['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file1['body']['$createdAt']));
$this->assertEquals('permissions.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
@@ -888,7 +896,8 @@ class StorageCustomClientTest extends Scope
$fileId = $file1['body']['$id'];
$this->assertEquals($file1['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, self::$dateValidator->isValid($file1['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file1['body']['$createdAt']));
$this->assertEquals('permissions.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
@@ -1027,7 +1036,8 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -1262,7 +1272,8 @@ class StorageCustomClientTest extends Scope
$this->assertContains(Permission::read(Role::user($this->getUser()['$id'])), $file['body']['$permissions']);
$this->assertContains(Permission::update(Role::user($this->getUser()['$id'])), $file['body']['$permissions']);
$this->assertContains(Permission::delete(Role::user($this->getUser()['$id'])), $file['body']['$permissions']);
$this->assertEquals(true, self::$dateValidator->isValid($file['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($file['body']['$createdAt']));
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@@ -8,6 +8,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\DatetimeValidator;
class StorageCustomServerTest extends Scope
{
@@ -30,7 +31,8 @@ class StorageCustomServerTest extends Scope
]);
$this->assertEquals(201, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($bucket['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($bucket['body']['$createdAt']));
$this->assertIsArray($bucket['body']['$permissions']);
$this->assertIsArray($bucket['body']['allowedFileExtensions']);
$this->assertEquals('Test Bucket', $bucket['body']['name']);
@@ -228,7 +230,8 @@ class StorageCustomServerTest extends Scope
]);
$this->assertEquals(200, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($bucket['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($bucket['body']['$createdAt']));
$this->assertIsArray($bucket['body']['$permissions']);
$this->assertIsArray($bucket['body']['allowedFileExtensions']);
$this->assertEquals('Test Bucket Updated', $bucket['body']['name']);
+12 -7
View File
@@ -6,6 +6,7 @@ use Tests\E2E\Client;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\DatetimeValidator;
trait TeamsBase
{
@@ -28,7 +29,8 @@ trait TeamsBase
$this->assertEquals('Arsenal', $response1['body']['name']);
$this->assertGreaterThan(-1, $response1['body']['total']);
$this->assertIsInt($response1['body']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($response1['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response1['body']['$createdAt']));
$teamUid = $response1['body']['$id'];
$teamName = $response1['body']['name'];
@@ -48,7 +50,7 @@ trait TeamsBase
$this->assertEquals('Manchester United', $response2['body']['name']);
$this->assertGreaterThan(-1, $response2['body']['total']);
$this->assertIsInt($response2['body']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($response2['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($response2['body']['$createdAt']));
$response3 = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
@@ -63,7 +65,7 @@ trait TeamsBase
$this->assertEquals('Newcastle', $response3['body']['name']);
$this->assertGreaterThan(-1, $response3['body']['total']);
$this->assertIsInt($response3['body']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($response3['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($response3['body']['$createdAt']));
/**
* Test for FAILURE
*/
@@ -98,7 +100,8 @@ trait TeamsBase
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt']));
/**
* Test for FAILURE
@@ -275,7 +278,8 @@ trait TeamsBase
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt']));
$response = $this->client->call(Client::METHOD_PUT, '/teams/' . $response['body']['$id'], array_merge([
'content-type' => 'application/json',
@@ -290,7 +294,7 @@ trait TeamsBase
$this->assertEquals('Demo New', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt']));
/**
* Test for FAILURE
@@ -326,7 +330,8 @@ trait TeamsBase
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt']));
$response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid, array_merge([
'content-type' => 'application/json',
+9 -5
View File
@@ -5,6 +5,7 @@ namespace Tests\E2E\Services\Teams;
use Tests\E2E\Client;
use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\DatetimeValidator;
trait TeamsBaseClient
{
@@ -150,7 +151,8 @@ trait TeamsBaseClient
$this->assertNotEmpty($response['body']['teamId']);
$this->assertNotEmpty($response['body']['teamName']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(false, self::$dateValidator->isValid($response['body']['joined'])); // is null in DB
$dateValidator = new DatetimeValidator();
$this->assertEquals(false, $dateValidator->isValid($response['body']['joined'])); // is null in DB
$this->assertEquals(false, $response['body']['confirm']);
/**
@@ -203,7 +205,8 @@ trait TeamsBaseClient
$this->assertNotEmpty($response['body']['teamId']);
$this->assertNotEmpty($response['body']['teamName']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(false, self::$dateValidator->isValid($response['body']['joined'])); // is null in DB
$dateValidator = new DatetimeValidator();
$this->assertEquals(false, $dateValidator->isValid($response['body']['joined'])); // is null in DB
$this->assertEquals(false, $response['body']['confirm']);
$lastEmail = $this->getLastEmail();
@@ -337,7 +340,8 @@ trait TeamsBaseClient
$this->assertNotEmpty($response['body']['userId']);
$this->assertNotEmpty($response['body']['teamId']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['joined']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->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;
@@ -369,7 +373,7 @@ trait TeamsBaseClient
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@@ -403,7 +407,7 @@ trait TeamsBaseClient
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['registration']));
$this->assertEquals(true, $dateValidator->isValid($response['body']['registration']));
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
+8 -4
View File
@@ -5,6 +5,7 @@ namespace Tests\E2E\Services\Teams;
use Tests\E2E\Client;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
use Utopia\Database\Validator\DatetimeValidator;
trait TeamsBaseServer
{
@@ -57,7 +58,8 @@ trait TeamsBaseServer
$this->assertNotEmpty($response['body']['teamId']);
$this->assertNotEmpty($response['body']['teamName']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['joined'])); // is null in DB
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['joined'])); // is null in DB
$this->assertEquals(true, $response['body']['confirm']);
/**
@@ -108,7 +110,8 @@ trait TeamsBaseServer
$this->assertEquals($email, $response['body']['userEmail']);
$this->assertNotEmpty($response['body']['teamId']);
$this->assertCount(2, $response['body']['roles']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['joined']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['joined']));
$this->assertEquals(true, $response['body']['confirm']);
$userUid = $response['body']['userId'];
@@ -252,7 +255,8 @@ trait TeamsBaseServer
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt']));
/** Delete User */
$user = $this->client->call(Client::METHOD_DELETE, '/users/' . $userUid, array_merge([
@@ -277,6 +281,6 @@ trait TeamsBaseServer
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($response['body']['$createdAt']));
$this->assertEquals(true, $dateValidator->isValid($response['body']['$createdAt']));
}
}
+17 -8
View File
@@ -9,6 +9,7 @@ use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\DatetimeValidator;
trait WebhooksBase
{
@@ -529,7 +530,8 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['$createdAt']));
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@@ -587,7 +589,8 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['$createdAt']));
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@@ -637,7 +640,8 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['$createdAt']));
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@@ -719,7 +723,8 @@ trait WebhooksBase
$this->assertEquals('Arsenal', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['$createdAt']));
/**
* Test for FAILURE
@@ -764,7 +769,8 @@ trait WebhooksBase
$this->assertEquals('Demo New', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['$createdAt']));
/**
* Test for FAILURE
@@ -813,7 +819,8 @@ trait WebhooksBase
$this->assertEquals('Chelsea', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['$createdAt']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['$createdAt']));
/**
* Test for FAILURE
@@ -874,7 +881,8 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['teamId']);
$this->assertCount(2, $webhook['data']['roles']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['invited']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['invited']));
$this->assertEquals(('server' === $this->getSide()), $webhook['data']['confirm']);
/**
@@ -946,7 +954,8 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['teamId']);
$this->assertCount(2, $webhook['data']['roles']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['invited']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['invited']));
$this->assertEquals(('server' === $this->getSide()), $webhook['data']['confirm']);
}
}
@@ -9,6 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\DatetimeValidator;
class WebhooksCustomClientTest extends Scope
{
@@ -60,7 +61,8 @@ 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->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], true);
$this->assertEquals($webhook['data']['email'], $email);
$this->assertEquals($webhook['data']['emailVerification'], false);
@@ -136,7 +138,8 @@ 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->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], false);
$this->assertEquals($webhook['data']['email'], $email);
$this->assertEquals($webhook['data']['emailVerification'], false);
@@ -196,7 +199,8 @@ 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->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['expire']));
$this->assertEquals($webhook['data']['ip'], '127.0.0.1');
$this->assertNotEmpty($webhook['data']['osCode']);
$this->assertIsString($webhook['data']['osCode']);
@@ -371,7 +375,8 @@ 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->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['expire']));
$this->assertEquals($webhook['data']['ip'], '127.0.0.1');
$this->assertNotEmpty($webhook['data']['osCode']);
$this->assertIsString($webhook['data']['osCode']);
@@ -683,7 +688,8 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['expire']));
$data['secret'] = $webhook['data']['secret'];
@@ -743,7 +749,8 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['expire']));
$data['secret'] = $webhook['data']['secret'];
@@ -799,7 +806,8 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['expire']));
$data['secret'] = $webhook['data']['secret'];
@@ -857,7 +865,8 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['secret']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['expire']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['expire']));
$data['secret'] = $webhook['data']['secret'];
@@ -920,7 +929,8 @@ class WebhooksCustomClientTest extends Scope
$this->assertNotEmpty($webhook['data']['userId']);
$this->assertNotEmpty($webhook['data']['teamId']);
$this->assertCount(2, $webhook['data']['roles']);
$this->assertEquals(true, self::$dateValidator->isValid($webhook['data']['joined']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['joined']));
$this->assertEquals(true, $webhook['data']['confirm']);
/**
@@ -12,6 +12,7 @@ use Utopia\Database\DateTime;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\DatetimeValidator;
class WebhooksCustomServerTest extends Scope
{
@@ -245,7 +246,8 @@ 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->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], true);
$this->assertEquals($webhook['data']['email'], $email);
$this->assertEquals($webhook['data']['emailVerification'], false);
@@ -336,7 +338,8 @@ 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->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], false);
$this->assertEquals($webhook['data']['email'], $data['email']);
$this->assertEquals($webhook['data']['emailVerification'], false);
@@ -378,7 +381,8 @@ 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->assertEquals(true, self::$dateValidator->isValid($webhook['data']['registration']));
$dateValidator = new DatetimeValidator();
$this->assertEquals(true, $dateValidator->isValid($webhook['data']['registration']));
$this->assertEquals($webhook['data']['status'], false);
$this->assertEquals($webhook['data']['email'], $data['email']);
$this->assertEquals($webhook['data']['emailVerification'], false);