Exemple #1
0
 public function testGetUserAsSubAdminSelfLookup()
 {
     $loggedInUser = $this->getMock('\\OCP\\IUser');
     $loggedInUser->expects($this->exactly(2))->method('getUID')->will($this->returnValue('subadmin'));
     $targetUser = $this->getMock('\\OCP\\IUser');
     $this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($loggedInUser));
     $this->userManager->expects($this->once())->method('get')->with('subadmin')->will($this->returnValue($targetUser));
     $this->groupManager->expects($this->once())->method('isAdmin')->with('subadmin')->will($this->returnValue(false));
     $subAdminManager = $this->getMockBuilder('\\OC\\Subadmin')->disableOriginalConstructor()->getMock();
     $subAdminManager->expects($this->once())->method('isUserAccessible')->with($loggedInUser, $targetUser)->will($this->returnValue(false));
     $this->groupManager->expects($this->once())->method('getSubAdmin')->will($this->returnValue($subAdminManager));
     $this->api->expects($this->once())->method('fillStorageInfo')->with('subadmin')->will($this->returnValue(['DummyValue']));
     $this->config->expects($this->once())->method('getUserValue')->with('subadmin', 'settings', 'email')->will($this->returnValue('*****@*****.**'));
     $targetUser->expects($this->once())->method('getDisplayName')->will($this->returnValue('Subadmin User'));
     $expected = new \OC_OCS_Result(['quota' => ['DummyValue'], 'email' => '*****@*****.**', 'displayname' => 'Subadmin User']);
     $this->assertEquals($expected, $this->api->getUser(['userid' => 'subadmin']));
 }
Exemple #2
0
 public function testGetUserOnOtherUser()
 {
     $users = $this->generateUsers(2);
     $params['userid'] = $users[0];
     self::loginAsUser($users[1]);
     $result = \OCA\provisioning_API\Users::getUser($params);
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertFalse($result->succeeded());
     // Now as as admin
     $users = $this->generateUsers(2);
     $params['userid'] = $users[0];
     // login to generate home
     self::loginAsUser($users[0]);
     \OC_Group::addToGroup($users[1], 'admin');
     self::loginAsUser($users[1]);
     $result = \OCA\provisioning_API\Users::getUser($params);
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertTrue($result->succeeded());
     $data = $result->getData();
     $this->assertEquals(\OC::$server->getConfig()->getUserValue($users[0], 'core', 'enabled', 'true'), $data['enabled']);
 }