コード例 #1
0
ファイル: swift.php プロジェクト: Combustible/core
 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);
 }
コード例 #2
0
ファイル: apitest.php プロジェクト: ynott/activity
 /**
  * @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]);
             }
         }
     }
 }
コード例 #3
0
ファイル: swift.php プロジェクト: nem0xff/core
 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);
 }
コード例 #4
0
 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());
 }
コード例 #5
0
ファイル: updater.php プロジェクト: olucao/owncloud-core
 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');
 }
コード例 #6
0
 protected function tearDown()
 {
     \OC_User::setUserId('');
     $user = \OC::$server->getUserManager()->get($this->user);
     if ($user !== null) {
         $user->delete();
     }
 }
コード例 #7
0
 protected function tearDown()
 {
     \OC_User::setIncognitoMode(false);
     // Set old user
     \OC_User::setUserId($this->oldUser);
     \OC_Util::setupFS($this->oldUser);
     parent::tearDown();
 }
コード例 #8
0
ファイル: usercache.php プロジェクト: adolfo2103/hcloudfilem
 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();
 }
コード例 #9
0
ファイル: vcategories.php プロジェクト: ryanshoover/core
 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);
 }
コード例 #10
0
ファイル: file.php プロジェクト: Commenter123/core
 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();
 }
コード例 #11
0
 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();
 }
コード例 #12
0
 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']));
 }
コード例 #13
0
 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());
 }
コード例 #14
0
ファイル: migrate.php プロジェクト: olucao/owncloud-core
 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);
 }
コード例 #15
0
ファイル: userservice.php プロジェクト: mach-o/mozilla_sync
 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);
 }
コード例 #16
0
ファイル: storageservice.php プロジェクト: netcon-source/apps
 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);
 }
コード例 #17
0
 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);
 }
コード例 #18
0
ファイル: proxy.php プロジェクト: omusico/isle-web-framework
 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';
 }
コード例 #19
0
 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);
 }
コード例 #20
0
ファイル: view.php プロジェクト: Combustible/core
 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()));
     }
 }
コード例 #21
0
 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);
 }
コード例 #22
0
ファイル: proxy.php プロジェクト: CDN-Sparks/owncloud
 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';
 }
コード例 #23
0
ファイル: certificatemanager.php プロジェクト: evanjt/core
 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);
 }
コード例 #24
0
ファイル: helperstorage.php プロジェクト: Commenter123/core
 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();
 }
コード例 #25
0
 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');
 }
コード例 #26
0
 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);
     }
 }
コード例 #27
0
ファイル: view.php プロジェクト: riso/owncloud-core
 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();
 }
コード例 #28
0
ファイル: proxy.php プロジェクト: droiter/openwrt-on-android
 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';
 }
コード例 #29
0
ファイル: scannerTest.php プロジェクト: anolisti/apps
 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']);
     }
 }
コード例 #30
0
ファイル: stream.php プロジェクト: omusico/isle-web-framework
 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');
 }