ID updates

This commit is contained in:
Jake Barnby
2022-08-14 22:33:36 +12:00
parent a8698b6065
commit b007acfa95
61 changed files with 1010 additions and 928 deletions
+3 -1
View File
@@ -2,12 +2,14 @@
namespace Tests\E2E\Scopes;
use Utopia\Database\ID;
trait ProjectConsole
{
public function getProject(): array
{
return [
'$id' => 'console',
'$id' => ID::custom('console'),
'name' => 'Appwrite',
'apiKey' => '',
];
+3 -2
View File
@@ -3,6 +3,7 @@
namespace Tests\E2E\Scopes;
use Tests\E2E\Client;
use Utopia\Database\ID;
trait ProjectCustom
{
@@ -26,7 +27,7 @@ trait ProjectCustom
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
'x-appwrite-project' => 'console',
], [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Demo Project Team',
]);
$this->assertEquals(201, $team['headers']['status-code']);
@@ -39,7 +40,7 @@ trait ProjectCustom
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
'x-appwrite-project' => 'console',
], [
'projectId' => 'unique()',
'projectId' => ID::unique(),
'name' => 'Demo Project',
'teamId' => $team['body']['$id'],
'description' => 'Demo Project Description',
+5 -4
View File
@@ -4,6 +4,7 @@ namespace Tests\E2E\Scopes;
use Tests\E2E\Client;
use PHPUnit\Framework\TestCase;
use Utopia\Database\ID;
abstract class Scope extends TestCase
{
@@ -87,7 +88,7 @@ abstract class Scope extends TestCase
'content-type' => 'application/json',
'x-appwrite-project' => 'console',
], [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -107,7 +108,7 @@ abstract class Scope extends TestCase
$session = $this->client->parseCookie((string)$session['headers']['set-cookie'])['a_session_console'];
self::$root = [
'$id' => $root['body']['$id'],
'$id' => ID::custom($root['body']['$id']),
'name' => $root['body']['name'],
'email' => $root['body']['email'],
'session' => $session,
@@ -139,7 +140,7 @@ abstract class Scope extends TestCase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -159,7 +160,7 @@ abstract class Scope extends TestCase
$session = $this->client->parseCookie((string)$session['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
self::$user[$this->getProject()['$id']] = [
'$id' => $user['body']['$id'],
'$id' => ID::custom($user['body']['$id']),
'name' => $user['body']['name'],
'email' => $user['body']['email'],
'session' => $session,
+15 -14
View File
@@ -3,6 +3,7 @@
namespace Tests\E2E\Services\Account;
use Tests\E2E\Client;
use Utopia\Database\ID;
trait AccountBase
{
@@ -20,7 +21,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -43,7 +44,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -56,7 +57,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => '',
'password' => '',
]);
@@ -68,7 +69,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => '',
]);
@@ -80,7 +81,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => '',
'password' => $password,
]);
@@ -340,7 +341,7 @@ trait AccountBase
$this->assertIsNumeric($response['body']['total']);
$this->assertContains($response['body']['logs'][1]['event'], ["users.{$userId}.create", "users.{$userId}.sessions.{$sessionId}.create"]);
$this->assertEquals($response['body']['logs'][1]['ip'], filter_var($response['body']['logs'][1]['ip'], FILTER_VALIDATE_IP));
$this->assertIsNumeric($response['body']['logs'][1]['time']);
$this->assertIsString($response['body']['logs'][1]['time']);
$this->assertEquals('Windows', $response['body']['logs'][1]['osName']);
$this->assertEquals('WIN', $response['body']['logs'][1]['osCode']);
@@ -362,7 +363,7 @@ trait AccountBase
$this->assertContains($response['body']['logs'][2]['event'], ["users.{$userId}.create", "users.{$userId}.sessions.{$sessionId}.create"]);
$this->assertEquals($response['body']['logs'][2]['ip'], filter_var($response['body']['logs'][2]['ip'], FILTER_VALIDATE_IP));
$this->assertIsNumeric($response['body']['logs'][2]['time']);
$this->assertIsString($response['body']['logs'][2]['time']);
$this->assertEquals('Windows', $response['body']['logs'][2]['osName']);
$this->assertEquals('WIN', $response['body']['logs'][2]['osCode']);
@@ -663,7 +664,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $data['email'],
'password' => $data['password'],
'name' => $data['name'],
@@ -899,7 +900,7 @@ trait AccountBase
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
]), [
'userId' => 'ewewe',
'userId' => ID::custom('ewewe'),
'secret' => $verification,
]);
@@ -1214,7 +1215,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'ewewe',
'userId' => ID::custom('ewewe'),
'secret' => $recovery,
'password' => $newPassowrd,
'passwordAgain' => $newPassowrd,
@@ -1263,7 +1264,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
// 'url' => 'http://localhost/magiclogin',
]);
@@ -1301,7 +1302,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'url' => 'localhost/magiclogin',
]);
@@ -1313,7 +1314,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'url' => 'http://remotehost/magiclogin',
]);
@@ -1389,7 +1390,7 @@ trait AccountBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'ewewe',
'userId' => ID::custom('ewewe'),
'secret' => $token,
]);
@@ -8,6 +8,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\ID;
use function sleep;
class AccountCustomClientTest extends Scope
@@ -70,7 +71,7 @@ class AccountCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -151,7 +152,7 @@ class AccountCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -230,7 +231,7 @@ class AccountCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -410,7 +411,7 @@ class AccountCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password
]);
@@ -689,7 +690,7 @@ class AccountCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'number' => $number,
]);
@@ -708,7 +709,7 @@ class AccountCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()'
'userId' => ID::unique()
]);
$this->assertEquals(400, $response['headers']['status-code']);
@@ -737,7 +738,7 @@ class AccountCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'ewewe',
'userId' => ID::custom('ewewe'),
'secret' => $token,
]);
@@ -963,7 +964,7 @@ class AccountCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
]), [
'userId' => 'ewewe',
'userId' => ID::custom('ewewe'),
'secret' => Mock::$defaultDigits,
]);
@@ -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\ID;
class AccountCustomServerTest extends Scope
{
@@ -26,7 +27,7 @@ class AccountCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
+145 -142
View File
@@ -4,6 +4,9 @@ namespace Tests\E2E\Services\Databases;
use Tests\E2E\Client;
use Utopia\Database\Database;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
trait DatabasesBase
{
@@ -17,7 +20,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'Test Database'
]);
@@ -42,7 +45,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::read(Role::any()),
@@ -86,14 +89,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Captain America',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
],
]);
@@ -225,7 +228,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Response Models',
'permissions' => [],
'documentSecurity' => true,
@@ -782,7 +785,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
@@ -792,9 +795,9 @@ trait DatabasesBase
]
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -802,7 +805,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Spider-Man: Far From Home',
'releaseYear' => 2019,
@@ -813,9 +816,9 @@ trait DatabasesBase
]
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -823,7 +826,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Spider-Man: Homecoming',
'releaseYear' => 2017,
@@ -834,9 +837,9 @@ trait DatabasesBase
],
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -844,14 +847,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'releaseYear' => 2020, // Missing title, expect an 400 error
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -942,7 +945,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'databaseId' => 'default',
'databaseId' => ID::custom('default'),
'name' => 'Default'
]);
@@ -958,7 +961,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Movies',
'permissions' => [],
'documentSecurity' => true,
@@ -1420,7 +1423,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Thor: Ragnaroc',
'releaseYear' => 2017,
@@ -1428,9 +1431,9 @@ trait DatabasesBase
'$createdAt' => 5 // Should be ignored
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
],
]);
@@ -1491,16 +1494,16 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Thor: Ragnarok',
'releaseYear' => 2017,
'actors' => [],
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1539,7 +1542,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'InvalidDocumentDatabase',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -1551,7 +1554,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'invalidDocumentStructure',
'permissions' => [
Permission::create(Role::any()),
@@ -1687,7 +1690,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'attributeId' => 'defaultRequired',
'attributeId' => ID::custom('defaultRequired'),
'required' => true,
'default' => 12
]);
@@ -1697,7 +1700,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'attributeId' => 'enumDefault',
'attributeId' => ID::custom('enumDefault'),
'elements' => ['north', 'west'],
'default' => 'south'
]);
@@ -1707,7 +1710,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'attributeId' => 'enumDefault',
'attributeId' => ID::custom('enumDefault'),
'elements' => ['north', 'west'],
'default' => 'NORTH'
]);
@@ -1748,14 +1751,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'email' => 'user@example.com',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1763,14 +1766,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'enum' => 'yes',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1778,14 +1781,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'ip' => '1.1.1.1',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1793,14 +1796,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'url' => 'http://www.example.com',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1808,14 +1811,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'range' => 3,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1823,14 +1826,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'floatRange' => 1.4,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1838,14 +1841,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'probability' => 0.99999,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1853,14 +1856,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'upperBound' => 8,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1868,14 +1871,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'lowerBound' => 8,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1897,14 +1900,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'email' => 'user@@example.com',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1912,14 +1915,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'enum' => 'badEnum',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1927,14 +1930,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'ip' => '1.1.1.1.1',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1942,14 +1945,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'url' => 'example...com',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1957,14 +1960,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'range' => 11,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1972,14 +1975,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'floatRange' => 2.5,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -1987,14 +1990,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'probability' => 1.1,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -2002,14 +2005,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'upperBound' => 11,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -2017,14 +2020,14 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'lowerBound' => 3,
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -2058,7 +2061,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
@@ -2156,7 +2159,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'EnforceCollectionPermissions',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -2169,7 +2172,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'enforceCollectionPermissions',
'documentSecurity' => true,
'permissions' => [
@@ -2224,7 +2227,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'attribute' => 'one',
],
@@ -2241,7 +2244,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'attribute' => 'one',
],
@@ -2258,13 +2261,13 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'attribute' => 'one',
],
'permissions' => [
Permission::read(Role::user('other')),
Permission::update(Role::user('other')),
Permission::read(Role::user(ID::custom('other'))),
Permission::update(Role::user(ID::custom('other'))),
],
]);
@@ -2301,7 +2304,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], [
'userId' => 'other',
'userId' => ID::custom('other'),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -2370,7 +2373,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
@@ -2380,9 +2383,9 @@ trait DatabasesBase
]
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -2393,7 +2396,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Captain America 5',
'releaseYear' => 1944,
@@ -2403,9 +2406,9 @@ trait DatabasesBase
]
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -2416,7 +2419,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
@@ -2426,9 +2429,9 @@ trait DatabasesBase
]
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -2452,7 +2455,7 @@ trait DatabasesBase
];
$document = $this->client->call(Client::METHOD_POST, '/databases/' . $data['databaseId'] . '/collections/' . $data['moviesId'] . '/documents', $headers, [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Creation Date Test',
'releaseYear' => 2000
@@ -2506,7 +2509,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'Empty Permissions',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -2519,13 +2522,13 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::create(Role::user($this->getUser()['$id'])),
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::create(Role::user(ID::custom($this->getUser()['$id']))),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
],
'documentSecurity' => true,
]);
@@ -2556,7 +2559,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Captain America',
],
@@ -2581,7 +2584,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -2594,8 +2597,8 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'permissions' => [
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
],
]);
@@ -6,6 +6,9 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Client;
use Tests\E2E\Scopes\SideConsole;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
class DatabasesConsoleClientTest extends Scope
{
@@ -19,7 +22,7 @@ class DatabasesConsoleClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'invalidDocumentDatabase',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -33,7 +36,7 @@ class DatabasesConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::read(Role::any()),
@@ -6,6 +6,9 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
class DatabasesCustomClientTest extends Scope
{
@@ -32,7 +35,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'permissionCheckDatabase',
'databaseId' => ID::custom('permissionCheckDatabase'),
'name' => 'Test Database',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -45,7 +48,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'permissionCheck',
'collectionId' => ID::custom('permissionCheck'),
'name' => 'permissionCheck',
'permissions' => [],
'documentSecurity' => true,
@@ -73,15 +76,15 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => 'permissionCheckDocument',
'documentId' => ID::custom('permissionCheckDocument'),
'data' => [
'name' => 'AppwriteBeginner',
],
'permissions' => [
Permission::read(Role::user('user2')),
Permission::read(Role::user($userId)),
Permission::update(Role::user($userId)),
Permission::delete(Role::user($userId)),
Permission::read(Role::user(ID::custom('user2'))),
Permission::read(Role::user(ID::custom($userId))),
Permission::update(Role::user(ID::custom($userId))),
Permission::delete(Role::user(ID::custom($userId))),
],
]);
@@ -7,6 +7,9 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Tests\E2E\Client;
use Utopia\Database\Database;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
class DatabasesCustomServerTest extends Scope
{
@@ -21,7 +24,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'first',
'databaseId' => ID::custom('first'),
'name' => 'Test 1',
]);
$this->assertEquals(201, $test1['headers']['status-code']);
@@ -32,7 +35,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'second',
'databaseId' => ID::custom('second'),
'name' => 'Test 2',
]);
$this->assertEquals(201, $test2['headers']['status-code']);
@@ -172,7 +175,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Test 1',
'databaseId' => 'first',
'databaseId' => ID::custom('first'),
]);
$this->assertEquals(409, $response['headers']['status-code']);
@@ -233,7 +236,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'invalidDocumentDatabase',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -249,7 +252,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Test 1',
'collectionId' => 'first',
'collectionId' => ID::custom('first'),
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
@@ -265,7 +268,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Test 2',
'collectionId' => 'second',
'collectionId' => ID::custom('second'),
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
@@ -409,7 +412,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Test 1',
'collectionId' => 'first',
'collectionId' => ID::custom('first'),
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
@@ -429,7 +432,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'invalidDocumentDatabase',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -446,7 +449,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::any()),
@@ -499,7 +502,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'firstName' => 'lorem',
'lastName' => 'ipsum',
@@ -717,7 +720,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'invalidDocumentDatabase',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -729,7 +732,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'TestCleanupDuplicateIndexOnDeleteAttribute',
'permissions' => [
Permission::read(Role::any()),
@@ -849,15 +852,15 @@ class DatabasesCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'firstName' => 'Tom',
'lastName' => 'Holland',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
],
]);
@@ -865,15 +868,15 @@ class DatabasesCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'firstName' => 'Samuel',
'lastName' => 'Jackson',
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
],
]);
@@ -924,7 +927,7 @@ class DatabasesCustomServerTest extends Scope
// 'x-appwrite-project' => $this->getProject()['$id'],
// 'x-appwrite-key' => $this->getProject()['apiKey']
// ]), [
// 'collectionId' => 'unique()',
// 'collectionId' => ID::unique(),
// 'name' => 'attributeCountLimit',
// 'read' => ['any'],
// 'write' => ['any'],
@@ -969,7 +972,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'invalidDocumentDatabase',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -981,7 +984,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'attributeRowWidthLimit',
'collectionId' => ID::custom('attributeRowWidthLimit'),
'name' => 'attributeRowWidthLimit',
'permissions' => [
Permission::read(Role::any()),
@@ -1035,7 +1038,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'invalidDocumentDatabase',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -1047,7 +1050,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'testLimitException',
'collectionId' => ID::custom('testLimitException'),
'name' => 'testLimitException',
'permissions' => [
Permission::read(Role::any()),
@@ -6,6 +6,9 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
class DatabasesPermissionsGuestTest extends Scope
{
@@ -20,7 +23,7 @@ class DatabasesPermissionsGuestTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'InvalidDocumentDatabase',
]);
$this->assertEquals(201, $database['headers']['status-code']);
@@ -28,7 +31,7 @@ class DatabasesPermissionsGuestTest extends Scope
$databaseId = $database['body']['$id'];
$movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::read(Role::any()),
@@ -76,7 +79,7 @@ class DatabasesPermissionsGuestTest extends Scope
$collectionId = $data['collectionId'];
$databaseId = $data['databaseId'];
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents', $this->getServerHeader(), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@@ -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\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
@@ -30,10 +31,10 @@ class DatabasesPermissionsMemberTest extends Scope
return [
[[Permission::read(Role::any())]],
[[Permission::read(Role::users())]],
[[Permission::read(Role::user('random'))]],
[[Permission::read(Role::user('lorem')), Permission::update(Role::user('lorem')), Permission::delete(Role::user('lorem'))]],
[[Permission::read(Role::user('dolor')), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))]],
[[Permission::read(Role::user('dolor')), Permission::read(Role::user('lorem')), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))]],
[[Permission::read(Role::user(ID::custom('random')))]],
[[Permission::read(Role::user(ID::custom('lorem'))), Permission::update(Role::user('lorem')), Permission::delete(Role::user('lorem'))]],
[[Permission::read(Role::user(ID::custom('dolor'))), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))]],
[[Permission::read(Role::user(ID::custom('dolor'))), Permission::read(Role::user('lorem')), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))]],
[[Permission::update(Role::any()), Permission::delete(Role::any())]],
[[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())]],
[[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())]],
@@ -54,7 +55,7 @@ class DatabasesPermissionsMemberTest extends Scope
$this->createUsers();
$db = $this->client->call(Client::METHOD_POST, '/databases', $this->getServerHeader(), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'Test Database',
]);
$this->assertEquals(201, $db['headers']['status-code']);
@@ -62,7 +63,7 @@ class DatabasesPermissionsMemberTest extends Scope
$databaseId = $db['body']['$id'];
$public = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::read(Role::any()),
@@ -84,7 +85,7 @@ class DatabasesPermissionsMemberTest extends Scope
$this->assertEquals(202, $response['headers']['status-code']);
$private = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Private Movies',
'permissions' => [
Permission::read(Role::users()),
@@ -126,7 +127,7 @@ class DatabasesPermissionsMemberTest extends Scope
$databaseId = $data['databaseId'];
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collections['public'] . '/documents', $this->getServerHeader(), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@@ -135,7 +136,7 @@ class DatabasesPermissionsMemberTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collections['private'] . '/documents', $this->getServerHeader(), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@@ -6,6 +6,9 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
class DatabasesPermissionsTeamTest extends Scope
{
@@ -42,13 +45,13 @@ class DatabasesPermissionsTeamTest extends Scope
$this->assertEquals(201, $db['headers']['status-code']);
$collection1 = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => 'collection1',
'collectionId' => ID::custom('collection1'),
'name' => 'Collection 1',
'permissions' => [
Permission::read(Role::team($teams['team1']['$id'])),
Permission::create(Role::team($teams['team1']['$id'], 'admin')),
Permission::update(Role::team($teams['team1']['$id'], 'admin')),
Permission::delete(Role::team($teams['team1']['$id'], 'admin')),
Permission::read(Role::team(ID::custom($teams['team1']['$id']))),
Permission::create(Role::team(ID::custom($teams['team1']['$id']), 'admin')),
Permission::update(Role::team(ID::custom($teams['team1']['$id']), 'admin')),
Permission::delete(Role::team(ID::custom($teams['team1']['$id']), 'admin')),
],
]);
@@ -61,13 +64,13 @@ class DatabasesPermissionsTeamTest extends Scope
]);
$collection2 = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => 'collection2',
'collectionId' => ID::custom('collection2'),
'name' => 'Collection 2',
'permissions' => [
Permission::read(Role::team($teams['team2']['$id'])),
Permission::create(Role::team($teams['team2']['$id'], 'owner')),
Permission::update(Role::team($teams['team2']['$id'], 'owner')),
Permission::delete(Role::team($teams['team2']['$id'], 'owner')),
Permission::read(Role::team(ID::custom($teams['team2']['$id']))),
Permission::create(Role::team(ID::custom($teams['team2']['$id']), 'owner')),
Permission::update(Role::team(ID::custom($teams['team2']['$id']), 'owner')),
Permission::delete(Role::team(ID::custom($teams['team2']['$id']), 'owner')),
]
]);
@@ -138,7 +141,7 @@ class DatabasesPermissionsTeamTest extends Scope
$this->createCollections($this->teams);
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/collections/' . $this->collections['collection1'] . '/documents', $this->getServerHeader(), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@@ -146,7 +149,7 @@ class DatabasesPermissionsTeamTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/collections/' . $this->collections['collection2'] . '/documents', $this->getServerHeader(), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Ipsum',
],
@@ -189,7 +192,7 @@ class DatabasesPermissionsTeamTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $users[$user]['session'],
], [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'title' => 'Ipsum',
],
@@ -6,6 +6,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Client;
use Tests\E2E\Scopes\SideConsole;
use Utopia\Database\ID;
class FunctionsConsoleClientTest extends Scope
{
@@ -18,7 +19,7 @@ class FunctionsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test',
'execute' => ["user:{$this->getUser()['$id']}"],
'runtime' => 'php-8.0',
@@ -41,7 +42,7 @@ class FunctionsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test Failure',
'execute' => ['some-random-string'],
'runtime' => 'php-8.0'
@@ -9,6 +9,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\ID;
class FunctionsCustomClientTest extends Scope
{
@@ -25,7 +26,7 @@ class FunctionsCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test',
'vars' => [
'funcKey1' => 'funcValue1',
@@ -55,7 +56,7 @@ class FunctionsCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test',
'execute' => ["user:{$this->getUser()['$id']}"],
'runtime' => 'php-8.0',
@@ -145,7 +146,7 @@ class FunctionsCustomClientTest extends Scope
'x-appwrite-project' => $projectId,
'x-appwrite-key' => $apikey,
], [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test',
'execute' => ['any'],
'runtime' => 'php-8.0',
@@ -236,7 +237,7 @@ class FunctionsCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test',
'execute' => [],
'runtime' => 'php-8.0',
@@ -330,7 +331,7 @@ class FunctionsCustomClientTest extends Scope
'x-appwrite-project' => $projectId,
'x-appwrite-key' => $apikey,
], [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test',
'execute' => ['any'],
'runtime' => 'php-8.0',
@@ -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\ID;
class FunctionsCustomServerTest extends Scope
{
@@ -25,7 +26,7 @@ class FunctionsCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test',
'runtime' => 'php-8.0',
'vars' => [
@@ -123,7 +124,7 @@ class FunctionsCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test 2',
'runtime' => 'php-8.0',
'vars' => [
@@ -711,7 +712,7 @@ class FunctionsCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test ' . $name,
'runtime' => $name,
'vars' => [],
@@ -796,7 +797,7 @@ class FunctionsCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test ' . $name,
'runtime' => $name,
'vars' => [],
@@ -905,7 +906,7 @@ class FunctionsCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test ' . $name,
'runtime' => $name,
'vars' => [
@@ -1010,7 +1011,7 @@ class FunctionsCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test ' . $name,
'runtime' => $name,
'vars' => [
@@ -1115,7 +1116,7 @@ class FunctionsCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test ' . $name,
'runtime' => $name,
'vars' => [
@@ -1220,7 +1221,7 @@ class FunctionsCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test ' . $name,
'runtime' => $name,
'vars' => [
@@ -1325,7 +1326,7 @@ class FunctionsCustomServerTest extends Scope
// 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders()), [
// 'functionId' => 'unique()',
// 'functionId' => ID::unique(),
// 'name' => 'Test '.$name,
// 'runtime' => $name,
// 'vars' => [
@@ -8,6 +8,7 @@ use Tests\E2E\Scopes\SideClient;
use Tests\E2E\Services\Projects\ProjectsBase;
use Tests\E2E\Client;
use Utopia\Database\Database;
use Utopia\Database\ID;
class ProjectsConsoleClientTest extends Scope
{
@@ -24,7 +25,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Project Test',
]);
@@ -36,7 +37,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'projectId' => 'unique()',
'projectId' => ID::unique(),
'name' => 'Project Test',
'teamId' => $team['body']['$id'],
]);
@@ -58,7 +59,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'projectId' => 'unique()',
'projectId' => ID::unique(),
'name' => '',
'teamId' => $team['body']['$id'],
]);
@@ -69,7 +70,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'projectId' => 'unique()',
'projectId' => ID::unique(),
'name' => 'Project Test',
]);
@@ -135,7 +136,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Project Test 2',
]);
@@ -147,7 +148,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'projectId' => 'unique()',
'projectId' => ID::unique(),
'name' => 'Project Test 2',
'teamId' => $team['body']['$id'],
]);
@@ -314,7 +315,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'projectId' => 'unique()',
'projectId' => ID::unique(),
'name' => 'Project Test 2',
]);
@@ -335,7 +336,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'projectId' => 'unique()',
'projectId' => ID::unique(),
'name' => '',
]);
@@ -393,7 +394,7 @@ class ProjectsConsoleClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'provider' => 'unknown',
'appId' => 'AppId',
'appId' => ID::custom('AppId'),
'secret' => 'Secret',
]);
@@ -419,7 +420,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $id,
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $originalEmail,
'password' => $originalPassword,
'name' => $originalName,
@@ -472,7 +473,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $id,
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -485,7 +486,7 @@ class ProjectsConsoleClientTest extends Scope
'x-appwrite-project' => $id,
'cookie' => 'a_session_' . $id . '=' . $session,
]), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Arsenal'
]);
@@ -579,7 +580,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $id,
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -605,7 +606,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $id,
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -623,7 +624,7 @@ class ProjectsConsoleClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
]), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Project Test',
]);
$this->assertEquals(201, $team['headers']['status-code']);
@@ -634,7 +635,7 @@ class ProjectsConsoleClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
]), [
'projectId' => 'unique()',
'projectId' => ID::unique(),
'name' => 'Project Test',
'teamId' => $team['body']['$id'],
]);
@@ -767,7 +768,7 @@ class ProjectsConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $id,
]), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Arsenal'
]);
@@ -857,7 +858,7 @@ class ProjectsConsoleClientTest extends Scope
'x-appwrite-project' => $id,
'x-appwrite-key' => $keySecret,
]), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Arsenal'
]);
@@ -6,6 +6,9 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideConsole;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
class RealtimeConsoleClientTest extends Scope
{
@@ -145,7 +148,7 @@ class RealtimeConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'Actors DB',
]);
@@ -157,7 +160,7 @@ class RealtimeConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::any()),
@@ -8,6 +8,9 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\CLI\Console;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
use WebSocket\ConnectionException;
class RealtimeCustomClientTest extends Scope
@@ -628,7 +631,7 @@ class RealtimeCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'Actors DB',
]);
@@ -642,7 +645,7 @@ class RealtimeCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::users()),
@@ -680,7 +683,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'name' => 'Chris Evans'
],
@@ -726,7 +729,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'name' => 'Chris Evans 2'
],
@@ -771,7 +774,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'name' => 'Bradley Cooper'
],
@@ -851,7 +854,7 @@ class RealtimeCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'Actors DB',
]);
@@ -865,7 +868,7 @@ class RealtimeCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::any()),
@@ -902,7 +905,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'name' => 'Chris Evans'
],
@@ -984,7 +987,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'name' => 'Bradley Cooper'
],
@@ -1058,7 +1061,7 @@ class RealtimeCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Bucket 1',
'permissions' => [
Permission::read(Role::any()),
@@ -1077,7 +1080,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
@@ -1215,7 +1218,7 @@ class RealtimeCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test',
'execute' => ['users'],
'runtime' => 'php-8.0',
@@ -1358,7 +1361,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Arsenal'
]);
+18 -15
View File
@@ -4,6 +4,9 @@ namespace Tests\E2E\Services\Storage;
use CURLFile;
use Tests\E2E\Client;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
trait StorageBase
{
@@ -17,7 +20,7 @@ trait StorageBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Test Bucket',
'fileSecurity' => true,
'maximumFileSize' => 2000000, //2MB
@@ -38,7 +41,7 @@ trait StorageBase
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
@@ -64,7 +67,7 @@ trait StorageBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Test Bucket 2',
'fileSecurity' => true,
'permissions' => [
@@ -163,7 +166,7 @@ trait StorageBase
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
@@ -181,7 +184,7 @@ trait StorageBase
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/disk-b/kitten-1.png'), 'image/png', 'kitten-1.png'),
'permissions' => [
Permission::read(Role::any()),
@@ -201,7 +204,7 @@ trait StorageBase
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/disk-a/kitten-3.gif'), 'image/gif', 'kitten-3.gif'),
'permissions' => [
Permission::read(Role::any()),
@@ -221,7 +224,7 @@ trait StorageBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Test Bucket 2',
'fileSecurity' => true,
'maximumFileSize' => 200000000, //200MB
@@ -476,7 +479,7 @@ trait StorageBase
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'testcache',
'fileId' => ID::custom('testcache'),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
@@ -522,7 +525,7 @@ trait StorageBase
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'testcache',
'fileId' => ID::custom('testcache'),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/disk-b/kitten-2.png'), 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
@@ -571,9 +574,9 @@ trait StorageBase
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -601,9 +604,9 @@ trait StorageBase
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
Permission::read(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
]
]);
@@ -51,7 +51,7 @@ class StorageConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Test Bucket',
'permission' => 'file'
]);
@@ -10,6 +10,9 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
class StorageCustomClientTest extends Scope
{
@@ -27,7 +30,7 @@ class StorageCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Test Bucket',
'permissions' => [
Permission::read(Role::any()),
@@ -45,7 +48,7 @@ class StorageCustomClientTest extends Scope
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'),
]);
@@ -92,7 +95,7 @@ class StorageCustomClientTest extends Scope
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'),
]);
@@ -120,7 +123,7 @@ class StorageCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Test Bucket',
'fileSecurity' => true,
'permissions' => [
@@ -137,7 +140,7 @@ class StorageCustomClientTest extends Scope
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'),
]);
@@ -166,11 +169,11 @@ class StorageCustomClientTest extends Scope
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'),
'folderId' => 'xyz',
'folderId' => ID::custom('xyz'),
'permissions' => [
Permission::read(Role::user('notme')),
Permission::read(Role::user(ID::custom('notme'))),
],
]);
@@ -184,12 +187,12 @@ class StorageCustomClientTest extends Scope
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'),
'folderId' => 'xyz',
'folderId' => ID::custom('xyz'),
'permissions' => [
Permission::update(Role::user('notme')),
Permission::delete(Role::user('notme')),
Permission::update(Role::user(ID::custom('notme'))),
Permission::delete(Role::user(ID::custom('notme'))),
]
]);
@@ -203,13 +206,13 @@ class StorageCustomClientTest extends Scope
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'),
'folderId' => 'xyz',
'folderId' => ID::custom('xyz'),
'permissions' => [
Permission::read(Role::user('notme')),
Permission::update(Role::user('notme')),
Permission::delete(Role::user('notme')),
Permission::read(Role::user(ID::custom('notme'))),
Permission::update(Role::user(ID::custom('notme'))),
Permission::delete(Role::user(ID::custom('notme'))),
],
]);
@@ -233,7 +236,7 @@ class StorageCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'permissions' => [
Permission::read(Role::user('notme')),
Permission::read(Role::user(ID::custom('notme'))),
],
]);
@@ -248,8 +251,8 @@ class StorageCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'permissions' => [
Permission::update(Role::user('notme')),
Permission::delete(Role::user('notme')),
Permission::update(Role::user(ID::custom('notme'))),
Permission::delete(Role::user(ID::custom('notme'))),
]
]);
@@ -264,10 +267,10 @@ class StorageCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'permissions' => [
Permission::read(Role::user('notme')),
Permission::create(Role::user('notme')),
Permission::update(Role::user('notme')),
Permission::delete(Role::user('notme')),
Permission::read(Role::user(ID::custom('notme'))),
Permission::create(Role::user(ID::custom('notme'))),
Permission::update(Role::user(ID::custom('notme'))),
Permission::delete(Role::user(ID::custom('notme'))),
],
]);
@@ -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\ID;
class StorageCustomServerTest extends Scope
{
@@ -22,7 +23,7 @@ class StorageCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Test Bucket',
'fileSecurity' => true,
]);
@@ -44,7 +45,7 @@ class StorageCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'bucketId' => 'bucket1',
'bucketId' => ID::custom('bucket1'),
'name' => 'Test Bucket',
'fileSecurity' => true,
]);
@@ -58,7 +59,7 @@ class StorageCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => '',
'fileSecurity' => true,
]);
@@ -179,7 +180,7 @@ class StorageCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Test Bucket Updated',
'enabled' => false,
'fileSecurity' => true,
+7 -6
View File
@@ -4,6 +4,7 @@ namespace Tests\E2E\Services\Teams;
use Tests\E2E\Client;
use Utopia\Database\Database;
use Utopia\Database\ID;
trait TeamsBase
{
@@ -16,7 +17,7 @@ trait TeamsBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Arsenal'
]);
@@ -35,7 +36,7 @@ trait TeamsBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => $teamId,
'teamId' => ID::custom($teamId),
'name' => 'Manchester United'
]);
@@ -51,7 +52,7 @@ trait TeamsBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Newcastle'
]);
@@ -251,7 +252,7 @@ trait TeamsBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Demo'
]);
@@ -266,7 +267,7 @@ trait TeamsBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Demo New'
]);
@@ -300,7 +301,7 @@ trait TeamsBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Demo'
]);
+6 -6
View File
@@ -238,7 +238,7 @@ trait TeamsBaseClient
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => $secret,
'userId' => $userUid,
'userId' => ID::custom($userUid),
]);
$this->assertEquals(200, $response['headers']['status-code']);
@@ -318,7 +318,7 @@ trait TeamsBaseClient
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => 'sdasdasd',
'userId' => $userUid,
'userId' => ID::custom($userUid),
]);
$this->assertEquals(401, $response['headers']['status-code']);
@@ -329,7 +329,7 @@ trait TeamsBaseClient
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => '',
'userId' => $userUid,
'userId' => ID::custom($userUid),
]);
$this->assertEquals(400, $response['headers']['status-code']);
@@ -340,7 +340,7 @@ trait TeamsBaseClient
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => $secret,
'userId' => 'sdasd',
'userId' => ID::custom('sdasd'),
]);
$this->assertEquals(401, $response['headers']['status-code']);
@@ -351,7 +351,7 @@ trait TeamsBaseClient
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => $secret,
'userId' => '',
'userId' => ID::custom(''),
]);
$this->assertEquals(400, $response['headers']['status-code']);
@@ -362,7 +362,7 @@ trait TeamsBaseClient
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => $secret,
'userId' => $userUid,
'userId' => ID::custom($userUid),
]);
$this->assertEquals(409, $response['headers']['status-code']);
@@ -24,7 +24,7 @@ class TeamsConsoleClientTest extends Scope
'x-appwrite-project' => 'console'
], $this->getHeaders()), [
'name' => 'Latest version Team',
'teamId' => 'unique()'
'teamId' => ID::unique()
]);
$this->assertEquals(201, $response['headers']['status-code']);
+3 -2
View File
@@ -4,6 +4,7 @@ namespace Tests\E2E\Services\Users;
use Tests\E2E\Client;
use Utopia\Database\Database;
use Utopia\Database\ID;
trait UsersBase
{
@@ -16,7 +17,7 @@ trait UsersBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => 'cristiano.ronaldo@manchester-united.co.uk',
'password' => 'password',
'name' => 'Cristiano Ronaldo',
@@ -42,7 +43,7 @@ trait UsersBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'userId' => 'user1',
'userId' => ID::custom('user1'),
'email' => 'lionel.messi@psg.fr',
'password' => 'password',
'name' => 'Lionel Messi',
+12 -9
View File
@@ -4,6 +4,9 @@ namespace Tests\E2E\Services\Webhooks;
use CURLFile;
use Tests\E2E\Client;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
trait WebhooksBase
{
@@ -25,7 +28,7 @@ trait WebhooksBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'Actors DB',
]);
@@ -39,7 +42,7 @@ trait WebhooksBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::any()),
@@ -189,7 +192,7 @@ trait WebhooksBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'firstName' => 'Chris',
'lastName' => 'Evans',
@@ -312,7 +315,7 @@ trait WebhooksBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'documentId' => ID::unique(),
'data' => [
'firstName' => 'Bradly',
'lastName' => 'Cooper',
@@ -377,7 +380,7 @@ trait WebhooksBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'bucketId' => 'unique()',
'bucketId' => ID::unique(),
'name' => 'Test Bucket',
'permissions' => [
Permission::read(Role::any()),
@@ -485,14 +488,14 @@ trait WebhooksBase
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => 'unique()',
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
'folderId' => 'xyz',
'folderId' => ID::custom('xyz'),
]);
$fileId = $file['body']['$id'];
@@ -687,7 +690,7 @@ trait WebhooksBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Arsenal'
]);
@@ -776,7 +779,7 @@ trait WebhooksBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => 'unique()',
'teamId' => ID::unique(),
'name' => 'Chelsea'
]);
@@ -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\ID;
class WebhooksCustomClientTest extends Scope
{
@@ -27,7 +28,7 @@ class WebhooksCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -85,7 +86,7 @@ class WebhooksCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -8,6 +8,9 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\CLI\Console;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
class WebhooksCustomServerTest extends Scope
{
@@ -141,7 +144,7 @@ class WebhooksCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], $this->getHeaders()), [
'databaseId' => 'unique()',
'databaseId' => ID::unique(),
'name' => 'Actors DB',
]);
@@ -155,7 +158,7 @@ class WebhooksCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'unique()',
'collectionId' => ID::unique(),
'name' => 'Demo',
'permissions' => [
Permission::read(Role::any()),
@@ -214,7 +217,7 @@ class WebhooksCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'userId' => 'unique()',
'userId' => ID::unique(),
'email' => $email,
'password' => $password,
'name' => $name,
@@ -392,7 +395,7 @@ class WebhooksCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => 'unique()',
'functionId' => ID::unique(),
'name' => 'Test',
'execute' => ['any'],
'runtime' => 'php-8.0',
+20 -19
View File
@@ -4,6 +4,7 @@ namespace Tests\Unit\Auth;
use Appwrite\Auth\Auth;
use Utopia\Database\Document;
use Utopia\Database\ID;
use Utopia\Database\Validator\Authorization;
use PHPUnit\Framework\TestCase;
@@ -70,14 +71,14 @@ class AuthTest extends TestCase
$hash = Auth::hash($secret);
$tokens1 = [
new Document([
'$id' => 'token1',
'$id' => ID::custom('token1'),
'expire' => time() + 60 * 60 * 24,
'secret' => $hash,
'provider' => Auth::SESSION_PROVIDER_EMAIL,
'providerUid' => 'test@example.com',
]),
new Document([
'$id' => 'token2',
'$id' => ID::custom('token2'),
'expire' => time() - 60 * 60 * 24,
'secret' => 'secret2',
'provider' => Auth::SESSION_PROVIDER_EMAIL,
@@ -87,14 +88,14 @@ class AuthTest extends TestCase
$tokens2 = [
new Document([ // Correct secret and type time, wrong expire time
'$id' => 'token1',
'$id' => ID::custom('token1'),
'expire' => time() - 60 * 60 * 24,
'secret' => $hash,
'provider' => Auth::SESSION_PROVIDER_EMAIL,
'providerUid' => 'test@example.com',
]),
new Document([
'$id' => 'token2',
'$id' => ID::custom('token2'),
'expire' => time() - 60 * 60 * 24,
'secret' => 'secret2',
'provider' => Auth::SESSION_PROVIDER_EMAIL,
@@ -114,13 +115,13 @@ class AuthTest extends TestCase
$hash = Auth::hash($secret);
$tokens1 = [
new Document([
'$id' => 'token1',
'$id' => ID::custom('token1'),
'type' => Auth::TOKEN_TYPE_RECOVERY,
'expire' => time() + 60 * 60 * 24,
'secret' => $hash,
]),
new Document([
'$id' => 'token2',
'$id' => ID::custom('token2'),
'type' => Auth::TOKEN_TYPE_RECOVERY,
'expire' => time() - 60 * 60 * 24,
'secret' => 'secret2',
@@ -129,13 +130,13 @@ class AuthTest extends TestCase
$tokens2 = [
new Document([ // Correct secret and type time, wrong expire time
'$id' => 'token1',
'$id' => ID::custom('token1'),
'type' => Auth::TOKEN_TYPE_RECOVERY,
'expire' => time() - 60 * 60 * 24,
'secret' => $hash,
]),
new Document([
'$id' => 'token2',
'$id' => ID::custom('token2'),
'type' => Auth::TOKEN_TYPE_RECOVERY,
'expire' => time() - 60 * 60 * 24,
'secret' => 'secret2',
@@ -144,13 +145,13 @@ class AuthTest extends TestCase
$tokens3 = [ // Correct secret and expire time, wrong type
new Document([
'$id' => 'token1',
'$id' => ID::custom('token1'),
'type' => Auth::TOKEN_TYPE_INVITE,
'expire' => time() + 60 * 60 * 24,
'secret' => $hash,
]),
new Document([
'$id' => 'token2',
'$id' => ID::custom('token2'),
'type' => Auth::TOKEN_TYPE_RECOVERY,
'expire' => time() - 60 * 60 * 24,
'secret' => 'secret2',
@@ -213,17 +214,17 @@ class AuthTest extends TestCase
public function testUserRoles(): void
{
$user = new Document([
'$id' => '123',
'$id' => ID::custom('123'),
'memberships' => [
[
'teamId' => 'abc',
'teamId' => ID::custom('abc'),
'roles' => [
'administrator',
'moderator'
]
],
[
'teamId' => 'def',
'teamId' => ID::custom('def'),
'roles' => [
'guest'
]
@@ -247,17 +248,17 @@ class AuthTest extends TestCase
{
Authorization::setRole(Auth::USER_ROLE_OWNER);
$user = new Document([
'$id' => '123',
'$id' => ID::custom('123'),
'memberships' => [
[
'teamId' => 'abc',
'teamId' => ID::custom('abc'),
'roles' => [
'administrator',
'moderator'
]
],
[
'teamId' => 'def',
'teamId' => ID::custom('def'),
'roles' => [
'guest'
]
@@ -281,17 +282,17 @@ class AuthTest extends TestCase
{
Authorization::setRole(Auth::USER_ROLE_APP);
$user = new Document([
'$id' => '123',
'$id' => ID::custom('123'),
'memberships' => [
[
'teamId' => 'abc',
'teamId' => ID::custom('abc'),
'roles' => [
'administrator',
'moderator'
]
],
[
'teamId' => 'def',
'teamId' => ID::custom('def'),
'roles' => [
'guest'
]
@@ -6,6 +6,7 @@ use Appwrite\Auth\Auth;
use Utopia\Database\Document;
use Appwrite\Messaging\Adapter\Realtime;
use PHPUnit\Framework\TestCase;
use Utopia\Database\ID;
class MessagingChannelsTest extends TestCase
{
@@ -49,10 +50,10 @@ class MessagingChannelsTest extends TestCase
for ($i = 0; $i < $this->connectionsPerChannel; $i++) {
foreach ($this->allChannels as $index => $channel) {
$user = new Document([
'$id' => 'user' . $this->connectionsCount,
'$id' => ID::custom('user' . $this->connectionsCount),
'memberships' => [
[
'teamId' => 'team' . $i,
'teamId' => ID::custom('team' . $i),
'roles' => [
empty($index % 2) ? 'admin' : 'member'
]
+20 -17
View File
@@ -5,6 +5,9 @@ namespace Tests\Unit\Messaging;
use Utopia\Database\Document;
use Appwrite\Messaging\Adapter\Realtime;
use PHPUnit\Framework\TestCase;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
class MessagingTest extends TestCase
{
@@ -160,17 +163,17 @@ class MessagingTest extends TestCase
public function testConvertChannelsUser(): void
{
$user = new Document([
'$id' => '123',
'$id' => ID::custom('123'),
'memberships' => [
[
'teamId' => 'abc',
'teamId' => ID::custom('abc'),
'roles' => [
'administrator',
'moderator'
]
],
[
'teamId' => 'def',
'teamId' => ID::custom('def'),
'roles' => [
'guest'
]
@@ -204,8 +207,8 @@ class MessagingTest extends TestCase
$result = Realtime::fromPayload(
event: 'databases.database_id.collections.collection_id.documents.document_id.create',
payload: new Document([
'$id' => 'test',
'$collection' => 'collection',
'$id' => ID::custom('test'),
'$collection' => ID::custom('collection'),
'$permissions' => [
'read(admin)',
'update(admin)',
@@ -213,10 +216,10 @@ class MessagingTest extends TestCase
],
]),
database: new Document([
'$id' => 'database',
'$id' => ID::custom('database'),
]),
collection: new Document([
'$id' => 'collection',
'$id' => ID::custom('collection'),
'$permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
@@ -234,8 +237,8 @@ class MessagingTest extends TestCase
$result = Realtime::fromPayload(
event: 'databases.database_id.collections.collection_id.documents.document_id.create',
payload: new Document([
'$id' => 'test',
'$collection' => 'collection',
'$id' => ID::custom('test'),
'$collection' => ID::custom('collection'),
'$permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
@@ -243,10 +246,10 @@ class MessagingTest extends TestCase
],
]),
database: new Document([
'$id' => 'database',
'$id' => ID::custom('database'),
]),
collection: new Document([
'$id' => 'collection',
'$id' => ID::custom('collection'),
'$permissions' => [
'read(admin)',
'update(admin)',
@@ -268,8 +271,8 @@ class MessagingTest extends TestCase
$result = Realtime::fromPayload(
event: 'buckets.bucket_id.files.file_id.create',
payload: new Document([
'$id' => 'test',
'$collection' => 'bucket',
'$id' => ID::custom('test'),
'$collection' => ID::custom('bucket'),
'$permissions' => [
'read(admin)',
'update(admin)',
@@ -277,7 +280,7 @@ class MessagingTest extends TestCase
],
]),
bucket: new Document([
'$id' => 'bucket',
'$id' => ID::custom('bucket'),
'$permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
@@ -295,8 +298,8 @@ class MessagingTest extends TestCase
$result = Realtime::fromPayload(
event: 'buckets.bucket_id.files.file_id.create',
payload: new Document([
'$id' => 'test',
'$collection' => 'bucket',
'$id' => ID::custom('test'),
'$collection' => ID::custom('bucket'),
'$permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
@@ -304,7 +307,7 @@ class MessagingTest extends TestCase
],
]),
bucket: new Document([
'$id' => 'bucket',
'$id' => ID::custom('bucket'),
'$permissions' => [
'read(admin)',
'update(admin)',
+12 -11
View File
@@ -5,6 +5,7 @@ namespace Tests\Unit\Migration;
use ReflectionClass;
use Appwrite\Migration\Version\V12;
use Utopia\Database\Document;
use Utopia\Database\ID;
class MigrationV12Test extends MigrationTest
{
@@ -19,8 +20,8 @@ class MigrationV12Test extends MigrationTest
public function testMigrationProjects(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'project',
'$collection' => 'projects',
'$id' => ID::custom('project'),
'$collection' => ID::custom('projects'),
'name' => 'Appwrite',
'version' => '0.12.0',
'search' => ''
@@ -33,8 +34,8 @@ class MigrationV12Test extends MigrationTest
public function testMigrationUsers(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'user',
'$collection' => 'users',
'$id' => ID::custom('user'),
'$collection' => ID::custom('users'),
'email' => 'test@appwrite.io',
'name' => 'Torsten Dittmann'
]));
@@ -45,8 +46,8 @@ class MigrationV12Test extends MigrationTest
public function testMigrationTeams(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'team',
'$collection' => 'teams',
'$id' => ID::custom('team'),
'$collection' => ID::custom('teams'),
'name' => 'Appwrite'
]));
@@ -56,8 +57,8 @@ class MigrationV12Test extends MigrationTest
public function testMigrationFunctions(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'function',
'$collection' => 'functions',
'$id' => ID::custom('function'),
'$collection' => ID::custom('functions'),
'name' => 'My Function',
'runtime' => 'php-8.0'
]));
@@ -68,9 +69,9 @@ class MigrationV12Test extends MigrationTest
public function testMigrationExecutions(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'execution',
'$collection' => 'executions',
'functionId' => 'function'
'$id' => ID::custom('execution'),
'$collection' => ID::custom('executions'),
'functionId' => ID::custom('function')
]));
$this->assertEquals($document->getAttribute('search'), 'execution function');
+5 -4
View File
@@ -5,6 +5,7 @@ namespace Tests\Unit\Migration;
use ReflectionClass;
use Appwrite\Migration\Version\V13;
use Utopia\Database\Document;
use Utopia\Database\ID;
class MigrationV13Test extends MigrationTest
{
@@ -19,8 +20,8 @@ class MigrationV13Test extends MigrationTest
public function testMigrateFunctions(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'func',
'$collection' => 'functions',
'$id' => ID::custom('func'),
'$collection' => ID::custom('functions'),
'events' => ['account.create', 'users.create']
]));
@@ -30,8 +31,8 @@ class MigrationV13Test extends MigrationTest
public function testMigrationWebhooks(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'webh',
'$collection' => 'webhooks',
'$id' => ID::custom('webh'),
'$collection' => ID::custom('webhooks'),
'events' => ['account.create', 'users.create']
]));
+25 -24
View File
@@ -5,6 +5,7 @@ namespace Tests\Unit\Migration;
use ReflectionClass;
use Appwrite\Migration\Version\V14;
use Utopia\Database\Document;
use Utopia\Database\ID;
class MigrationV14Test extends MigrationTest
{
@@ -19,8 +20,8 @@ class MigrationV14Test extends MigrationTest
public function testMigrateProjects(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'projects',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('projects'),
'version' => '0.14.0'
]));
@@ -31,7 +32,7 @@ class MigrationV14Test extends MigrationTest
public function testMigrateKeys(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$id' => ID::custom('appwrite'),
'$collection' => 'keys'
]));
@@ -42,7 +43,7 @@ class MigrationV14Test extends MigrationTest
public function testMigrateWebhooks(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$id' => ID::custom('appwrite'),
'$collection' => 'webhooks'
]));
@@ -53,8 +54,8 @@ class MigrationV14Test extends MigrationTest
public function testMigrateUsers(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'users',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('users'),
'phoneVerification' => null
]));
@@ -65,8 +66,8 @@ class MigrationV14Test extends MigrationTest
public function testMigratePlatforms(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'platforms',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('platforms'),
'$createdAt' => null,
'$updatedAt' => null,
'dateCreated' => 123456789,
@@ -80,8 +81,8 @@ class MigrationV14Test extends MigrationTest
public function testMigrateFunctions(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'functions',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('functions'),
'$createdAt' => null,
'$updatedAt' => null,
'dateCreated' => 123456789,
@@ -95,8 +96,8 @@ class MigrationV14Test extends MigrationTest
public function testMigrateDeployments(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'deployments',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('deployments'),
'$createdAt' => null,
'dateCreated' => 123456789,
]));
@@ -107,8 +108,8 @@ class MigrationV14Test extends MigrationTest
public function testMigrateExecutions(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'executions',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('executions'),
'$createdAt' => null,
'dateCreated' => 123456789,
]));
@@ -119,8 +120,8 @@ class MigrationV14Test extends MigrationTest
public function testMigrateTeams(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'teams',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('teams'),
'$createdAt' => null,
'dateCreated' => 123456789,
]));
@@ -131,8 +132,8 @@ class MigrationV14Test extends MigrationTest
public function testMigrateAudits(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'audit',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('audit'),
'resource' => 'collection/movies',
'event' => 'collections.movies.create'
]));
@@ -141,8 +142,8 @@ class MigrationV14Test extends MigrationTest
$this->assertEquals($document->getAttribute('event'), 'databases.default.collections.movies.create');
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'audit',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('audit'),
'resource' => 'document/avatar',
'event' => 'collections.movies.documents.avatar.create'
]));
@@ -154,16 +155,16 @@ class MigrationV14Test extends MigrationTest
public function testMigrateStats(): void
{
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'stats',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('stats'),
'metric' => 'database.collections.62b2039844d4277495d0.documents.create'
]));
$this->assertEquals($document->getAttribute('metric'), 'databases.default.collections.62b2039844d4277495d0.documents.create');
$document = $this->fixDocument(new Document([
'$id' => 'appwrite',
'$collection' => 'stats',
'$id' => ID::custom('appwrite'),
'$collection' => ID::custom('stats'),
'metric' => 'users.create'
]));
+4 -3
View File
@@ -4,6 +4,7 @@ namespace Tests\Unit\Network\Validators;
use Appwrite\Network\Validator\Origin;
use PHPUnit\Framework\TestCase;
use Utopia\Database\ID;
class OriginTest extends TestCase
{
@@ -11,19 +12,19 @@ class OriginTest extends TestCase
{
$validator = new Origin([
[
'$collection' => 'platforms',
'$collection' => ID::custom('platforms'),
'name' => 'Production',
'type' => 'web',
'hostname' => 'appwrite.io',
],
[
'$collection' => 'platforms',
'$collection' => ID::custom('platforms'),
'name' => 'Development',
'type' => 'web',
'hostname' => 'appwrite.test',
],
[
'$collection' => 'platforms',
'$collection' => ID::custom('platforms'),
'name' => 'Localhost',
'type' => 'web',
'hostname' => 'localhost',