Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Central user account table arriving ..... #27165

Closed
wants to merge 10 commits into from
12 changes: 6 additions & 6 deletions apps/federatedfilesharing/tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use OC\Files\Filesystem;
use OCA\Files\Share;
use Test\Traits\UserTrait;

/**
* Class Test_Files_Sharing_Base
Expand All @@ -34,6 +35,8 @@
*/
abstract class TestCase extends \Test\TestCase {

use UserTrait;

const TEST_FILES_SHARING_API_USER1 = "test-share-user1";
const TEST_FILES_SHARING_API_USER2 = "test-share-user2";

Expand All @@ -43,17 +46,14 @@ public static function setUpBeforeClass() {
// reset backend
\OC_User::clearBackends();
\OC::$server->getGroupManager()->clearBackends();

// create users
$backend = new \Test\Util\User\Dummy();
\OC_User::useBackend($backend);
$backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
$backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);
}

protected function setUp() {
parent::setUp();

$this->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
$this->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);

//login as user1
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
}
Expand Down
14 changes: 6 additions & 8 deletions apps/files/tests/Service/TagServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
namespace OCA\Files\Tests\Service;

use OCA\Files\Service\TagService;
use OCP\IUserSession;
use Test\Traits\UserTrait;

/**
* Class TagServiceTest
Expand All @@ -34,6 +36,8 @@
*/
class TagServiceTest extends \Test\TestCase {

use UserTrait;

/**
* @var string
*/
Expand All @@ -57,14 +61,10 @@ class TagServiceTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
$this->user = $this->getUniqueID('user');
\OC::$server->getUserManager()->createUser($this->user, 'test');
$user = $this->createUser($this->user, 'test');
\OC_User::setUserId($this->user);
\OC_Util::setupFS($this->user);
/** @var \OCP\IUser */
$user = new \OC\User\User($this->user, null);
/**
* @var \OCP\IUserSession
*/
/** @var IUserSession | \PHPUnit_Framework_MockObject_MockObject $userSession */
$userSession = $this->createMock('\OCP\IUserSession');
$userSession->expects($this->any())
->method('getUser')
Expand All @@ -83,8 +83,6 @@ protected function setUp() {

protected function tearDown() {
\OC_User::setUserId('');
$user = \OC::$server->getUserManager()->get($this->user);
if ($user !== null) { $user->delete(); }
}

public function testUpdateFileTags() {
Expand Down
32 changes: 20 additions & 12 deletions apps/files_sharing/tests/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@

namespace OCA\Files_Sharing\Tests;

use OC\Files\View;
use OCP\Constants;
use Test\Traits\UserTrait;

/**
* Class CacheTest
*
* @group DB
*/
class CacheTest extends TestCase {
use UserTrait;

/**
* @var \OC\Files\View
*/
/** @var View */
public $user2View;

/** @var \OC\Files\Cache\Cache */
Expand All @@ -60,12 +63,17 @@ protected function setUp() {

$this->shareManager = \OC::$server->getShareManager();

$this->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
$this->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);

\OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER1, 'User One');
\OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER2, 'User Two');

self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);

$this->user2View = new \OC\Files\View('/'. self::TEST_FILES_SHARING_API_USER2 . '/files');
$this->user2View = new View('/'. self::TEST_FILES_SHARING_API_USER2 . '/files');

self::loginHelper(self::TEST_FILES_SHARING_API_USER1);

// prepare user1's dir structure
$this->view->mkdir('container');
Expand Down Expand Up @@ -94,7 +102,7 @@ protected function setUp() {
->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
->setPermissions(Constants::PERMISSION_ALL);
$this->shareManager->createShare($share);

$node = $rootFolder->get('container/shared single file.txt');
Expand All @@ -103,14 +111,14 @@ protected function setUp() {
->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE));
->setPermissions(Constants::PERMISSION_ALL & ~(Constants::PERMISSION_CREATE | Constants::PERMISSION_DELETE));
$this->shareManager->createShare($share);

// login as user2
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);

