diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-01-16 13:27:45 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2018-01-16 18:39:11 +0100 |
commit | 55532f19d90b40f7f46354b92a5322676729ba7e (patch) | |
tree | c29ee88dbb789c7c0aa9c9f1c08fccef27272d7f /apps | |
parent | a159d7c28c483a2b77e2f533795f6d6d1ec720fd (diff) | |
download | nextcloud-server-55532f19d90b40f7f46354b92a5322676729ba7e.tar.gz nextcloud-server-55532f19d90b40f7f46354b92a5322676729ba7e.zip |
Cleanup OC_User and OCP\User
* mainly removes deprecated methods and old static code
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/federatedfilesharing/lib/Controller/RequestHandlerController.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/tests/CacheTest.php | 6 | ||||
-rw-r--r-- | apps/user_ldap/lib/Access.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/tests/User_LDAPTest.php | 24 |
4 files changed, 25 insertions, 11 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php index e0985f9aefc..a74342f1182 100644 --- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php +++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php @@ -148,7 +148,7 @@ class RequestHandlerController extends OCSController { ); \OCP\Util::writeLog('files_sharing', 'shareWith after, ' . $shareWith, \OCP\Util::DEBUG); - if (!\OCP\User::userExists($shareWith)) { + if (!\OC::$server->getUserManager()->userExists($shareWith)) { throw new OCSException('User does not exists', 400); } diff --git a/apps/files_sharing/tests/CacheTest.php b/apps/files_sharing/tests/CacheTest.php index 5d5de433ee4..c891f56f3d3 100644 --- a/apps/files_sharing/tests/CacheTest.php +++ b/apps/files_sharing/tests/CacheTest.php @@ -66,8 +66,10 @@ class CacheTest extends TestCase { $this->shareManager = \OC::$server->getShareManager(); - \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER1, 'User One'); - \OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER2, 'User Two'); + + $userManager = \OC::$server->getUserManager(); + $userManager->get(self::TEST_FILES_SHARING_API_USER1)->setDisplayName('User One'); + $userManager->get(self::TEST_FILES_SHARING_API_USER2)->setDisplayName('User Two'); self::loginHelper(self::TEST_FILES_SHARING_API_USER1); diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index b84f5a38b31..43feeb4c1f0 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -588,7 +588,7 @@ class Access extends LDAPUtility implements IUserTools { // outside of core user management will still cache the user as non-existing. $originalTTL = $this->connection->ldapCacheTTL; $this->connection->setConfiguration(array('ldapCacheTTL' => 0)); - if(($isUser && $intName !== '' && !\OCP\User::userExists($intName)) + if(($isUser && $intName !== '' && !\OC::$server->getUserManager()->userExists($intName)) || (!$isUser && !\OC::$server->getGroupManager()->groupExists($intName))) { if($mapper->map($fdn, $intName, $uuid)) { $this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL)); @@ -721,7 +721,7 @@ class Access extends LDAPUtility implements IUserTools { //20 attempts, something else is very wrong. Avoids infinite loop. while($attempts < 20){ $altName = $name . '_' . rand(1000,9999); - if(!\OCP\User::userExists($altName)) { + if(!\OC::$server->getUserManager()->userExists($altName)) { return $altName; } $attempts++; diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php index 3262a2360ad..9911aa37e37 100644 --- a/apps/user_ldap/tests/User_LDAPTest.php +++ b/apps/user_ldap/tests/User_LDAPTest.php @@ -275,7 +275,11 @@ class User_LDAPTest extends TestCase { $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock()); \OC_User::useBackend($backend); - $result = \OCP\User::checkPassword('roland', 'dt19'); + $user = \OC::$server->getUserManager()->checkPassword('roland', 'dt19'); + $result = false; + if ($user !== false) { + $result = $user->getUID(); + } $this->assertEquals('gunslinger', $result); } @@ -285,7 +289,11 @@ class User_LDAPTest extends TestCase { $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock()); \OC_User::useBackend($backend); - $result = \OCP\User::checkPassword('roland', 'wrong'); + $user = \OC::$server->getUserManager()->checkPassword('roland', 'wrong'); + $result = false; + if ($user !== false) { + $result = $user->getUID(); + } $this->assertFalse($result); } @@ -295,7 +303,11 @@ class User_LDAPTest extends TestCase { $backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock()); \OC_User::useBackend($backend); - $result = \OCP\User::checkPassword('mallory', 'evil'); + $user = \OC::$server->getUserManager()->checkPassword('mallory', 'evil'); + $result = false; + if ($user !== false) { + $result = $user->getUID(); + } $this->assertFalse($result); } @@ -629,7 +641,7 @@ class User_LDAPTest extends TestCase { ->willReturn($this->createMock(UserMapping::class)); //test for existing user - $result = \OCP\User::userExists('gunslinger'); + $result = \OC::$server->getUserManager()->userExists('gunslinger'); $this->assertTrue($result); } @@ -656,7 +668,7 @@ class User_LDAPTest extends TestCase { ->willReturn($this->createMock(User::class)); //test for deleted user - \OCP\User::userExists('formerUser'); + \OC::$server->getUserManager()->userExists('formerUser'); } public function testUserExistsPublicAPIForNeverExisting() { @@ -675,7 +687,7 @@ class User_LDAPTest extends TestCase { })); //test for never-existing user - $result = \OCP\User::userExists('mallory'); + $result = \OC::$server->getUserManager()->userExists('mallory'); $this->assertFalse($result); } |