$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);
->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() {
->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')
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');
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'));
}