public function setUp() { if (!getenv('RUN_OBJECTSTORE_TESTS')) { $this->markTestSkipped('objectstore tests are unreliable on travis'); } \OC_App::disable('files_sharing'); \OC_App::disable('files_versions'); // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); // create users $users = array('test'); foreach ($users as $userName) { \OC_User::deleteUser($userName); \OC_User::createUser($userName, $userName); } // main test user $userName = '******'; \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_User::setUserId('test'); $testContainer = 'oc-test-container-' . substr(md5(rand()), 0, 7); $params = array('username' => 'facebook100000330192569', 'password' => 'Dbdj1sXnRSHxIGc4', 'container' => $testContainer, 'autocreate' => true, 'region' => 'RegionOne', 'url' => 'http://8.21.28.222:5000/v2.0', 'tenantName' => 'facebook100000330192569', 'serviceName' => 'swift', 'user' => \OC_User::getManager()->get($userName)); $this->objectStorage = new ObjectStoreToTest($params); $params['objectstore'] = $this->objectStorage; $this->instance = new ObjectStoreStorage($params); }
/** * @dataProvider getData */ public function testGet($user, $start, $count, $expected) { $_GET['start'] = $start; $_GET['count'] = $count; \OC_User::setUserId($user); $sessionUser = \OC::$server->getUserSession()->getUser(); $this->assertInstanceOf('OCP\\IUser', $sessionUser); $this->assertEquals($user, $sessionUser->getUID()); $activityManager = new ActivityManager($this->getMock('OCP\\IRequest'), $this->getMock('OCP\\IUserSession'), $this->getMock('OCP\\IConfig')); $activityManager->registerExtension(function () { return new Extension(\OCP\Util::getL10N('activity', 'en'), $this->getMock('\\OCP\\IURLGenerator')); }); $this->overwriteService('ActivityManager', $activityManager); $result = \OCA\Activity\Api::get(array('_route' => 'get_cloud_activity')); $this->restoreService('ActivityManager'); $this->assertEquals(100, $result->getStatusCode()); $data = $result->getData(); $this->assertEquals(sizeof($expected), sizeof($data)); while (!empty($expected)) { $assertExpected = array_shift($expected); $assertData = array_shift($data); foreach ($assertExpected as $key => $value) { $this->assertArrayHasKey($key, $assertData); if ($value !== null) { $this->assertEquals($value, $assertData[$key]); } } } }
protected function setUp() { parent::setUp(); if (!getenv('RUN_OBJECTSTORE_TESTS')) { $this->markTestSkipped('objectstore tests are unreliable in some environments'); } // reset backend \OC_User::clearBackends(); \OC_User::useBackend('database'); // create users $users = array('test'); foreach ($users as $userName) { \OC_User::deleteUser($userName); \OC_User::createUser($userName, $userName); } // main test user \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_User::setUserId('test'); $config = \OC::$server->getConfig()->getSystemValue('objectstore'); $this->objectStorage = new ObjectStoreToTest($config['arguments']); $config['objectstore'] = $this->objectStorage; $this->instance = new ObjectStoreStorage($config); }
function testBasic() { $uid = uniqid(); $this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array()); OC_User::setUserId($uid); $calId1 = OC_Calendar_Calendar::addCalendar($uid, 'test'); $all = OC_Calendar_Calendar::allCalendars($uid); $this->assertEquals(count($all), 1); $this->assertEquals($all[0]['id'], $calId1); $this->assertEquals($all[0]['displayname'], 'test'); $this->assertEquals($all[0]['uri'], 'test'); $this->assertEquals($uid, $all[0]['userid']); $calId2 = OC_Calendar_Calendar::addCalendar($uid, 'test'); $this->assertNotEquals($calId1, $calId2); $all = OC_Calendar_Calendar::allCalendars($uid); $this->assertEquals(count($all), 2); $this->assertEquals($all[1]['id'], $calId2); $this->assertEquals($all[1]['displayname'], 'test'); $this->assertEquals($all[1]['uri'], 'test1'); //$cal1=OC_Calendar_Calendar::find($calId1); //$this->assertEquals($cal1,$all[0]); OC_Calendar_Calendar::deleteCalendar($calId1); OC_Calendar_Calendar::deleteCalendar($calId2); $this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array()); }
public function setUp() { // remember files_encryption state $this->stateFilesEncryption = \OC_App::isEnabled('files_encryption'); // we want to tests with the encryption app disabled \OC_App::disable('files_encryption'); $this->storage = new \OC\Files\Storage\Temporary(array()); $textData = "dummy file data\n"; $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); $this->storage->mkdir('folder'); $this->storage->file_put_contents('foo.txt', $textData); $this->storage->file_put_contents('foo.png', $imgData); $this->storage->file_put_contents('folder/bar.txt', $textData); $this->storage->file_put_contents('folder/bar2.txt', $textData); $this->scanner = $this->storage->getScanner(); $this->scanner->scan(''); $this->cache = $this->storage->getCache(); \OC\Files\Filesystem::tearDown(); if (!self::$user) { self::$user = uniqid(); } \OC_User::createUser(self::$user, 'password'); \OC_User::setUserId(self::$user); \OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files'); Filesystem::clearMounts(); Filesystem::mount($this->storage, array(), '/' . self::$user . '/files'); \OC_Hook::clear('OC_Filesystem'); }
protected function tearDown() { \OC_User::setUserId(''); $user = \OC::$server->getUserManager()->get($this->user); if ($user !== null) { $user->delete(); } }
protected function tearDown() { \OC_User::setIncognitoMode(false); // Set old user \OC_User::setUserId($this->oldUser); \OC_Util::setupFS($this->oldUser); parent::tearDown(); }
protected function tearDown() { \OC_User::setUserId($this->user); \OC_Config::setValue('cachedirectory', $this->datadir); // Restore the original mount point \OC\Files\Filesystem::clearMounts(); \OC\Files\Filesystem::mount($this->storage, array(), '/'); parent::tearDown(); }
public function setUp() { OC_User::clearBackends(); OC_User::useBackend('dummy'); $this->user = uniqid('user_'); $this->objectType = uniqid('type_'); OC_User::createUser($this->user, 'pass'); OC_User::setUserId($this->user); }
protected function tearDown() { $this->instance->remove('hack', 'hack'); \OC_User::setUserId($this->user); \OC::$server->getConfig()->setSystemValue('cachedirectory', $this->datadir); // Restore the original mount point \OC\Files\Filesystem::clearMounts(); \OC\Files\Filesystem::mount($this->storage, array(), '/'); parent::tearDown(); }
protected function tearDown() { foreach ($this->tmpDirs as $dir) { \OC_Helper::rmdirr($dir); } \OC\Files\Filesystem::clearMounts(); \OC\Files\Filesystem::mount($this->originalStorage, array(), '/'); \OC_User::setUserId(''); parent::tearDown(); }
public function testGetApps() { $user = $this->generateUsers(); \OC_Group::addToGroup($user, 'admin'); \OC_User::setUserId($user); $result = \OCA\provisioning_API\Apps::getApps(array()); $this->assertTrue($result->succeeded()); $data = $result->getData(); $this->assertEquals(count(\OC_App::listAllApps()), count($data['apps'])); }
protected function setUp() { parent::setUp(); $this->username = $this->getUniqueID('', 20); OC_User::createUser($this->username, $this->getUniqueID('', 20)); \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_Util::setupFS($this->username); $this->certificateManager = new CertificateManager($this->username, new \OC\Files\View()); }
public function testUserOtherExport() { $user = $this->generateUser(); $user2 = $this->generateUser(); \OC_User::setUserId($user2); $export = \OC_Migrate::export($user); // Check it succeeded and exists $this->assertTrue(json_decode($export)->success); // Validate the export $this->validateUserExport($user2, $user, json_decode($export)->data); }
public function setUp() { OCA_mozilla_sync\Utils::setTestState(); // Create ownCloud Test User OC_User::createUser($this->userName, $this->password); OC_User::setUserId($this->userName); \OC::$server->getConfig()->setUserValue($this->userName, 'settings', 'email', $this->email); OCA_mozilla_sync\OutputData::$outputFlag = OCA_mozilla_sync\OutputData::ConstOutputBuffer; OCA_mozilla_sync\Utils::setTestState(); $this->urlParser = new OCA_mozilla_sync\UrlParser('/1.0/' . $this->userHash); }
public function setUp() { OCA_mozilla_sync\Utils::setTestState(); // Create ownCloud Test User OC_User::createUser($this->userName, $this->password); OC_User::setUserId($this->userName); OC_Preferences::setValue($this->userName, 'settings', 'email', $this->email); OCA_mozilla_sync\OutputData::$outputFlag = OCA_mozilla_sync\OutputData::ConstOutputBuffer; OCA_mozilla_sync\Utils::setTestState(); OCA_mozilla_sync\User::createUser($this->userHash, $this->password, $this->email); }
function setUp() { $this->username = OC_Util::generateRandomBytes(20); OC_User::createUser($this->username, OC_Util::generateRandomBytes(20)); \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_Util::setupFS($this->username); $this->user = \OC::$server->getUserManager()->get($this->username); $this->certificateManager = new CertificateManager($this->user); }
function setUp() { // set user id \OC_User::setUserId(\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1); $this->userId = \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1; $this->pass = \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1; // init filesystem view $this->view = new \OC_FilesystemView('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files'); // init short data $this->data = 'hats'; }
public function tearDown() { $this->user = null; if ($this->storageMock) { $this->storageMock->getCache()->clear(); $this->storageMock = null; } \OC\Files\Filesystem::tearDown(); \OC_User::setUserId(''); \OC_User::deleteUser($this->user); \OC_Preferences::deleteUser($this->user); }
public function tearDown() { \OC_User::setUserId($this->user); foreach ($this->storages as $storage) { $cache = $storage->getCache(); $ids = $cache->getAll(); $cache->clear(); } if ($this->tempStorage && !\OC_Util::runningOnWindows()) { system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir())); } }
protected function tearDown() { \OC_Util::tearDownFS(); \OC_User::setUserId(''); Filesystem::tearDown(); \OC_User::deleteUser($this->user); \OC_User::setIncognitoMode(false); \OC::$server->getSession()->set('public_link_authenticated', ''); // Set old user \OC_User::setUserId($this->oldUser); \OC_Util::setupFS($this->oldUser); }
function setUp() { // set user id \OC_User::setUserId(\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1); $this->userId = \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1; $this->pass = \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1; // init filesystem view $this->view = new \OC\Files\View('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files'); $this->rootView = new \OC\Files\View('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1); // init short data $this->data = 'hats'; $this->filename = 'enc_proxy_tests-' . uniqid() . '.txt'; }
protected function setUp() { parent::setUp(); $this->username = $this->getUniqueID('', 20); OC_User::createUser($this->username, $this->getUniqueID('', 20)); \OC_Util::tearDownFS(); \OC_User::setUserId(''); \OC\Files\Filesystem::tearDown(); \OC_Util::setupFS($this->username); $config = $this->getMock('OCP\\IConfig'); $config->expects($this->any())->method('getSystemValue')->with('installed', false)->willReturn(true); $this->certificateManager = new CertificateManager($this->username, new \OC\Files\View(), $config); }
protected function tearDown() { $this->user = null; if ($this->storageMock) { $this->storageMock->getCache()->clear(); $this->storageMock = null; } \OC\Files\Filesystem::tearDown(); \OC\Files\Filesystem::mount($this->storage, array(), '/'); \OC_User::setUserId(''); \OC_User::deleteUser($this->user); \OC::$server->getConfig()->deleteAllUserValues($this->user); parent::tearDown(); }
protected function setUp() { parent::setUp(); $this->originalStorage = \OC\Files\Filesystem::getStorage('/'); // create a new user with his own filesystem view // this gets called by each test in this test class $this->user = $this->getUniqueID(); \OC_User::setUserId($this->user); \OC\Files\Filesystem::init($this->user, '/' . $this->user . '/files'); \OC\Files\Filesystem::mount('OC\\Files\\Storage\\Temporary', array(), '/'); $this->rootView = new \OC\Files\View(''); $this->rootView->mkdir('/' . $this->user); $this->rootView->mkdir('/' . $this->user . '/files'); }
protected function loginWithEncryption($user = '') { \OC_Util::tearDownFS(); \OC_User::setUserId(''); // needed for fully logout \OC::$server->getUserSession()->setUser(null); Filesystem::tearDown(); \OC_User::setUserId($user); $this->postLogin(); \OC_Util::setupFS($user); if (\OC_User::userExists($user)) { \OC::$server->getUserFolder($user); } }
protected function tearDown() { \OC_User::setUserId($this->user); foreach ($this->storages as $storage) { $cache = $storage->getCache(); $ids = $cache->getAll(); $cache->clear(); } if ($this->tempStorage && !\OC_Util::runningOnWindows()) { system('rm -rf ' . escapeshellarg($this->tempStorage->getDataDir())); } \OC\Files\Filesystem::clearMounts(); \OC\Files\Filesystem::mount($this->originalStorage, array(), '/'); parent::tearDown(); }
protected function setUp() { parent::setUp(); // set user id \OC_User::setUserId(\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1); $this->userId = \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1; $this->pass = \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1; // init filesystem view $this->view = new \OC\Files\View('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files'); $this->rootView = new \OC\Files\View('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1); // init short data $this->data = 'hats'; $this->dataLong = file_get_contents(__DIR__ . '/../lib/crypt.php'); $this->filename = 'enc_proxy_tests-' . $this->getUniqueID() . '.txt'; }
public function tearDown() { \OC_User::setUserId($this->user); $cache = $this->storage->getCache(); $ids = $cache->getAll(); $permissionsCache = $this->storage->getPermissionsCache(); $permissionsCache->removeMultiple($ids, \OC_User::getUser()); $cache->clear(); if (!is_null($this->config['av_mode'])) { \OCP\Config::setAppValue('files_antivirus', 'av_mode', $this->config['av_mode']); } if (!is_null($this->config['av_path'])) { \OCP\Config::setAppValue('files_antivirus', 'av_path', $this->config['av_path']); } }
function setUp() { // set user id \OC_User::setUserId(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1); $this->userId = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1; $this->pass = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1; // init filesystem view $this->view = new \OC_FilesystemView('/'); // init short data $this->dataShort = 'hats'; // remember files_trashbin state $this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); // we don't want to tests with app files_trashbin enabled \OC_App::disable('files_trashbin'); }