// Admin? Or SubAdmin?
if($this->groupManager->isAdmin($currentLoggedInUser->getUID())
|| $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) {
- $data['enabled'] = $this->config->getUserValue($userId, 'core', 'enabled', 'true');
+ $data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true');
} else {
// Check they are looking up themselves
- if($currentLoggedInUser->getUID() !== $userId) {
+ if($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) {
throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
}
}
// Find the data
$data['id'] = $targetUserObject->getUID();
- $data['quota'] = $this->fillStorageInfo($userId);
+ $data['quota'] = $this->fillStorageInfo($targetUserObject->getUID());
$data['email'] = $targetUserObject->getEMailAddress();
$data['displayname'] = $targetUserObject->getDisplayName();
$data['phone'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_PHONE]['value'];
}
$permittedFields = [];
- if($userId === $currentLoggedInUser->getUID()) {
+ if($targetUser->getUID() === $currentLoggedInUser->getUID()) {
// Editing self (display, email)
$permittedFields[] = 'display';
$permittedFields[] = 'email';
throw new OCSException('', 104);
}
// Check they aren't removing themselves from 'admin' or their 'subadmin; group
- if($userId === $loggedInUser->getUID()) {
- if($this->groupManager->isAdmin($loggedInUser->getUID())) {
- if($group->getGID() === 'admin') {
+ if ($targetUser->getUID() === $loggedInUser->getUID()) {
+ if ($this->groupManager->isAdmin($loggedInUser->getUID())) {
+ if ($group->getGID() === 'admin') {
throw new OCSException('Cannot remove yourself from the admin group', 105);
}
} else {
$this->config
->expects($this->at(0))
->method('getUserValue')
- ->with('UserToGet', 'core', 'enabled', 'true')
+ ->with('UID', 'core', 'enabled', 'true')
->will($this->returnValue('true'));
$this->api
->expects($this->once())
->method('fillStorageInfo')
- ->with('UserToGet')
+ ->with('UID')
->will($this->returnValue(['DummyValue']));
$targetUser
->expects($this->once())
->method('getDisplayName')
->will($this->returnValue('Demo User'));
$targetUser
- ->expects($this->once())
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('UID'));
$this->config
->expects($this->at(0))
->method('getUserValue')
- ->with('UserToGet', 'core', 'enabled', 'true')
+ ->with('UID', 'core', 'enabled', 'true')
->will($this->returnValue('true'));
$this->api
->expects($this->once())
->method('fillStorageInfo')
- ->with('UserToGet')
+ ->with('UID')
->will($this->returnValue(['DummyValue']));
$targetUser
->expects($this->once())
->method('getDisplayName')
->will($this->returnValue('Demo User'));
$targetUser
- ->expects($this->once())
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('UID'));
$this->accountManager->expects($this->any())->method('getUser')
$loggedInUser
->expects($this->exactly(2))
->method('getUID')
- ->will($this->returnValue('subadmin'));
+ ->will($this->returnValue('UID'));
$targetUser = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
$this->groupManager
->expects($this->once())
->method('isAdmin')
- ->with('subadmin')
+ ->with('UID')
->will($this->returnValue(false));
$subAdminManager = $this->getMockBuilder('OC\SubAdmin')
->disableOriginalConstructor()
$this->api
->expects($this->once())
->method('fillStorageInfo')
- ->with('subadmin')
+ ->with('UID')
->will($this->returnValue(['DummyValue']));
$targetUser
->expects($this->once())
->method('getEMailAddress')
->will($this->returnValue('subadmin@owncloud.org'));
$targetUser
- ->expects($this->once())
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('UID'));
$this->accountManager->expects($this->any())->method('getUser')
$loggedInUser
->expects($this->any())
->method('getUID')
- ->will($this->returnValue('UserToEdit'));
+ ->will($this->returnValue('UID'));
$targetUser = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
->expects($this->once())
->method('setDisplayName')
->with('NewDisplayName');
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->assertEquals([], $this->api->editUser('UserToEdit', 'display', 'NewDisplayName')->getData());
}
$loggedInUser
->expects($this->any())
->method('getUID')
- ->will($this->returnValue('UserToEdit'));
+ ->will($this->returnValue('UID'));
$targetUser = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
->expects($this->once())
->method('setEMailAddress')
->with('demo@owncloud.org');
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->assertEquals([], $this->api->editUser('UserToEdit', 'email', 'demo@owncloud.org')->getData());
}
$loggedInUser
->expects($this->any())
->method('getUID')
- ->will($this->returnValue('UserToEdit'));
+ ->will($this->returnValue('UID'));
$targetUser = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
->method('get')
->with('UserToEdit')
->will($this->returnValue($targetUser));
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->api->editUser('UserToEdit', 'email', 'demo.org');
}
$loggedInUser
->expects($this->any())
->method('getUID')
- ->will($this->returnValue('UserToEdit'));
+ ->will($this->returnValue('UID'));
$targetUser = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
->expects($this->once())
->method('setPassword')
->with('NewPassword');
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->assertEquals([], $this->api->editUser('UserToEdit', 'password', 'NewPassword')->getData());
}
$loggedInUser
->expects($this->any())
->method('getUID')
- ->will($this->returnValue('UserToEdit'));
+ ->will($this->returnValue('UID'));
$targetUser = $this->getMockBuilder('OCP\IUser')
->disableOriginalConstructor()
->getMock();
->method('get')
->with('UserToEdit')
->will($this->returnValue($targetUser));
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->api->editUser('UserToEdit', 'quota', 'NewQuota');
}
$loggedInUser
->expects($this->any())
->method('getUID')
- ->will($this->returnValue('UserToEdit'));
+ ->will($this->returnValue('UID'));
$targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser->expects($this->once())
->method('setQuota')
$this->groupManager
->expects($this->once())
->method('isAdmin')
- ->with('UserToEdit')
+ ->with('UID')
->will($this->returnValue(true));
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->assertEquals([], $this->api->editUser('UserToEdit', 'quota', '3042824')->getData());
}
$loggedInUser
->expects($this->any())
->method('getUID')
- ->will($this->returnValue('UserToEdit'));
+ ->will($this->returnValue('UID'));
$targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
$this->groupManager
->expects($this->once())
->method('isAdmin')
- ->with('UserToEdit')
+ ->with('UID')
->will($this->returnValue(true));
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->api->editUser('UserToEdit', 'quota', 'ABC');
}
->expects($this->once())
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->assertEquals([], $this->api->editUser('UserToEdit', 'quota', '3042824')->getData());
}
->expects($this->once())
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->assertEquals([], $this->api->editUser('UserToEdit', 'quota', '3042824')->getData());
}
->expects($this->once())
->method('getSubAdmin')
->will($this->returnValue($subAdminManager));
+ $targetUser
+ ->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('UID'));
$this->api->editUser('UserToEdit', 'quota', 'value');
}
$loggedInUser
->expects($this->any())
->method('getUID')
- ->will($this->returnValue('UserToDelete'));
+ ->will($this->returnValue('UID'));
$targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
$targetUser
->expects($this->once())
->method('getUID')
- ->will($this->returnValue('UserToDelete'));
+ ->will($this->returnValue('UID'));
$this->userSession
->expects($this->once())
->method('getUser')
$targetUser
->expects($this->once())
->method('getUID')
- ->will($this->returnValue('UserToDelete'));
+ ->will($this->returnValue('UID'));
$this->userSession
->expects($this->once())
->method('getUser')
$targetUser
->expects($this->once())
->method('getUID')
- ->will($this->returnValue('UserToDelete'));
+ ->will($this->returnValue('UID'));
$this->userSession
->expects($this->once())
->method('getUser')
$targetUser
->expects($this->once())
->method('getUID')
- ->will($this->returnValue('UserToDelete'));
+ ->will($this->returnValue('UID'));
$this->userSession
->expects($this->once())
->method('getUser')
$targetUser
->expects($this->once())
->method('getUID')
- ->will($this->returnValue('UserToDelete'));
+ ->will($this->returnValue('UID'));
$this->userSession
->expects($this->once())
->method('getUser')
$targetUser
->expects($this->once())
->method('getUID')
- ->will($this->returnValue('UserToDelete'));
+ ->will($this->returnValue('UID'));
$this->userSession
->expects($this->once())
->method('getUser')
->method('getUID')
->will($this->returnValue('admin'));
$targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetUser
+ ->expects($this->once())
+ ->method('getUID')
+ ->will($this->returnValue('admin'));
$targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$targetGroup
->expects($this->once())
$this->userManager
->expects($this->once())
->method('get')
- ->with('admin')
+ ->with('Admin')
->will($this->returnValue($targetUser));
$subAdminManager = $this->getMockBuilder('OC\SubAdmin')
->disableOriginalConstructor()->getMock();
->with('admin')
->will($this->returnValue(true));
- $this->api->removeFromGroup('admin', 'admin');
+ $this->api->removeFromGroup('Admin', 'admin');
}
/**
->method('getUID')
->will($this->returnValue('subadmin'));
$targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();
+ $targetUser
+ ->expects($this->once())
+ ->method('getUID')
+ ->will($this->returnValue('subadmin'));
$targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$targetGroup
->expects($this->any())
$this->userManager
->expects($this->once())
->method('get')
- ->with('subadmin')
+ ->with('SubAdmin')
->will($this->returnValue($targetUser));
$subAdminManager = $this->getMockBuilder('OC\SubAdmin')
->disableOriginalConstructor()->getMock();
->with('subadmin')
->will($this->returnValue(false));
- $this->api->removeFromGroup('subadmin', 'subadmin');
+ $this->api->removeFromGroup('SubAdmin', 'subadmin');
}
public function testRemoveFromGroupSuccessful() {
public function testGetCurrentUserLoggedIn() {
- $user = $this->getMock(IUser::class);
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$user->expects($this->once())->method('getUID')->willReturn('UID');
$this->userSession->expects($this->once())->method('getUser')