1
0
Fork 0
mirror of synced 2024-06-14 00:34:51 +12:00

Review test updates

This commit is contained in:
Jake Barnby 2022-08-27 15:16:37 +12:00
parent d78795e7bd
commit 790276fced
8 changed files with 36 additions and 32 deletions

View file

@ -1604,8 +1604,8 @@ trait DatabasesBase
],
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
Permission::update(Role::user(ID::custom($this->getUser()['$id']))),
Permission::delete(Role::user(ID::custom($this->getUser()['$id']))),
Permission::update(Role::user($this->getUser()['$id'])),
Permission::delete(Role::user($this->getUser()['$id'])),
]
]);

View file

@ -95,6 +95,12 @@ class DatabasesPermissionsMemberTest extends Scope
'users' => 11,
'doconly' => 6,
],
[
'permissions' => [Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())],
'any' => 12,
'users' => 12,
'doconly' => 7,
],
];
}

View file

@ -7,6 +7,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Client;
use Tests\E2E\Scopes\SideConsole;
use Utopia\Database\ID;
use Utopia\Database\Role;
class FunctionsConsoleClientTest extends Scope
{
@ -21,7 +22,7 @@ class FunctionsConsoleClientTest extends Scope
], $this->getHeaders()), [
'functionId' => ID::unique(),
'name' => 'Test',
'execute' => ["user:{$this->getUser()['$id']}"],
'execute' => [Role::user($this->getUser()['$id'])->toString()],
'runtime' => 'php-8.0',
'vars' => [
'funcKey1' => 'funcValue1',

View file

@ -59,7 +59,7 @@ class FunctionsCustomClientTest extends Scope
], [
'functionId' => ID::unique(),
'name' => 'Test',
'execute' => ["user:{$this->getUser()['$id']}"],
'execute' => [Role::user($this->getUser()['$id'])->toString()],
'runtime' => 'php-8.0',
'vars' => [
'funcKey1' => 'funcValue1',

View file

@ -396,7 +396,7 @@ class ProjectsConsoleClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'provider' => 'unknown',
'appId' => ID::custom('AppId'),
'appId' => 'AppId',
'secret' => 'Secret',
]);

View file

@ -648,10 +648,7 @@ class RealtimeCustomClientTest extends Scope
'collectionId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::users()),
Permission::create(Role::users()),
Permission::update(Role::users()),
Permission::delete(Role::users()),
Permission::create(Role::user($this->getUser()['$id'])),
],
'documentSecurity' => true,
]);

View file

@ -371,13 +371,13 @@ class AuthTest extends TestCase
$roles = Auth::getRoles($user);
$this->assertCount(7, $roles);
$this->assertContains('users', $roles);
$this->assertContains('user:123', $roles);
$this->assertContains('team:abc', $roles);
$this->assertContains('team:abc/administrator', $roles);
$this->assertContains('team:abc/moderator', $roles);
$this->assertContains('team:def', $roles);
$this->assertContains('team:def/guest', $roles);
$this->assertContains(Role::users()->toString(), $roles);
$this->assertContains(Role::user(ID::custom('123')), $roles);
$this->assertContains(Role::team(ID::custom('abc')), $roles);
$this->assertContains(Role::team(ID::custom('abc'), 'administrator'), $roles);
$this->assertContains(Role::team(ID::custom('abc'), 'moderator'), $roles);
$this->assertContains(Role::team(ID::custom('def')), $roles);
$this->assertContains(Role::team(ID::custom('def'), 'guest'), $roles);
}
public function testPrivilegedUserRoles(): void
@ -405,13 +405,13 @@ class AuthTest extends TestCase
$roles = Auth::getRoles($user);
$this->assertCount(5, $roles);
$this->assertNotContains('users', $roles);
$this->assertNotContains('user:123', $roles);
$this->assertContains('team:abc', $roles);
$this->assertContains('team:abc/administrator', $roles);
$this->assertContains('team:abc/moderator', $roles);
$this->assertContains('team:def', $roles);
$this->assertContains('team:def/guest', $roles);
$this->assertNotContains(Role::users()->toString(), $roles);
$this->assertNotContains(Role::user(ID::custom('123')), $roles);
$this->assertContains(Role::team(ID::custom('abc')), $roles);
$this->assertContains(Role::team(ID::custom('abc'), 'administrator'), $roles);
$this->assertContains(Role::team(ID::custom('abc'), 'moderator'), $roles);
$this->assertContains(Role::team(ID::custom('def')), $roles);
$this->assertContains(Role::team(ID::custom('def'), 'guest'), $roles);
}
public function testAppUserRoles(): void
@ -439,12 +439,12 @@ class AuthTest extends TestCase
$roles = Auth::getRoles($user);
$this->assertCount(5, $roles);
$this->assertNotContains('users', $roles);
$this->assertNotContains('user:123', $roles);
$this->assertContains('team:abc', $roles);
$this->assertContains('team:abc/administrator', $roles);
$this->assertContains('team:abc/moderator', $roles);
$this->assertContains('team:def', $roles);
$this->assertContains('team:def/guest', $roles);
$this->assertNotContains(Role::users()->toString(), $roles);
$this->assertNotContains(Role::user(ID::custom('123')), $roles);
$this->assertContains(Role::team(ID::custom('abc')), $roles);
$this->assertContains(Role::team(ID::custom('abc'), 'administrator'), $roles);
$this->assertContains(Role::team(ID::custom('abc'), 'moderator'), $roles);
$this->assertContains(Role::team(ID::custom('def')), $roles);
$this->assertContains(Role::team(ID::custom('def'), 'guest'), $roles);
}
}

View file

@ -58,7 +58,7 @@ class MessagingChannelsTest extends TestCase
'roles' => [
empty($index % 2)
? Auth::USER_ROLE_ADMIN
: Role::users()->toString(),
: 'member',
]
]
]
@ -288,7 +288,7 @@ class MessagingChannelsTest extends TestCase
ID::custom('team' . $index),
(empty($index % 2)
? Auth::USER_ROLE_ADMIN
: Role::users()->toString())
: 'member')
)->toString()
];