From 835911bce5cf8da9ce6d4021f0836b11d6b97d31 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 17 Dec 2015 15:10:11 +0100 Subject: [PATCH] Removed deprecated private OC_User::createUser All function calls are replaced with the recommended (which was already the body of the function). --- apps/encryption/tests/lib/MigrationTest.php | 6 +++--- apps/files/tests/service/tagservice.php | 2 +- .../tests/controller/sharecontroller.php | 2 +- apps/files_sharing/tests/testcase.php | 2 +- apps/files_trashbin/tests/trashbin.php | 2 +- lib/private/user.php | 18 ------------------ tests/lib/cache/file.php | 2 +- tests/lib/files/cache/cache.php | 2 +- tests/lib/files/cache/updaterlegacy.php | 2 +- tests/lib/files/filesystem.php | 8 ++++---- tests/lib/files/objectstore/swift.php | 2 +- tests/lib/files/storage/homestoragequota.php | 4 ++-- tests/lib/helperstorage.php | 2 +- tests/lib/security/certificatemanager.php | 2 +- tests/lib/share/share.php | 14 +++++++------- tests/lib/tags.php | 4 ++-- tests/lib/user.php | 17 +---------------- 17 files changed, 29 insertions(+), 62 deletions(-) diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php index fc3d014345b..ec1dccb87b8 100644 --- a/apps/encryption/tests/lib/MigrationTest.php +++ b/apps/encryption/tests/lib/MigrationTest.php @@ -43,9 +43,9 @@ class MigrationTest extends \Test\TestCase { public static function setUpBeforeClass() { parent::setUpBeforeClass(); - \OC_User::createUser(self::TEST_ENCRYPTION_MIGRATION_USER1, 'foo'); - \OC_User::createUser(self::TEST_ENCRYPTION_MIGRATION_USER2, 'foo'); - \OC_User::createUser(self::TEST_ENCRYPTION_MIGRATION_USER3, 'foo'); + \OC::$server->getUserManager()->createUser(self::TEST_ENCRYPTION_MIGRATION_USER1, 'foo'); + \OC::$server->getUserManager()->createUser(self::TEST_ENCRYPTION_MIGRATION_USER2, 'foo'); + \OC::$server->getUserManager()->createUser(self::TEST_ENCRYPTION_MIGRATION_USER3, 'foo'); } public static function tearDownAfterClass() { diff --git a/apps/files/tests/service/tagservice.php b/apps/files/tests/service/tagservice.php index 36da3edc61e..a34bd05afcc 100644 --- a/apps/files/tests/service/tagservice.php +++ b/apps/files/tests/service/tagservice.php @@ -54,7 +54,7 @@ class TagServiceTest extends \Test\TestCase { protected function setUp() { parent::setUp(); $this->user = $this->getUniqueId('user'); - \OC_User::createUser($this->user, 'test'); + \OC::$server->getUserManager()->createUser($this->user, 'test'); \OC_User::setUserId($this->user); \OC_Util::setupFS($this->user); /** diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php index 168488f5613..d165151b87f 100644 --- a/apps/files_sharing/tests/controller/sharecontroller.php +++ b/apps/files_sharing/tests/controller/sharecontroller.php @@ -78,7 +78,7 @@ class ShareControllerTest extends \Test\TestCase { // Create a dummy user $this->user = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(12, ISecureRandom::CHAR_LOWER); - \OC_User::createUser($this->user, $this->user); + \OC::$server->getUserManager()->createUser($this->user, $this->user); \OC_Util::tearDownFS(); $this->loginAsUser($this->user); diff --git a/apps/files_sharing/tests/testcase.php b/apps/files_sharing/tests/testcase.php index a74ee83c25b..cc82fc3d949 100644 --- a/apps/files_sharing/tests/testcase.php +++ b/apps/files_sharing/tests/testcase.php @@ -149,7 +149,7 @@ abstract class TestCase extends \Test\TestCase { } if ($create) { - \OC_User::createUser($user, $password); + \OC::$server->getUserManager()->createUser($user, $password); \OC_Group::createGroup('group'); \OC_Group::addToGroup($user, 'group'); } diff --git a/apps/files_trashbin/tests/trashbin.php b/apps/files_trashbin/tests/trashbin.php index db7e7e6e840..e8d586816c3 100644 --- a/apps/files_trashbin/tests/trashbin.php +++ b/apps/files_trashbin/tests/trashbin.php @@ -636,7 +636,7 @@ class Test_Trashbin extends \Test\TestCase { public static function loginHelper($user, $create = false) { if ($create) { try { - \OC_User::createUser($user, $user); + \OC::$server->getUserManager()->createUser($user, $user); } catch(\Exception $e) { // catch username is already being used from previous aborted runs } diff --git a/lib/private/user.php b/lib/private/user.php index 9094f388f9e..3c011d5cc81 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -190,24 +190,6 @@ class OC_User { } } - /** - * Create a new user - * - * @param string $uid The username of the user to create - * @param string $password The password of the new user - * @throws Exception - * @return bool true/false - * - * Creates a new user. Basic checking of username is done in OC_User - * itself, not in its subclasses. - * - * Allowed characters in the username are: "a-z", "A-Z", "0-9" and "_.@-" - * @deprecated Use \OC::$server->getUserManager()->createUser($uid, $password) - */ - public static function createUser($uid, $password) { - return \OC::$server->getUserManager()->createUser($uid, $password); - } - /** * delete a user * diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php index 7aa969df02c..0880e7e1282 100644 --- a/tests/lib/cache/file.php +++ b/tests/lib/cache/file.php @@ -71,7 +71,7 @@ class FileCache extends \Test_Cache { \OC_User::useBackend(new \Test\Util\User\Dummy()); //login - \OC_User::createUser('test', 'test'); + \OC::$server->getUserManager()->createUser('test', 'test'); $this->user = \OC_User::getUser(); \OC_User::setUserId('test'); diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php index 503d25597cd..6ae095fa5c2 100644 --- a/tests/lib/files/cache/cache.php +++ b/tests/lib/files/cache/cache.php @@ -317,7 +317,7 @@ class Cache extends \Test\TestCase { function testSearchByTag() { $userId = $this->getUniqueId('user'); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); $this->loginAsUser($userId); $user = new \OC\User\User($userId, null); diff --git a/tests/lib/files/cache/updaterlegacy.php b/tests/lib/files/cache/updaterlegacy.php index 1946913bba4..ca59850eb0b 100644 --- a/tests/lib/files/cache/updaterlegacy.php +++ b/tests/lib/files/cache/updaterlegacy.php @@ -57,7 +57,7 @@ class UpdaterLegacy extends \Test\TestCase { self::$user = $this->getUniqueID(); } - \OC_User::createUser(self::$user, 'password'); + \OC::$server->getUserManager()->createUser(self::$user, 'password'); $this->loginAsUser(self::$user); Filesystem::init(self::$user, '/' . self::$user . '/files'); diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index c5ebbdd1a2d..1de8cba5446 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -325,7 +325,7 @@ class Filesystem extends \Test\TestCase { public function testHomeMount() { $userId = $this->getUniqueID('user_'); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); \OC\Files\Filesystem::initMountPoints($userId); @@ -360,7 +360,7 @@ class Filesystem extends \Test\TestCase { // this will trigger the insert $cache = $localStorage->getCache(); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); \OC\Files\Filesystem::initMountPoints($userId); $homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/'); @@ -388,7 +388,7 @@ class Filesystem extends \Test\TestCase { // no cache path configured $config->setSystemValue('cache_path', ''); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); \OC\Files\Filesystem::initMountPoints($userId); $this->assertEquals( @@ -416,7 +416,7 @@ class Filesystem extends \Test\TestCase { $cachePath = \OC_Helper::tmpFolder() . '/extcache'; $config->setSystemValue('cache_path', $cachePath); - \OC_User::createUser($userId, $userId); + \OC::$server->getUserManager()->createUser($userId, $userId); \OC\Files\Filesystem::initMountPoints($userId); $this->assertEquals( diff --git a/tests/lib/files/objectstore/swift.php b/tests/lib/files/objectstore/swift.php index 63332af68da..906efb6390f 100644 --- a/tests/lib/files/objectstore/swift.php +++ b/tests/lib/files/objectstore/swift.php @@ -52,7 +52,7 @@ class Swift extends \Test\Files\Storage\Storage { $users = array('test'); foreach($users as $userName) { \OC_User::deleteUser($userName); - \OC_User::createUser($userName, $userName); + \OC::$server->getUserManager()->createUser($userName, $userName); } // main test user diff --git a/tests/lib/files/storage/homestoragequota.php b/tests/lib/files/storage/homestoragequota.php index 49e8f499efd..bee05438c80 100644 --- a/tests/lib/files/storage/homestoragequota.php +++ b/tests/lib/files/storage/homestoragequota.php @@ -32,7 +32,7 @@ class HomeStorageQuota extends \Test\TestCase { */ function testHomeStorageWrapperWithoutQuota() { $user1 = $this->getUniqueID(); - \OC_User::createUser($user1, 'test'); + \OC::$server->getUserManager()->createUser($user1, 'test'); \OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', 'none'); \OC_User::setUserId($user1); @@ -54,7 +54,7 @@ class HomeStorageQuota extends \Test\TestCase { */ function testHomeStorageWrapperWithQuota() { $user1 = $this->getUniqueID(); - \OC_User::createUser($user1, 'test'); + \OC::$server->getUserManager()->createUser($user1, 'test'); \OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', '1024'); \OC_User::setUserId($user1); diff --git a/tests/lib/helperstorage.php b/tests/lib/helperstorage.php index cf022109c27..1b2d1ec4fea 100644 --- a/tests/lib/helperstorage.php +++ b/tests/lib/helperstorage.php @@ -23,7 +23,7 @@ class Test_Helper_Storage extends \Test\TestCase { parent::setUp(); $this->user = $this->getUniqueID('user_'); - \OC_User::createUser($this->user, $this->user); + \OC::$server->getUserManager()->createUser($this->user, $this->user); $this->storage = \OC\Files\Filesystem::getStorage('/'); \OC\Files\Filesystem::tearDown(); diff --git a/tests/lib/security/certificatemanager.php b/tests/lib/security/certificatemanager.php index 43b2f1cf980..a4e6d8d68ac 100644 --- a/tests/lib/security/certificatemanager.php +++ b/tests/lib/security/certificatemanager.php @@ -24,7 +24,7 @@ class CertificateManagerTest extends \Test\TestCase { parent::setUp(); $this->username = $this->getUniqueID('', 20); - OC_User::createUser($this->username, $this->getUniqueID('', 20)); + \OC::$server->getUserManager()->createUser($this->username, $this->getUniqueID('', 20)); \OC_Util::tearDownFS(); \OC_User::setUserId(''); diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index fa19577cb72..273073239c9 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -54,13 +54,13 @@ class Test_Share extends \Test\TestCase { $this->user5 = $this->getUniqueID('user5_'); $this->user6 = $this->getUniqueID('user6_'); $this->groupAndUser = $this->getUniqueID('groupAndUser_'); - OC_User::createUser($this->user1, 'pass'); - OC_User::createUser($this->user2, 'pass'); - OC_User::createUser($this->user3, 'pass'); - OC_User::createUser($this->user4, 'pass'); - OC_User::createUser($this->user5, 'pass'); - OC_User::createUser($this->user6, 'pass'); // no group - OC_User::createUser($this->groupAndUser, 'pass'); + \OC::$server->getUserManager()->createUser($this->user1, 'pass'); + \OC::$server->getUserManager()->createUser($this->user2, 'pass'); + \OC::$server->getUserManager()->createUser($this->user3, 'pass'); + \OC::$server->getUserManager()->createUser($this->user4, 'pass'); + \OC::$server->getUserManager()->createUser($this->user5, 'pass'); + \OC::$server->getUserManager()->createUser($this->user6, 'pass'); // no group + \OC::$server->getUserManager()->createUser($this->groupAndUser, 'pass'); OC_User::setUserId($this->user1); OC_Group::clearBackends(); OC_Group::useBackend(new OC_Group_Dummy); diff --git a/tests/lib/tags.php b/tests/lib/tags.php index a8f59ff16e4..537c898da13 100644 --- a/tests/lib/tags.php +++ b/tests/lib/tags.php @@ -44,7 +44,7 @@ class Test_Tags extends \Test\TestCase { OC_User::clearBackends(); OC_User::useBackend('dummy'); $userId = $this->getUniqueID('user_'); - OC_User::createUser($userId, 'pass'); + \OC::$server->getUserManager()->createUser($userId, 'pass'); OC_User::setUserId($userId); $this->user = new OC\User\User($userId, null); $this->userSession = $this->getMock('\OCP\IUserSession'); @@ -290,7 +290,7 @@ class Test_Tags extends \Test\TestCase { $tagger->tagAs(1, $testTag); $otherUserId = $this->getUniqueID('user2_'); - OC_User::createUser($otherUserId, 'pass'); + \OC::$server->getUserManager()->createUser($otherUserId, 'pass'); OC_User::setUserId($otherUserId); $otherUserSession = $this->getMock('\OCP\IUserSession'); $otherUserSession diff --git a/tests/lib/user.php b/tests/lib/user.php index 5e9a38a43c0..26596e2fb54 100644 --- a/tests/lib/user.php +++ b/tests/lib/user.php @@ -56,25 +56,10 @@ class User extends TestCase { $fail = \OC_User::deleteUser('victim'); $this->assertFalse($fail); - $success = \OC_User::createUser('victim', 'password'); + $success = \OC::$server->getUserManager()->createUser('victim', 'password'); $success = \OC_User::deleteUser('victim'); $this->assertTrue($success); } - - public function testCreateUser(){ - $this->backend->expects($this->any()) - ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { - if ($actions === \OC_USER_BACKEND_CREATE_USER) { - return true; - } else { - return false; - } - })); - - $user = \OC_User::createUser('newuser', 'newpassword'); - $this->assertEquals('newuser', $user->getUid()); - } } -- 2.39.5