]> source.dussan.org Git - nextcloud-server.git/commitdiff
admin have no special rights on users' entries 40271/head
authorMaxence Lange <maxence@artificial-owl.com>
Thu, 31 Aug 2023 17:00:21 +0000 (16:00 -0100)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 7 Sep 2023 09:04:55 +0000 (11:04 +0200)
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
apps/files_external/lib/Controller/AjaxController.php
apps/files_external/tests/Controller/AjaxControllerTest.php

index db23ecd709d632c95985db2c720f39c28208a504..e41a75a62bc091d46841a9cdd04f7982fa434648 100644 (file)
@@ -108,7 +108,7 @@ class AjaxController extends Controller {
                $currentUser = $this->userSession->getUser();
 
                // Non-admins can only edit their own credentials
-               $allowedToEdit = ($this->groupManager->isAdmin($currentUser->getUID()) || $currentUser->getUID() === $uid);
+               $allowedToEdit = ($currentUser->getUID() === $uid);
 
                if ($allowedToEdit) {
                        $this->globalAuth->saveAuth($uid, $user, $password);
index 2ddd64f0e073ae1ca5174c87e0cb36f161b3fd53..304a1807931107723167c2a5173d14261cc17171 100644 (file)
@@ -102,17 +102,11 @@ class AjaxControllerTest extends TestCase {
                        ->expects($this->once())
                        ->method('getUser')
                        ->willReturn($user);
-               $this->groupManager
-                       ->expects($this->once())
-                       ->method('isAdmin')
-                       ->with('MyAdminUid')
-                       ->willReturn(true);
                $this->globalAuth
-                       ->expects($this->once())
-                       ->method('saveAuth')
-                       ->with('UidOfTestUser', 'test', 'password');
+                       ->expects($this->never())
+                       ->method('saveAuth');
 
-               $this->assertSame(true, $this->ajaxController->saveGlobalCredentials('UidOfTestUser', 'test', 'password'));
+               $this->assertSame(false, $this->ajaxController->saveGlobalCredentials('UidOfTestUser', 'test', 'password'));
        }
 
        public function testSaveGlobalCredentialsAsAdminForSelf() {
@@ -125,11 +119,6 @@ class AjaxControllerTest extends TestCase {
                        ->expects($this->once())
                        ->method('getUser')
                        ->willReturn($user);
-               $this->groupManager
-                       ->expects($this->once())
-                       ->method('isAdmin')
-                       ->with('MyAdminUid')
-                       ->willReturn(true);
                $this->globalAuth
                        ->expects($this->once())
                        ->method('saveAuth')
@@ -141,20 +130,12 @@ class AjaxControllerTest extends TestCase {
        public function testSaveGlobalCredentialsAsNormalUserForSelf() {
                $user = $this->createMock(IUser::class);
                $user
-                       ->expects($this->exactly(2))
                        ->method('getUID')
                        ->willReturn('MyUserUid');
                $this->userSession
-                       ->expects($this->once())
                        ->method('getUser')
                        ->willReturn($user);
-               $this->groupManager
-                       ->expects($this->once())
-                       ->method('isAdmin')
-                       ->with('MyUserUid')
-                       ->willReturn(false);
                $this->globalAuth
-                       ->expects($this->once())
                        ->method('saveAuth')
                        ->with('MyUserUid', 'test', 'password');
 
@@ -164,18 +145,14 @@ class AjaxControllerTest extends TestCase {
        public function testSaveGlobalCredentialsAsNormalUserForAnotherUser() {
                $user = $this->createMock(IUser::class);
                $user
-                       ->expects($this->exactly(2))
                        ->method('getUID')
                        ->willReturn('MyUserUid');
                $this->userSession
-                       ->expects($this->once())
                        ->method('getUser')
                        ->willReturn($user);
-               $this->groupManager
-                       ->expects($this->once())
-                       ->method('isAdmin')
-                       ->with('MyUserUid')
-                       ->willReturn(false);
+               $this->globalAuth
+                       ->expects($this->never())
+                       ->method('saveAuth');
 
                $this->assertSame(false, $this->ajaxController->saveGlobalCredentials('AnotherUserUid', 'test', 'password'));
        }