From 978f15c1c1d72ff60ca793fcbb76295b8a05d8fb Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 3 Sep 2021 18:05:50 +0200 Subject: [PATCH] extend tests --- tests/unit/Auth/AuthTest.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/unit/Auth/AuthTest.php b/tests/unit/Auth/AuthTest.php index 0b1fb5cf7..443f244d4 100644 --- a/tests/unit/Auth/AuthTest.php +++ b/tests/unit/Auth/AuthTest.php @@ -243,6 +243,42 @@ class AuthTest extends TestCase } public function testPrivilegedUserRoles() + { + Authorization::setRole('role:'.Auth::USER_ROLE_OWNER); + $user = new Document([ + '$id' => '123', + 'memberships' => [ + [ + 'teamId' => 'abc', + 'roles' => [ + 'administrator', + 'moderator' + ] + ], + [ + 'teamId' => 'def', + 'roles' => [ + 'guest' + ] + ] + ] + ]); + + $roles = Auth::getRoles($user); + + $this->assertCount(5, $roles); + $this->assertNotContains('role:member', $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); + + Authorization::reset(); + } + + public function testAppUserRoles() { Authorization::setRole('role:'.Auth::USER_ROLE_APP); $user = new Document([