ID updates
This commit is contained in:
parent
a8698b6065
commit
b007acfa95
File diff suppressed because it is too large
Load diff
|
@ -27,6 +27,7 @@ use Utopia\Config\Config;
|
|||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Exception\Duplicate;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Role;
|
||||
|
@ -97,11 +98,11 @@ App::post('/v1/account')
|
|||
try {
|
||||
$userId = $userId == 'unique()' ? $dbForProject->getId() : $userId;
|
||||
$user = Authorization::skip(fn() => $dbForProject->createDocument('users', new Document([
|
||||
'$id' => $userId,
|
||||
'$id' => ID::custom($userId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::user($userId)),
|
||||
Permission::delete(Role::user($userId)),
|
||||
Permission::update(Role::user(ID::custom($userId))),
|
||||
Permission::delete(Role::user(ID::custom($userId))),
|
||||
],
|
||||
'email' => $email,
|
||||
'emailVerification' => false,
|
||||
|
@ -185,9 +186,9 @@ App::post('/v1/account/sessions/email')
|
|||
$secret = Auth::tokenGenerator();
|
||||
$session = new Document(array_merge(
|
||||
[
|
||||
'$id' => $dbForProject->getId(),
|
||||
'userId' => $profile->getId(),
|
||||
'userInternalId' => $profile->getInternalId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => ID::custom($profile->getId()),
|
||||
'userInternalId' => ID::custom($profile->getInternalId()),
|
||||
'provider' => Auth::SESSION_PROVIDER_EMAIL,
|
||||
'providerUid' => $email,
|
||||
'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak
|
||||
|
@ -204,9 +205,9 @@ App::post('/v1/account/sessions/email')
|
|||
Authorization::setRole('user:' . $profile->getId());
|
||||
|
||||
$session = $dbForProject->createDocument('sessions', $session->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($profile->getId())),
|
||||
Permission::update(Role::user($profile->getId())),
|
||||
Permission::delete(Role::user($profile->getId())),
|
||||
Permission::read(Role::user(ID::custom($profile->getId()))),
|
||||
Permission::update(Role::user(ID::custom($profile->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($profile->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $profile->getId());
|
||||
|
@ -484,11 +485,11 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
|||
try {
|
||||
$userId = $dbForProject->getId();
|
||||
$user = Authorization::skip(fn() => $dbForProject->createDocument('users', new Document([
|
||||
'$id' => $userId,
|
||||
'$id' => ID::custom($userId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::user($userId)),
|
||||
Permission::delete(Role::user($userId)),
|
||||
Permission::update(Role::user(ID::custom($userId))),
|
||||
Permission::delete(Role::user(ID::custom($userId))),
|
||||
],
|
||||
'email' => $email,
|
||||
'emailVerification' => true,
|
||||
|
@ -520,9 +521,9 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
|||
$secret = Auth::tokenGenerator();
|
||||
$expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG;
|
||||
$session = new Document(array_merge([
|
||||
'$id' => $dbForProject->getId(),
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => ID::custom($user->getId()),
|
||||
'userInternalId' => ID::custom($user->getInternalId()),
|
||||
'provider' => $provider,
|
||||
'providerUid' => $oauth2ID,
|
||||
'providerAccessToken' => $accessToken,
|
||||
|
@ -553,9 +554,9 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
|||
$dbForProject->updateDocument('users', $user->getId(), $user);
|
||||
|
||||
$session = $dbForProject->createDocument('sessions', $session->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
@ -654,11 +655,11 @@ App::post('/v1/account/sessions/magic-url')
|
|||
$userId = $userId == 'unique()' ? $dbForProject->getId() : $userId;
|
||||
|
||||
$user = Authorization::skip(fn () => $dbForProject->createDocument('users', new Document([
|
||||
'$id' => $userId,
|
||||
'$id' => ID::custom($userId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::user($userId)),
|
||||
Permission::delete(Role::user($userId)),
|
||||
Permission::update(Role::user(ID::custom($userId))),
|
||||
Permission::delete(Role::user(ID::custom($userId))),
|
||||
],
|
||||
'email' => $email,
|
||||
'emailVerification' => false,
|
||||
|
@ -680,7 +681,7 @@ App::post('/v1/account/sessions/magic-url')
|
|||
$expire = \time() + Auth::TOKEN_EXPIRATION_CONFIRM;
|
||||
|
||||
$token = new Document([
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'type' => Auth::TOKEN_TYPE_MAGIC_URL,
|
||||
|
@ -694,9 +695,9 @@ App::post('/v1/account/sessions/magic-url')
|
|||
|
||||
$token = $dbForProject->createDocument('tokens', $token
|
||||
->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
@ -783,7 +784,7 @@ App::put('/v1/account/sessions/magic-url')
|
|||
$expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG;
|
||||
$session = new Document(array_merge(
|
||||
[
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'provider' => Auth::SESSION_PROVIDER_MAGIC_URL,
|
||||
|
@ -802,9 +803,9 @@ App::put('/v1/account/sessions/magic-url')
|
|||
|
||||
$session = $dbForProject->createDocument('sessions', $session
|
||||
->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
@ -904,11 +905,11 @@ App::post('/v1/account/sessions/phone')
|
|||
$userId = $userId == 'unique()' ? $dbForProject->getId() : $userId;
|
||||
|
||||
$user = Authorization::skip(fn () => $dbForProject->createDocument('users', new Document([
|
||||
'$id' => $userId,
|
||||
'$id' => ID::custom($userId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::user($userId)),
|
||||
Permission::delete(Role::user($userId)),
|
||||
Permission::update(Role::user(ID::custom($userId))),
|
||||
Permission::delete(Role::user(ID::custom($userId))),
|
||||
],
|
||||
'email' => null,
|
||||
'phone' => $number,
|
||||
|
@ -932,7 +933,7 @@ App::post('/v1/account/sessions/phone')
|
|||
$expire = \time() + Auth::TOKEN_EXPIRATION_PHONE;
|
||||
|
||||
$token = new Document([
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'type' => Auth::TOKEN_TYPE_PHONE,
|
||||
|
@ -946,9 +947,9 @@ App::post('/v1/account/sessions/phone')
|
|||
|
||||
$token = $dbForProject->createDocument('tokens', $token
|
||||
->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
@ -1022,7 +1023,7 @@ App::put('/v1/account/sessions/phone')
|
|||
$expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG;
|
||||
$session = new Document(array_merge(
|
||||
[
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'provider' => Auth::SESSION_PROVIDER_PHONE,
|
||||
|
@ -1041,9 +1042,9 @@ App::put('/v1/account/sessions/phone')
|
|||
|
||||
$session = $dbForProject->createDocument('sessions', $session
|
||||
->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
@ -1141,11 +1142,11 @@ App::post('/v1/account/sessions/anonymous')
|
|||
|
||||
$userId = $dbForProject->getId();
|
||||
$user = Authorization::skip(fn() => $dbForProject->createDocument('users', new Document([
|
||||
'$id' => $userId,
|
||||
'$id' => ID::custom($userId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::user($userId)),
|
||||
Permission::delete(Role::user($userId)),
|
||||
Permission::update(Role::user(ID::custom($userId))),
|
||||
Permission::delete(Role::user(ID::custom($userId))),
|
||||
],
|
||||
'email' => null,
|
||||
'emailVerification' => false,
|
||||
|
@ -1170,7 +1171,7 @@ App::post('/v1/account/sessions/anonymous')
|
|||
$expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG;
|
||||
$session = new Document(array_merge(
|
||||
[
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'provider' => Auth::SESSION_PROVIDER_ANONYMOUS,
|
||||
|
@ -1188,9 +1189,9 @@ App::post('/v1/account/sessions/anonymous')
|
|||
Authorization::setRole('user:' . $user->getId());
|
||||
|
||||
$session = $dbForProject->createDocument('sessions', $session-> setAttribute('$permissions', [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
@ -2001,7 +2002,7 @@ App::post('/v1/account/recovery')
|
|||
|
||||
$secret = Auth::tokenGenerator();
|
||||
$recovery = new Document([
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => $profile->getId(),
|
||||
'userInternalId' => $profile->getInternalId(),
|
||||
'type' => Auth::TOKEN_TYPE_RECOVERY,
|
||||
|
@ -2015,9 +2016,9 @@ App::post('/v1/account/recovery')
|
|||
|
||||
$recovery = $dbForProject->createDocument('tokens', $recovery
|
||||
->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($profile->getId())),
|
||||
Permission::update(Role::user($profile->getId())),
|
||||
Permission::delete(Role::user($profile->getId())),
|
||||
Permission::read(Role::user(ID::custom($profile->getId()))),
|
||||
Permission::update(Role::user(ID::custom($profile->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($profile->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $profile->getId());
|
||||
|
@ -2165,7 +2166,7 @@ App::post('/v1/account/verification')
|
|||
$expire = \time() + Auth::TOKEN_EXPIRATION_CONFIRM;
|
||||
|
||||
$verification = new Document([
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'type' => Auth::TOKEN_TYPE_VERIFICATION,
|
||||
|
@ -2179,9 +2180,9 @@ App::post('/v1/account/verification')
|
|||
|
||||
$verification = $dbForProject->createDocument('tokens', $verification
|
||||
->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
@ -2323,7 +2324,7 @@ App::post('/v1/account/verification/phone')
|
|||
$expire = \time() + Auth::TOKEN_EXPIRATION_CONFIRM;
|
||||
|
||||
$verification = new Document([
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'type' => Auth::TOKEN_TYPE_PHONE,
|
||||
|
@ -2337,9 +2338,9 @@ App::post('/v1/account/verification/phone')
|
|||
|
||||
$verification = $dbForProject->createDocument('tokens', $verification
|
||||
->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
|
|
@ -5,6 +5,7 @@ use Utopia\App;
|
|||
use Appwrite\Event\Delete;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Utopia\Audit\Audit;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Validator\Boolean;
|
||||
use Utopia\Validator\FloatValidator;
|
||||
use Utopia\Validator\Integer;
|
||||
|
@ -94,12 +95,12 @@ function createAttribute(string $databaseId, string $collectionId, Document $att
|
|||
|
||||
try {
|
||||
$attribute = new Document([
|
||||
'$id' => $db->getInternalId() . '_' . $collection->getInternalId() . '_' . $key,
|
||||
'$id' => ID::custom($db->getInternalId() . '_' . $collection->getInternalId() . '_' . $key),
|
||||
'key' => $key,
|
||||
'databaseInternalId' => $db->getInternalId(),
|
||||
'databaseId' => $db->getId(),
|
||||
'collectionInternalId' => $collection->getInternalId(),
|
||||
'collectionId' => $collectionId,
|
||||
'databaseInternalId' => ID::custom($db->getInternalId()),
|
||||
'databaseId' => ID::custom($db->getId()),
|
||||
'collectionInternalId' => ID::custom($collection->getInternalId()),
|
||||
'collectionId' => ID::custom($collectionId),
|
||||
'type' => $type,
|
||||
'status' => 'processing', // processing, available, failed, deleting, stuck
|
||||
'size' => $size,
|
||||
|
@ -177,7 +178,7 @@ App::post('/v1/databases')
|
|||
|
||||
try {
|
||||
$dbForProject->createDocument('databases', new Document([
|
||||
'$id' => $databaseId,
|
||||
'$id' => ID::custom($databaseId),
|
||||
'name' => $name,
|
||||
'search' => implode(' ', [$databaseId, $name]),
|
||||
]));
|
||||
|
@ -193,7 +194,7 @@ App::post('/v1/databases')
|
|||
|
||||
foreach ($collections['attributes'] as $attribute) {
|
||||
$attributes[] = new Document([
|
||||
'$id' => $attribute['$id'],
|
||||
'$id' => ID::custom($attribute['$id']),
|
||||
'type' => $attribute['type'],
|
||||
'size' => $attribute['size'],
|
||||
'required' => $attribute['required'],
|
||||
|
@ -207,7 +208,7 @@ App::post('/v1/databases')
|
|||
|
||||
foreach ($collections['indexes'] as $index) {
|
||||
$indexes[] = new Document([
|
||||
'$id' => $index['$id'],
|
||||
'$id' => ID::custom($index['$id']),
|
||||
'type' => $index['type'],
|
||||
'attributes' => $index['attributes'],
|
||||
'lengths' => $index['lengths'],
|
||||
|
@ -344,7 +345,7 @@ App::get('/v1/databases/:databaseId/logs')
|
|||
|
||||
$output[$i] = new Document([
|
||||
'event' => $log['event'],
|
||||
'userId' => $log['userId'],
|
||||
'userId' => ID::custom($log['userId']),
|
||||
'userEmail' => $log['data']['userEmail'] ?? null,
|
||||
'userName' => $log['data']['userName'] ?? null,
|
||||
'mode' => $log['data']['mode'] ?? null,
|
||||
|
@ -519,7 +520,7 @@ App::post('/v1/databases/:databaseId/collections')
|
|||
|
||||
try {
|
||||
$dbForProject->createDocument('database_' . $database->getInternalId(), new Document([
|
||||
'$id' => $collectionId,
|
||||
'$id' => ID::custom($collectionId),
|
||||
'$permissions' => $permissions ?? [],
|
||||
'databaseInternalId' => $database->getInternalId(),
|
||||
'databaseId' => $databaseId,
|
||||
|
@ -1600,7 +1601,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes')
|
|||
|
||||
try {
|
||||
$index = $dbForProject->createDocument('indexes', new Document([
|
||||
'$id' => $db->getInternalId() . '_' . $collection->getInternalId() . '_' . $key,
|
||||
'$id' => ID::custom($db->getInternalId() . '_' . $collection->getInternalId() . '_' . $key),
|
||||
'key' => $key,
|
||||
'status' => 'processing', // processing, available, failed, deleting, stuck
|
||||
'databaseInternalId' => $db->getInternalId(),
|
||||
|
@ -1870,6 +1871,10 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
|
|||
throw new Exception('Unauthorized permissions', 401, Exception::USER_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add permissions for current the user for any missing types
|
||||
* from the allowed permissions for this resource type.
|
||||
*/
|
||||
$permissions = PermissionsProcessor::addDefaultsIfNeeded(
|
||||
$permissions,
|
||||
$user->getId(),
|
||||
|
|
|
@ -9,6 +9,7 @@ use Appwrite\Event\Func;
|
|||
use Appwrite\Event\Validator\Event as ValidatorEvent;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Utopia\Database\Validator\CustomId;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Validator\UID;
|
||||
|
@ -67,7 +68,7 @@ App::post('/v1/functions')
|
|||
|
||||
$functionId = ($functionId == 'unique()') ? $dbForProject->getId() : $functionId;
|
||||
$function = $dbForProject->createDocument('functions', new Document([
|
||||
'$id' => $functionId,
|
||||
'$id' => ID::custom($functionId),
|
||||
'execute' => $execute,
|
||||
'status' => 'disabled',
|
||||
'name' => $name,
|
||||
|
@ -570,13 +571,13 @@ App::post('/v1/functions/:functionId/deployments')
|
|||
|
||||
if ($deployment->isEmpty()) {
|
||||
$deployment = $dbForProject->createDocument('deployments', new Document([
|
||||
'$id' => $deploymentId,
|
||||
'$id' => ID::custom($deploymentId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::any()),
|
||||
Permission::delete(Role::any()),
|
||||
],
|
||||
'resourceId' => $function->getId(),
|
||||
'resourceId' => ID::custom($function->getId()),
|
||||
'resourceType' => 'functions',
|
||||
'entrypoint' => $entrypoint,
|
||||
'path' => $path,
|
||||
|
@ -602,7 +603,7 @@ App::post('/v1/functions/:functionId/deployments')
|
|||
} else {
|
||||
if ($deployment->isEmpty()) {
|
||||
$deployment = $dbForProject->createDocument('deployments', new Document([
|
||||
'$id' => $deploymentId,
|
||||
'$id' => ID::custom($deploymentId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::any()),
|
||||
|
@ -861,10 +862,10 @@ App::post('/v1/functions/:functionId/executions')
|
|||
|
||||
/** @var Document $execution */
|
||||
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', new Document([
|
||||
'$id' => $executionId,
|
||||
'$permissions' => !$user->isEmpty() ? [Permission::read(Role::user($user->getId()))] : [],
|
||||
'functionId' => $function->getId(),
|
||||
'deploymentId' => $deployment->getId(),
|
||||
'$id' => ID::custom($executionId),
|
||||
'$permissions' => !$user->isEmpty() ? [Permission::read(Role::user(ID::custom($user->getId())))] : [],
|
||||
'functionId' => ID::custom($function->getId()),
|
||||
'deploymentId' => ID::custom($deployment->getId()),
|
||||
'trigger' => 'http', // http / schedule / event
|
||||
'status' => 'waiting', // waiting / processing / completed / failed
|
||||
'statusCode' => 0,
|
||||
|
@ -889,8 +890,8 @@ App::post('/v1/functions/:functionId/executions')
|
|||
if (!$current->isEmpty()) {
|
||||
$jwtObj = new JWT(App::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 10); // Instantiate with key, algo, maxAge and leeway.
|
||||
$jwt = $jwtObj->encode([
|
||||
'userId' => $user->getId(),
|
||||
'sessionId' => $current->getId(),
|
||||
'userId' => ID::custom($user->getId()),
|
||||
'sessionId' => ID::custom($current->getId()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ use Utopia\Audit\Audit;
|
|||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Role;
|
||||
|
@ -88,17 +89,17 @@ App::post('/v1/projects')
|
|||
}
|
||||
|
||||
$project = $dbForConsole->createDocument('projects', new Document([
|
||||
'$id' => $projectId,
|
||||
'$id' => ID::custom($projectId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::team($teamId)),
|
||||
Permission::update(Role::team($teamId, 'owner')),
|
||||
Permission::update(Role::team($teamId, 'developer')),
|
||||
Permission::delete(Role::team($teamId, 'owner')),
|
||||
Permission::delete(Role::team($teamId, 'developer')),
|
||||
Permission::read(Role::team(ID::custom($teamId))),
|
||||
Permission::update(Role::team(ID::custom($teamId), 'owner')),
|
||||
Permission::update(Role::team(ID::custom($teamId), 'developer')),
|
||||
Permission::delete(Role::team(ID::custom($teamId), 'owner')),
|
||||
Permission::delete(Role::team(ID::custom($teamId), 'developer')),
|
||||
],
|
||||
'name' => $name,
|
||||
'teamInternalId' => $team->getInternalId(),
|
||||
'teamId' => $team->getId(),
|
||||
'teamInternalId' => ID::custom($team->getInternalId()),
|
||||
'teamId' => ID::custom($team->getId()),
|
||||
'description' => $description,
|
||||
'logo' => $logo,
|
||||
'url' => $url,
|
||||
|
@ -108,7 +109,7 @@ App::post('/v1/projects')
|
|||
'legalState' => $legalState,
|
||||
'legalCity' => $legalCity,
|
||||
'legalAddress' => $legalAddress,
|
||||
'legalTaxId' => $legalTaxId,
|
||||
'legalTaxId' => ID::custom($legalTaxId),
|
||||
'services' => new stdClass(),
|
||||
'platforms' => null,
|
||||
'authProviders' => [],
|
||||
|
@ -139,7 +140,7 @@ App::post('/v1/projects')
|
|||
|
||||
foreach ($collection['attributes'] as $attribute) {
|
||||
$attributes[] = new Document([
|
||||
'$id' => $attribute['$id'],
|
||||
'$id' => ID::custom($attribute['$id']),
|
||||
'type' => $attribute['type'],
|
||||
'size' => $attribute['size'],
|
||||
'required' => $attribute['required'],
|
||||
|
@ -153,7 +154,7 @@ App::post('/v1/projects')
|
|||
|
||||
foreach ($collection['indexes'] as $index) {
|
||||
$indexes[] = new Document([
|
||||
'$id' => $index['$id'],
|
||||
'$id' => ID::custom($index['$id']),
|
||||
'type' => $index['type'],
|
||||
'attributes' => $index['attributes'],
|
||||
'lengths' => $index['lengths'],
|
||||
|
@ -596,14 +597,14 @@ App::post('/v1/projects/:projectId/webhooks')
|
|||
$security = (bool) filter_var($security, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$webhook = new Document([
|
||||
'$id' => $dbForConsole->getId(),
|
||||
'$id' => ID::custom($dbForConsole->getId()),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::any()),
|
||||
Permission::delete(Role::any()),
|
||||
],
|
||||
'projectInternalId' => $project->getInternalId(),
|
||||
'projectId' => $project->getId(),
|
||||
'projectInternalId' => ID::custom($project->getInternalId()),
|
||||
'projectId' => ID::custom($project->getId()),
|
||||
'name' => $name,
|
||||
'events' => $events,
|
||||
'url' => $url,
|
||||
|
@ -843,14 +844,14 @@ App::post('/v1/projects/:projectId/keys')
|
|||
}
|
||||
|
||||
$key = new Document([
|
||||
'$id' => $dbForConsole->getId(),
|
||||
'$id' => ID::custom($dbForConsole->getId()),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::any()),
|
||||
Permission::delete(Role::any()),
|
||||
],
|
||||
'projectInternalId' => $project->getInternalId(),
|
||||
'projectId' => $project->getId(),
|
||||
'projectId' => ID::custom($project->getId()),
|
||||
'name' => $name,
|
||||
'scopes' => $scopes,
|
||||
'expire' => $expire,
|
||||
|
@ -1042,7 +1043,7 @@ App::post('/v1/projects/:projectId/platforms')
|
|||
}
|
||||
|
||||
$platform = new Document([
|
||||
'$id' => $dbForConsole->getId(),
|
||||
'$id' => ID::custom($dbForConsole->getId()),
|
||||
'$permissions' => [
|
||||
'read(any)',
|
||||
'update(any)',
|
||||
|
@ -1257,7 +1258,7 @@ App::post('/v1/projects/:projectId/domains')
|
|||
$domain = new Domain($domain);
|
||||
|
||||
$domain = new Document([
|
||||
'$id' => $dbForConsole->getId(),
|
||||
'$id' => ID::custom($dbForConsole->getId()),
|
||||
'$permissions' => [
|
||||
'read(any)',
|
||||
'update(any)',
|
||||
|
|
|
@ -19,6 +19,7 @@ use Utopia\Database\Document;
|
|||
use Utopia\Database\Exception\Duplicate;
|
||||
use Utopia\Database\Exception\Duplicate as DuplicateException;
|
||||
use Utopia\Database\Exception\Structure as StructureException;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\Permissions;
|
||||
|
@ -82,7 +83,7 @@ App::post('/v1/storage/buckets')
|
|||
|
||||
foreach ($files['attributes'] as $attribute) {
|
||||
$attributes[] = new Document([
|
||||
'$id' => $attribute['$id'],
|
||||
'$id' => ID::custom($attribute['$id']),
|
||||
'type' => $attribute['type'],
|
||||
'size' => $attribute['size'],
|
||||
'required' => $attribute['required'],
|
||||
|
@ -96,7 +97,7 @@ App::post('/v1/storage/buckets')
|
|||
|
||||
foreach ($files['indexes'] as $index) {
|
||||
$indexes[] = new Document([
|
||||
'$id' => $index['$id'],
|
||||
'$id' => ID::custom($index['$id']),
|
||||
'type' => $index['type'],
|
||||
'attributes' => $index['attributes'],
|
||||
'lengths' => $index['lengths'],
|
||||
|
@ -105,8 +106,8 @@ App::post('/v1/storage/buckets')
|
|||
}
|
||||
|
||||
$dbForProject->createDocument('buckets', new Document([
|
||||
'$id' => $bucketId,
|
||||
'$collection' => 'buckets',
|
||||
'$id' => ID::custom($bucketId),
|
||||
'$collection' => ID::custom('buckets'),
|
||||
'$permissions' => $permissions,
|
||||
'name' => $name,
|
||||
'maximumFileSize' => $maximumFileSize,
|
||||
|
@ -362,6 +363,10 @@ App::post('/v1/storage/buckets/:bucketId/files')
|
|||
throw new Exception('Unauthorized permissions', 401, Exception::USER_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add permissions for current the user for any missing types
|
||||
* from the allowed permissions for this resource type.
|
||||
*/
|
||||
$permissions = PermissionsProcessor::addDefaultsIfNeeded(
|
||||
$permissions,
|
||||
$user->getId(),
|
||||
|
@ -523,9 +528,9 @@ App::post('/v1/storage/buckets/:bucketId/files')
|
|||
try {
|
||||
if ($file->isEmpty()) {
|
||||
$doc = new Document([
|
||||
'$id' => $fileId,
|
||||
'$id' => ID::custom($fileId),
|
||||
'$permissions' => $permissions,
|
||||
'bucketId' => $bucket->getId(),
|
||||
'bucketId' => ID::custom($bucket->getId()),
|
||||
'name' => $fileName,
|
||||
'path' => $path,
|
||||
'signature' => $fileHash,
|
||||
|
@ -580,7 +585,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
|
|||
try {
|
||||
if ($file->isEmpty()) {
|
||||
$doc = new Document([
|
||||
'$id' => $fileId,
|
||||
'$id' => ID::custom($fileId),
|
||||
'$permissions' => $permissions,
|
||||
'bucketId' => $bucket->getId(),
|
||||
'name' => $fileName,
|
||||
|
|
|
@ -21,6 +21,7 @@ use Utopia\Database\Database;
|
|||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Exception\Authorization as AuthorizationException;
|
||||
use Utopia\Database\Exception\Duplicate;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Role;
|
||||
|
@ -60,11 +61,11 @@ App::post('/v1/teams')
|
|||
|
||||
$teamId = $teamId == 'unique()' ? $dbForProject->getId() : $teamId;
|
||||
$team = Authorization::skip(fn() => $dbForProject->createDocument('teams', new Document([
|
||||
'$id' => $teamId ,
|
||||
'$id' => ID::custom($teamId ),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::team($teamId)),
|
||||
Permission::update(Role::team($teamId, 'owner')),
|
||||
Permission::delete(Role::team($teamId, 'owner')),
|
||||
Permission::read(Role::team(ID::custom($teamId))),
|
||||
Permission::update(Role::team(ID::custom($teamId), 'owner')),
|
||||
Permission::delete(Role::team(ID::custom($teamId), 'owner')),
|
||||
],
|
||||
'name' => $name,
|
||||
'total' => ($isPrivilegedUser || $isAppUser) ? 0 : 1,
|
||||
|
@ -74,19 +75,19 @@ App::post('/v1/teams')
|
|||
if (!$isPrivilegedUser && !$isAppUser) { // Don't add user on server mode
|
||||
$membershipId = $dbForProject->getId();
|
||||
$membership = new Document([
|
||||
'$id' => $membershipId,
|
||||
'$id' => ID::custom($membershipId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::read(Role::team($team->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::update(Role::team($team->getId(), 'owner')),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::delete(Role::team($team->getId(), 'owner')),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::read(Role::team(ID::custom($team->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::team(ID::custom($team->getId()), 'owner')),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::team(ID::custom($team->getId()), 'owner')),
|
||||
],
|
||||
'userId' => $user->getId(),
|
||||
'userId' => ID::custom($user->getId()),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'teamId' => $team->getId(),
|
||||
'teamInternalId' => $team->getInternalId(),
|
||||
'teamId' => ID::custom($team->getId()),
|
||||
'teamInternalId' => ID::custom($team->getInternalId()),
|
||||
'roles' => $roles,
|
||||
'invited' => \time(),
|
||||
'joined' => \time(),
|
||||
|
@ -338,12 +339,12 @@ App::post('/v1/teams/:teamId/memberships')
|
|||
try {
|
||||
$userId = $dbForProject->getId();
|
||||
$invitee = Authorization::skip(fn() => $dbForProject->createDocument('users', new Document([
|
||||
'$id' => $userId,
|
||||
'$id' => ID::custom($userId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::read(Role::user($userId)),
|
||||
Permission::update(Role::user($userId)),
|
||||
Permission::delete(Role::user($userId)),
|
||||
Permission::read(Role::user(ID::custom($userId))),
|
||||
Permission::update(Role::user(ID::custom($userId))),
|
||||
Permission::delete(Role::user(ID::custom($userId))),
|
||||
],
|
||||
'email' => $email,
|
||||
'emailVerification' => false,
|
||||
|
@ -379,18 +380,18 @@ App::post('/v1/teams/:teamId/memberships')
|
|||
|
||||
$membershipId = $dbForProject->getId();
|
||||
$membership = new Document([
|
||||
'$id' => $membershipId,
|
||||
'$id' => ID::custom($membershipId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::user($invitee->getId())),
|
||||
Permission::update(Role::team($team->getId(), 'owner')),
|
||||
Permission::delete(Role::user($invitee->getId())),
|
||||
Permission::delete(Role::team($team->getId(), 'owner')),
|
||||
Permission::update(Role::user(ID::custom($invitee->getId()))),
|
||||
Permission::update(Role::team(ID::custom($team->getId()), 'owner')),
|
||||
Permission::delete(Role::user(ID::custom($invitee->getId()))),
|
||||
Permission::delete(Role::team(ID::custom($team->getId()), 'owner')),
|
||||
],
|
||||
'userId' => $invitee->getId(),
|
||||
'userInternalId' => $invitee->getInternalId(),
|
||||
'teamId' => $team->getId(),
|
||||
'teamInternalId' => $team->getInternalId(),
|
||||
'userId' => ID::custom($invitee->getId()),
|
||||
'userInternalId' => ID::custom($invitee->getInternalId()),
|
||||
'teamId' => ID::custom($team->getId()),
|
||||
'teamInternalId' => ID::custom($team->getInternalId()),
|
||||
'roles' => $roles,
|
||||
'invited' => \time(),
|
||||
'joined' => ($isPrivilegedUser || $isAppUser) ? \time() : 0,
|
||||
|
@ -723,9 +724,9 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status')
|
|||
$expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG;
|
||||
$secret = Auth::tokenGenerator();
|
||||
$session = new Document(array_merge([
|
||||
'$id' => $dbForProject->getId(),
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'$id' => ID::custom($dbForProject->getId()),
|
||||
'userId' => ID::custom($user->getId()),
|
||||
'userInternalId' => ID::custom($user->getInternalId()),
|
||||
'provider' => Auth::SESSION_PROVIDER_EMAIL,
|
||||
'providerUid' => $user->getAttribute('email'),
|
||||
'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak
|
||||
|
@ -737,9 +738,9 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status')
|
|||
|
||||
$session = $dbForProject->createDocument('sessions', $session
|
||||
->setAttribute('$permissions', [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user(ID::custom($user->getId()))),
|
||||
Permission::update(Role::user(ID::custom($user->getId()))),
|
||||
Permission::delete(Role::user(ID::custom($user->getId()))),
|
||||
]));
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
@ -895,7 +896,7 @@ App::get('/v1/teams/:teamId/logs')
|
|||
|
||||
$output[$i] = new Document([
|
||||
'event' => $log['event'],
|
||||
'userId' => $log['userId'],
|
||||
'userId' => ID::custom($log['userId']),
|
||||
'userEmail' => $log['data']['userEmail'] ?? null,
|
||||
'userName' => $log['data']['userName'] ?? null,
|
||||
'mode' => $log['data']['mode'] ?? null,
|
||||
|
|
|
@ -14,6 +14,9 @@ use Appwrite\Utopia\Response;
|
|||
use Utopia\App;
|
||||
use Utopia\Audit\Audit;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Locale\Locale;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Utopia\Database\Document;
|
||||
|
@ -56,11 +59,11 @@ App::post('/v1/users')
|
|||
try {
|
||||
$userId = $userId == 'unique()' ? $dbForProject->getId() : $userId;
|
||||
$user = $dbForProject->createDocument('users', new Document([
|
||||
'$id' => $userId,
|
||||
'$id' => ID::custom($userId),
|
||||
'$permissions' => [
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::user($userId)),
|
||||
Permission::delete(Role::user($userId)),
|
||||
Permission::update(Role::user(ID::custom($userId))),
|
||||
Permission::delete(Role::user(ID::custom($userId))),
|
||||
],
|
||||
'email' => $email,
|
||||
'emailVerification' => false,
|
||||
|
|
|
@ -282,7 +282,7 @@ App::post('/v1/mock/tests/general/upload')
|
|||
|
||||
if ($end !== $size) {
|
||||
$response->json([
|
||||
'$id' => 'newfileid',
|
||||
'$id' => ID::custom('newfileid'),
|
||||
'chunksTotal' => $file['size'] / $chunkSize,
|
||||
'chunksUploaded' => $start / $chunkSize
|
||||
]);
|
||||
|
|
13
app/http.php
13
app/http.php
|
@ -10,6 +10,7 @@ use Swoole\Http\Response as SwooleResponse;
|
|||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Permission;
|
||||
use Utopia\Database\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
|
@ -134,7 +135,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
|
|||
|
||||
foreach ($collection['attributes'] as $attribute) {
|
||||
$attributes[] = new Document([
|
||||
'$id' => $attribute['$id'],
|
||||
'$id' => ID::custom($attribute['$id']),
|
||||
'type' => $attribute['type'],
|
||||
'size' => $attribute['size'],
|
||||
'required' => $attribute['required'],
|
||||
|
@ -148,7 +149,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
|
|||
|
||||
foreach ($collection['indexes'] as $index) {
|
||||
$indexes[] = new Document([
|
||||
'$id' => $index['$id'],
|
||||
'$id' => ID::custom($index['$id']),
|
||||
'type' => $index['type'],
|
||||
'attributes' => $index['attributes'],
|
||||
'lengths' => $index['lengths'],
|
||||
|
@ -162,8 +163,8 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
|
|||
if ($dbForConsole->getDocument('buckets', 'default')->isEmpty()) {
|
||||
Console::success('[Setup] - Creating default bucket...');
|
||||
$dbForConsole->createDocument('buckets', new Document([
|
||||
'$id' => 'default',
|
||||
'$collection' => 'buckets',
|
||||
'$id' => ID::custom('default'),
|
||||
'$collection' => ID::custom('buckets'),
|
||||
'name' => 'Default',
|
||||
'maximumFileSize' => (int) App::getEnv('_APP_STORAGE_LIMIT', 0), // 10MB
|
||||
'allowedFileExtensions' => [],
|
||||
|
@ -192,7 +193,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
|
|||
|
||||
foreach ($files['attributes'] as $attribute) {
|
||||
$attributes[] = new Document([
|
||||
'$id' => $attribute['$id'],
|
||||
'$id' => ID::custom($attribute['$id']),
|
||||
'type' => $attribute['type'],
|
||||
'size' => $attribute['size'],
|
||||
'required' => $attribute['required'],
|
||||
|
@ -206,7 +207,7 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
|
|||
|
||||
foreach ($files['indexes'] as $index) {
|
||||
$indexes[] = new Document([
|
||||
'$id' => $index['$id'],
|
||||
'$id' => ID::custom($index['$id']),
|
||||
'type' => $index['type'],
|
||||
'attributes' => $index['attributes'],
|
||||
'lengths' => $index['lengths'],
|
||||
|
|
19
app/init.php
19
app/init.php
|
@ -43,6 +43,7 @@ use Appwrite\OpenSSL\OpenSSL;
|
|||
use Appwrite\Stats\Stats;
|
||||
use Appwrite\Utopia\View;
|
||||
use Utopia\App;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Logger\Logger;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Locale\Locale;
|
||||
|
@ -711,7 +712,7 @@ App::setResource('usage', function ($register) {
|
|||
|
||||
App::setResource('clients', function ($request, $console, $project) {
|
||||
$console->setAttribute('platforms', [ // Always allow current host
|
||||
'$collection' => 'platforms',
|
||||
'$collection' => ID::custom('platforms'),
|
||||
'name' => 'Current Host',
|
||||
'type' => 'web',
|
||||
'hostname' => $request->getHostname(),
|
||||
|
@ -787,7 +788,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons
|
|||
|
||||
if (APP_MODE_ADMIN !== $mode) {
|
||||
if ($project->isEmpty()) {
|
||||
$user = new Document(['$id' => '', '$collection' => 'users']);
|
||||
$user = new Document(['$id' => ID::custom(''), '$collection' => 'users']);
|
||||
} else {
|
||||
$user = $dbForProject->getDocument('users', Auth::$unique);
|
||||
}
|
||||
|
@ -799,14 +800,14 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons
|
|||
$user->isEmpty() // Check a document has been found in the DB
|
||||
|| !Auth::sessionVerify($user->getAttribute('sessions', []), Auth::$secret)
|
||||
) { // Validate user has valid login token
|
||||
$user = new Document(['$id' => '', '$collection' => 'users']);
|
||||
$user = new Document(['$id' => ID::custom(''), '$collection' => 'users']);
|
||||
}
|
||||
|
||||
if (APP_MODE_ADMIN === $mode) {
|
||||
if ($user->find('teamId', $project->getAttribute('teamId'), 'memberships')) {
|
||||
Authorization::setDefaultStatus(false); // Cancel security segmentation for admin users.
|
||||
} else {
|
||||
$user = new Document(['$id' => '', '$collection' => 'users']);
|
||||
$user = new Document(['$id' => ID::custom(''), '$collection' => 'users']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -829,7 +830,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons
|
|||
}
|
||||
|
||||
if (empty($user->find('$id', $jwtSessionId, 'sessions'))) { // Match JWT to active token
|
||||
$user = new Document(['$id' => '', '$collection' => 'users']);
|
||||
$user = new Document(['$id' => ID::custom(''), '$collection' => 'users']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -854,10 +855,10 @@ App::setResource('project', function ($dbForConsole, $request, $console) {
|
|||
|
||||
App::setResource('console', function () {
|
||||
return new Document([
|
||||
'$id' => 'console',
|
||||
'$internalId' => 'console',
|
||||
'$id' => ID::custom('console'),
|
||||
'$internalId' => ID::custom('console'),
|
||||
'name' => 'Appwrite',
|
||||
'$collection' => 'projects',
|
||||
'$collection' => ID::custom('projects'),
|
||||
'description' => 'Appwrite core engine',
|
||||
'logo' => '',
|
||||
'teamId' => -1,
|
||||
|
@ -865,7 +866,7 @@ App::setResource('console', function () {
|
|||
'keys' => [],
|
||||
'platforms' => [
|
||||
[
|
||||
'$collection' => 'platforms',
|
||||
'$collection' => ID::custom('platforms'),
|
||||
'name' => 'Localhost',
|
||||
'type' => 'web',
|
||||
'hostname' => 'localhost',
|
||||
|
|
|
@ -146,8 +146,8 @@ $server->onStart(function () use ($stats, $register, $containerId, &$statsDocume
|
|||
try {
|
||||
$attempts++;
|
||||
$document = new Document([
|
||||
'$id' => $database->getId(),
|
||||
'$collection' => 'realtime',
|
||||
'$id' => ID::custom($database->getId()),
|
||||
'$collection' => ID::custom('realtime'),
|
||||
'$permissions' => [],
|
||||
'container' => $containerId,
|
||||
'timestamp' => time(),
|
||||
|
@ -443,7 +443,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server,
|
|||
]));
|
||||
|
||||
$stats->set($project->getId(), [
|
||||
'projectId' => $project->getId(),
|
||||
'projectId' => ID::custom($project->getId()),
|
||||
'teamId' => $project->getAttribute('teamId')
|
||||
]);
|
||||
$stats->incr($project->getId(), 'connections');
|
||||
|
|
|
@ -80,10 +80,10 @@ class BuildsV1 extends Worker
|
|||
if (empty($buildId)) {
|
||||
$buildId = $dbForProject->getId();
|
||||
$build = $dbForProject->createDocument('builds', new Document([
|
||||
'$id' => $buildId,
|
||||
'$id' => ID::custom($buildId),
|
||||
'$permissions' => [],
|
||||
'startTime' => $startTime,
|
||||
'deploymentId' => $deployment->getId(),
|
||||
'deploymentId' => ID::custom($deployment->getId()),
|
||||
'status' => 'processing',
|
||||
'outputPath' => '',
|
||||
'runtime' => $function->getAttribute('runtime'),
|
||||
|
@ -123,7 +123,7 @@ class BuildsV1 extends Worker
|
|||
|
||||
/** Trigger Realtime */
|
||||
$allEvents = Event::generateEvents('functions.[functionId].deployments.[deploymentId].update', [
|
||||
'functionId' => $function->getId(),
|
||||
'functionId' => ID::custom($function->getId()),
|
||||
'deploymentId' => $deployment->getId()
|
||||
]);
|
||||
$target = Realtime::fromPayload(
|
||||
|
|
|
@ -236,10 +236,10 @@ class FunctionsV1 extends Worker
|
|||
if ($execution->isEmpty()) {
|
||||
$executionId = $dbForProject->getId();
|
||||
$execution = $dbForProject->createDocument('executions', new Document([
|
||||
'$id' => $executionId,
|
||||
'$permissions' => $user->isEmpty() ? [] : [Permission::read(Role::user($user->getId()))],
|
||||
'functionId' => $functionId,
|
||||
'deploymentId' => $deploymentId,
|
||||
'$id' => ID::custom($executionId),
|
||||
'$permissions' => $user->isEmpty() ? [] : [Permission::read(Role::user(ID::custom($user->getId())))],
|
||||
'functionId' => ID::custom($functionId),
|
||||
'deploymentId' => ID::custom($deploymentId),
|
||||
'trigger' => $trigger,
|
||||
'status' => 'waiting',
|
||||
'statusCode' => 0,
|
||||
|
@ -327,7 +327,7 @@ class FunctionsV1 extends Worker
|
|||
|
||||
/** Trigger realtime event */
|
||||
$allEvents = Event::generateEvents('functions.[functionId].executions.[executionId].update', [
|
||||
'functionId' => $function->getId(),
|
||||
'functionId' => ID::custom($function->getId()),
|
||||
'executionId' => $execution->getId()
|
||||
]);
|
||||
$target = Realtime::fromPayload(
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
stopOnFailure="true"
|
||||
>
|
||||
<extensions>
|
||||
<extension class="Appwrite\Tests\TestHook" />
|
||||
|
|
|
@ -9,6 +9,7 @@ use Utopia\CLI\Console;
|
|||
use Utopia\Config\Config;
|
||||
use Exception;
|
||||
use Utopia\App;
|
||||
use Utopia\Database\ID;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
|
||||
abstract class Migration
|
||||
|
@ -62,15 +63,15 @@ abstract class Migration
|
|||
Authorization::setDefaultStatus(false);
|
||||
$this->collections = array_merge([
|
||||
'_metadata' => [
|
||||
'$id' => '_metadata',
|
||||
'$id' => ID::custom('_metadata'),
|
||||
'$collection' => Database::METADATA
|
||||
],
|
||||
'audit' => [
|
||||
'$id' => 'audit',
|
||||
'$id' => ID::custom('audit'),
|
||||
'$collection' => Database::METADATA
|
||||
],
|
||||
'abuse' => [
|
||||
'$id' => 'abuse',
|
||||
'$id' => ID::custom('abuse'),
|
||||
'$collection' => Database::METADATA
|
||||
]
|
||||
], Config::getParam('collections', []));
|
||||
|
|
|
@ -158,8 +158,8 @@ class V12 extends Migration
|
|||
|
||||
if (!$this->projectDB->findOne('buckets', [new Query('$id', Query::TYPE_EQUAL, ['default'])])) {
|
||||
$this->projectDB->createDocument('buckets', new Document([
|
||||
'$id' => 'default',
|
||||
'$collection' => 'buckets',
|
||||
'$id' => ID::custom('default'),
|
||||
'$collection' => ID::custom('buckets'),
|
||||
'dateCreated' => \time(),
|
||||
'dateUpdated' => \time(),
|
||||
'name' => 'Default',
|
||||
|
|
|
@ -67,7 +67,7 @@ class V14 extends Migration
|
|||
|
||||
try {
|
||||
$this->projectDB->createDocument('databases', new Document([
|
||||
'$id' => 'default',
|
||||
'$id' => ID::custom('default'),
|
||||
'name' => 'Default',
|
||||
'search' => 'default Default'
|
||||
]));
|
||||
|
|
|
@ -278,7 +278,7 @@ class V11 extends Filter
|
|||
$content['rules'] = \array_map(function ($attribute) use ($content) {
|
||||
return [
|
||||
'$id' => $attribute['key'],
|
||||
'$collection' => $content['$id'],
|
||||
'$collection' => ID::custom($content['$id']),
|
||||
'type' => $attribute['type'],
|
||||
'key' => $attribute['key'],
|
||||
'label' => $attribute['key'],
|
||||
|
|
|
@ -32,7 +32,7 @@ class Bucket extends Model
|
|||
'type' => self::TYPE_STRING,
|
||||
'description' => 'File permissions.',
|
||||
'default' => [],
|
||||
'example' => [Permission::read(Role::any())],
|
||||
'example' => ['read("any")'],
|
||||
'array' => true,
|
||||
])
|
||||
->addRule('fileSecurity', [
|
||||
|
|
|
@ -32,7 +32,7 @@ class Collection extends Model
|
|||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Collection permissions.',
|
||||
'default' => '',
|
||||
'example' => Permission::read(Role::any()),
|
||||
'example' => ['read("any")'],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('databaseId', [
|
||||
|
|
|
@ -56,9 +56,9 @@ class Document extends Any
|
|||
])
|
||||
->addRule('$permissions', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Document write permissions.',
|
||||
'description' => 'Document permissions.',
|
||||
'default' => '',
|
||||
'example' => Permission::read(Role::user('608f9da25e7e1')),
|
||||
'example' => ['read("any")'],
|
||||
'array' => true,
|
||||
])
|
||||
;
|
||||
|
|
|
@ -28,11 +28,11 @@ class Execution extends Model
|
|||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
])
|
||||
->addRule('$permissions', [
|
||||
->addRule('$roles', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Execution permissions.',
|
||||
'description' => 'Execution roles.',
|
||||
'default' => '',
|
||||
'example' => 'any',
|
||||
'example' => ['any'],
|
||||
'array' => true,
|
||||
])
|
||||
->addRule('functionId', [
|
||||
|
|
|
@ -38,7 +38,7 @@ class File extends Model
|
|||
'type' => self::TYPE_STRING,
|
||||
'description' => 'File permissions.',
|
||||
'default' => [],
|
||||
'example' => Permission::read(Role::any()),
|
||||
'example' => ['read("any")'],
|
||||
'array' => true,
|
||||
])
|
||||
->addRule('name', [
|
||||
|
|
|
@ -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,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',
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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'
|
||||
]);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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'
|
||||
]);
|
||||
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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'
|
||||
]
|
||||
|
|
|
@ -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)',
|
||||
|
|
|
@ -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,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']
|
||||
]));
|
||||
|
||||
|
|
|
@ -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,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',
|
||||
|
|
Loading…
Reference in a new issue