// retrieve the shared storage
$secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
$secondView = new View('/' . self::TEST_FILES_SHARING_API_USER2);
list($this->sharedStorage,) = $secondView->resolvePath('files/shareddir');
$this->sharedCache = $this->sharedStorage->getCache();
}
Expand Down Expand Up @@ -393,12 +401,12 @@ function testGetFolderContentsWhenSubSubdirShared() {
->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
->setPermissions(Constants::PERMISSION_ALL);
$share = $this->shareManager->createShare($share);

self::loginHelper(self::TEST_FILES_SHARING_API_USER3);

$thirdView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
$thirdView = new View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
$results = $thirdView->getDirectoryContent('/subdir');

$this->verifyFiles(
Expand Down Expand Up @@ -477,7 +485,7 @@ public function testGetPathByIdDirectShare() {
->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
->setPermissions(Constants::PERMISSION_READ | Constants::PERMISSION_UPDATE | Constants::PERMISSION_SHARE);
$this->shareManager->createShare($share);

\OC_Util::tearDownFS();
Expand Down Expand Up @@ -508,7 +516,7 @@ public function testGetPathByIdShareSubFolder() {
->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
->setPermissions(Constants::PERMISSION_ALL);
$this->shareManager->createShare($share);
\OC_Util::tearDownFS();

Expand Down
6 changes: 3 additions & 3 deletions apps/files_sharing/tests/EncryptedSizePropagationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
class EncryptedSizePropagationTest extends SizePropagationTest {
use EncryptionTrait;

protected function setupUser($name, $password = '') {
$this->createUser($name, $password);
protected function setupUser($name) {
$this->createUser($name);
$tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
$this->setupForUser($name, $password);
$this->setupForUser($name, $name);
$this->loginWithEncryption($name);
return new View('/' . $name . '/files');
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/tests/External/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function setUp() {
parent::setUp();

$this->uid = $this->getUniqueID('user');
$this->createUser($this->uid, '');
$this->createUser($this->uid);
$this->user = \OC::$server->getUserManager()->get($this->uid);
$this->mountManager = new \OC\Files\Mount\Manager();
$this->httpHelper = $httpHelper = $this->getMockBuilder('\OC\HTTPHelper')->disableOriginalConstructor()->getMock();
Expand Down
18 changes: 4 additions & 14 deletions apps/files_sharing/tests/LockingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OC\Files\Filesystem;
use OC\Files\View;
use OCP\Lock\ILockingProvider;
use Test\Traits\UserTrait;

/**
* Class LockingTest
Expand All @@ -37,24 +38,18 @@
* @package OCA\Files_Sharing\Tests
*/
class LockingTest extends TestCase {
/**
* @var \Test\Util\User\Dummy
*/
private $userBackend;
use UserTrait;

private $ownerUid;
private $recipientUid;

public function setUp() {
parent::setUp();

$this->userBackend = new \Test\Util\User\Dummy();
\OC::$server->getUserManager()->registerBackend($this->userBackend);

$this->ownerUid = $this->getUniqueID('owner_');
$this->recipientUid = $this->getUniqueID('recipient_');
$this->userBackend->createUser($this->ownerUid, '');
$this->userBackend->createUser($this->recipientUid, '');
$this->createUser($this->ownerUid);
$this->createUser($this->recipientUid);

$this->loginAsUser($this->ownerUid);
Filesystem::mkdir('/foo');
Expand All @@ -73,11 +68,6 @@ public function setUp() {
$this->assertTrue(Filesystem::file_exists('bar.txt'));
}

public function tearDown() {
\OC::$server->getUserManager()->removeBackend($this->userBackend);
parent::tearDown();
}

/**
* @expectedException \OCP\Lock\LockedException
*/
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/tests/SizePropagationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class SizePropagationTest extends TestCase {
use UserTrait;
use MountProviderTrait;

protected function setupUser($name, $password = '') {
$this->createUser($name, $password);
protected function setupUser($name) {
$this->createUser($name);
$tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
$this->loginAsUser($name);
Expand Down
32 changes: 11 additions & 21 deletions apps/files_sharing/tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OCA\Files_Sharing\AppInfo\Application;
use OCA\Files_Sharing\SharedStorage;
use OCP\ICache;
use Test\Traits\UserTrait;

/**
* Class TestCase
Expand All @@ -46,6 +47,8 @@
*/
abstract class TestCase extends \Test\TestCase {

use UserTrait;

const TEST_FILES_SHARING_API_USER1 = "test-share-user1";
const TEST_FILES_SHARING_API_USER2 = "test-share-user2";
const TEST_FILES_SHARING_API_USER3 = "test-share-user3";
Expand Down Expand Up @@ -74,20 +77,21 @@ public static function setUpBeforeClass() {
$application->registerMountProviders();

// reset backend
\OC_User::clearBackends();
\OC::$server->getGroupManager()->clearBackends();

// clear share hooks
\OC_Hook::clear('OCP\\Share');
\OC::registerShareHooks();
}

protected function setUp() {
parent::setUp();

// create users
$backend = new \Test\Util\User\Dummy();
\OC_User::useBackend($backend);
$backend->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
$backend->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);
$backend->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3);
$backend->createUser(self::TEST_FILES_SHARING_API_USER4, self::TEST_FILES_SHARING_API_USER4);
$this->createUser(self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER1);
$this->createUser(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER2);
$this->createUser(self::TEST_FILES_SHARING_API_USER3, self::TEST_FILES_SHARING_API_USER3);
$this->createUser(self::TEST_FILES_SHARING_API_USER4, self::TEST_FILES_SHARING_API_USER4);

// create group
$groupBackend = new \Test\Util\Group\Dummy();
Expand All @@ -104,10 +108,6 @@ public static function setUpBeforeClass() {
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER4, 'group3');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
\OC::$server->getGroupManager()->addBackend($groupBackend);
}

protected function setUp() {
parent::setUp();

//login as user1
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
Expand All @@ -127,14 +127,6 @@ protected function tearDown() {
}

public static function tearDownAfterClass() {
// cleanup users
$user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER1);
if ($user !== null) { $user->delete(); }
$user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER2);
if ($user !== null) { $user->delete(); }
$user = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3);
if ($user !== null) { $user->delete(); }

// delete group
$group = \OC::$server->getGroupManager()->get(self::TEST_FILES_SHARING_API_GROUP1);
if ($group !== null) { $group->delete(); }
Expand All @@ -144,8 +136,6 @@ public static function tearDownAfterClass() {
Filesystem::tearDown();

// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
\OC::$server->getGroupManager()->clearBackends();
\OC::$server->getGroupManager()->addBackend(new \OC\Group\Database());

Expand Down
7 changes: 3 additions & 4 deletions apps/files_versions/tests/VersioningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@
require_once __DIR__ . '/../appinfo/app.php';

use OC\Files\Storage\Temporary;
use Test\TestCase;

/**
* Class Test_Files_versions
* this class provide basic files versions test
*
* @group DB
*/
class VersioningTest extends \Test\TestCase {
class VersioningTest extends TestCase {

const TEST_VERSIONS_USER = 'test-versions-user';
const TEST_VERSIONS_USER2 = 'test-versions-user2';
Expand Down Expand Up @@ -887,9 +888,7 @@ private function createAndCheckVersions(\OC\Files\View $view, $path) {
public static function loginHelper($user, $create = false) {

if ($create) {
$backend = new \Test\Util\User\Dummy();
$backend->createUser($user, $user);
\OC::$server->getUserManager()->registerBackend($backend);
\OC::$server->getUserManager()->createUser($user, $user);
}

$storage = new \ReflectionClass('\OCA\Files_Sharing\SharedStorage');
Expand Down
1 change: 0 additions & 1 deletion apps/provisioning_api/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
// Users
$users = new Users(
\OC::$server->getUserManager(),
\OC::$server->getConfig(),
\OC::$server->getGroupManager(),
\OC::$server->getUserSession(),
\OC::$server->getLogger(),
Expand Down
Loading