Ejemplo n.º 1
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $application = new Application();
     $application->registerMountProviders();
     // reset backend
     \OC_User::clearBackends();
     \OC_Group::clearBackends();
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     // 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);
     // create group
     $groupBackend = new \OC_Group_Dummy();
     $groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1);
     $groupBackend->createGroup('group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
     \OC_Group::useBackend($groupBackend);
 }
Ejemplo n.º 2
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // reset backend
     \OC_User::clearBackends();
     \OC_Group::clearBackends();
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // create users
     $backend = new \OC_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);
     // create group
     $groupBackend = new \OC_Group_Dummy();
     $groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1);
     $groupBackend->createGroup('group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
     \OC_Group::useBackend($groupBackend);
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     OC_User::clearBackends();
     OC_User::useBackend('dummy');
     $this->user1 = uniqid('user1_');
     $this->user2 = uniqid('user2_');
     $this->user3 = uniqid('user3_');
     $this->user4 = uniqid('user4_');
     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::setUserId($this->user1);
     OC_Group::clearBackends();
     OC_Group::useBackend(new OC_Group_Dummy());
     $this->group1 = uniqid('group_');
     $this->group2 = uniqid('group_');
     OC_Group::createGroup($this->group1);
     OC_Group::createGroup($this->group2);
     OC_Group::addToGroup($this->user1, $this->group1);
     OC_Group::addToGroup($this->user2, $this->group1);
     OC_Group::addToGroup($this->user3, $this->group1);
     OC_Group::addToGroup($this->user2, $this->group2);
     OC_Group::addToGroup($this->user4, $this->group2);
     OCP\Share::registerBackend('test', 'Test_Share_Backend');
     OC_Hook::clear('OCP\\Share');
     OC::registerShareHooks();
     $this->resharing = OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes');
     OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
     // 20 Minutes in the past, 20 minutes in the future.
     $now = time();
     $dateFormat = 'Y-m-d H:i:s';
     $this->dateInPast = date($dateFormat, $now - 20 * 60);
     $this->dateInFuture = date($dateFormat, $now + 20 * 60);
 }
Ejemplo n.º 4
0
 /**
  * delete a SubAdmin
  * @param string $uid uid of the SubAdmin
  * @param string $gid gid of the group
  * @return boolean
  */
 public static function deleteSubAdmin($uid, $gid)
 {
     $stmt = OC_DB::prepare('DELETE FROM `*PREFIX*group_admin` WHERE `gid` = ? AND `uid` = ?');
     $result = $stmt->execute(array($gid, $uid));
     OC_Hook::emit("OC_SubAdmin", "post_deleteSubAdmin", array("gid" => $gid));
     return true;
 }
Ejemplo n.º 5
0
	protected function setUp() {
		parent::setUp();

		$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();

		if (!self::$user) {
			self::$user = $this->getUniqueID();
		}

		\OC_User::createUser(self::$user, 'password');
		$this->loginAsUser(self::$user);

		Filesystem::init(self::$user, '/' . self::$user . '/files');

		Filesystem::clearMounts();
		Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');

		\OC_Hook::clear('OC_Filesystem');
	}
Ejemplo n.º 6
0
 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');
 }
Ejemplo n.º 7
0
 protected function tearDown()
 {
     \OC_Hook::clear('OC_Filesystem', 'post_write');
     \OC_Hook::clear('OC_Filesystem', 'post_delete');
     \OC_Hook::clear('OC_Filesystem', 'post_rename');
     parent::tearDown();
 }
Ejemplo n.º 8
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // remember files_encryption state
     self::$stateFilesEncryption = \OC_App::isEnabled('files_encryption');
     //we don't want to tests with app files_encryption enabled
     \OC_App::disable('files_encryption');
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // create users
     $backend = new \OC_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);
     // create group
     $groupBackend = new \OC_Group_Dummy();
     $groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1);
     $groupBackend->createGroup('group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER1, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER3, 'group');
     $groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
     \OC_Group::useBackend($groupBackend);
 }
Ejemplo n.º 9
0
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // enable resharing
     \OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // Sharing related hooks
     \OCA\Encryption\Helper::registerShareHooks();
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create users
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true);
     // create group and assign users
     \OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
 }
Ejemplo n.º 10
0
 public static function setUpBeforeClass()
 {
     // note: not using a data provider because these
     // files all need to coexist to make sure the
     // share keys are found properly (pattern matching)
     self::$testFiles = array('t est.txt', 't est_.txt', 't est.doc.txt', 't est(.*).txt', 'multiple.dots.can.happen.too.txt', 't est.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.txt', 't est_.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey.txt', 'who would upload their.shareKey', 'user ones file.txt', 'user ones file.txt.backup', '.t est.txt');
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     \OC_Hook::clear('OC_Filesystem');
     \OC_Hook::clear('OC_User');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // Sharing related hooks
     \OCA\Encryption\Helper::registerShareHooks();
     // clear and register proxies
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create test user
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true);
 }
Ejemplo n.º 11
0
 public function setUp()
 {
     OC_User::clearBackends();
     OC_User::useBackend('dummy');
     $this->user1 = uniqid('user1_');
     $this->user2 = uniqid('user2_');
     $this->user3 = uniqid('user3_');
     $this->user4 = uniqid('user4_');
     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::setUserId($this->user1);
     OC_Group::clearBackends();
     OC_Group::useBackend(new OC_Group_Dummy());
     $this->group1 = uniqid('group_');
     $this->group2 = uniqid('group_');
     OC_Group::createGroup($this->group1);
     OC_Group::createGroup($this->group2);
     OC_Group::addToGroup($this->user1, $this->group1);
     OC_Group::addToGroup($this->user2, $this->group1);
     OC_Group::addToGroup($this->user3, $this->group1);
     OC_Group::addToGroup($this->user2, $this->group2);
     OC_Group::addToGroup($this->user4, $this->group2);
     OCP\Share::registerBackend('test', 'Test_Share_Backend');
     OC_Hook::clear('OCP\\Share');
     OC::registerShareHooks();
 }
Ejemplo n.º 12
0
 public function setUp()
 {
     //clear all proxies and hooks so we can do clean testing
     \OC_FileProxy::clearProxies();
     \OC_Hook::clear('OC_Filesystem');
     //disabled atm
     //enable only the encryption hook if needed
     //if(OC_App::isEnabled('files_encryption')) {
     //	OC_FileProxy::register(new OC_FileProxy_Encryption());
     //}
     //set up temporary storage
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $datadir = str_replace('local::', '', $storage->getId());
     $this->datadir = \OC_Config::getValue('cachedirectory', \OC::$SERVERROOT . '/data/cache');
     \OC_Config::setValue('cachedirectory', $datadir);
     \OC_User::clearBackends();
     \OC_User::useBackend(new \OC_User_Dummy());
     //login
     \OC_User::createUser('test', 'test');
     $this->user = \OC_User::getUser();
     \OC_User::setUserId('test');
     //set up the users dir
     $rootView = new \OC\Files\View('');
     $rootView->mkdir('/test');
     $this->instance = new \OC\Cache\File();
 }
Ejemplo n.º 13
0
 protected function setUp()
 {
     parent::setUp();
     //clear all proxies and hooks so we can do clean testing
     \OC_Hook::clear('OC_Filesystem');
     //set up temporary storage
     $this->storage = \OC\Files\Filesystem::getStorage('/');
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $datadir = str_replace('local::', '', $storage->getId());
     $config = \OC::$server->getConfig();
     $this->datadir = $config->getSystemValue('cachedirectory', \OC::$SERVERROOT . '/data/cache');
     $config->setSystemValue('cachedirectory', $datadir);
     \OC_User::clearBackends();
     \OC_User::useBackend(new \Test\Util\User\Dummy());
     //login
     \OC_User::createUser('test', 'test');
     $this->user = \OC_User::getUser();
     \OC_User::setUserId('test');
     //set up the users dir
     $this->rootView = new \OC\Files\View('');
     $this->rootView->mkdir('/test');
     $this->instance = new \OC\Cache\File();
     // forces creation of cache folder for subsequent tests
     $this->instance->set('hack', 'hack');
 }
Ejemplo n.º 14
0
 protected function tearDown()
 {
     \OC_Hook::clear('OC_Filesystem', 'post_write');
     \OC_Hook::clear('OC_Filesystem', 'post_delete');
     \OC_Hook::clear('OC_Filesystem', 'post_rename');
     \OC_Hook::clear('OCP\\Share', 'post_update_permissions');
     parent::tearDown();
 }
Ejemplo n.º 15
0
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1);
     \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2);
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
 }
Ejemplo n.º 16
0
 protected function tearDown()
 {
     \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
     $this->logout();
     \OC_User::deleteUser($this->user);
     \OC_Hook::clear();
     parent::tearDown();
 }
Ejemplo n.º 17
0
 /**
  * delete a SubAdmin
  * @param IUser $user the user that is the SubAdmin
  * @param IGroup $group the group
  * @return bool
  */
 public function deleteSubAdmin(IUser $user, IGroup $group)
 {
     $qb = $this->dbConn->getQueryBuilder();
     $qb->delete('group_admin')->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))->execute();
     $this->emit('\\OC\\SubAdmin', 'postDeleteSubAdmin', [$user, $group]);
     \OC_Hook::emit("OC_SubAdmin", "post_deleteSubAdmin", ["gid" => $group->getGID()]);
     return true;
 }
Ejemplo n.º 18
0
 protected function tearDown()
 {
     $this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files/');
     $this->rootView->deleteAll(self::TEST_VERSIONS_USER2 . '/files/');
     $this->rootView->deleteAll(self::TEST_VERSIONS_USER . '/files_versions/');
     $this->rootView->deleteAll(self::TEST_VERSIONS_USER2 . '/files_versions/');
     \OC_Hook::clear();
     parent::tearDown();
 }
Ejemplo n.º 19
0
 public static function tearDownAfterClass()
 {
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->rmdir('public-keys');
     $view->rmdir('owncloud_private_key');
 }
Ejemplo n.º 20
0
 public static function tearDownAfterClass()
 {
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->deleteAll('files_encryption');
     parent::tearDownAfterClass();
 }
Ejemplo n.º 21
0
 public function setUp()
 {
     parent::setUp();
     \OC_Hook::clear();
     $this->user = $this->getUniqueID('user_');
     $userManager = \OC::$server->getUserManager();
     $userManager->createUser($this->user, 'pass');
     $this->loginAsUser($this->user);
 }
Ejemplo n.º 22
0
 /**
  * @brief Can be set up
  * @param string $user
  * @return boolean
  * @description configure the initial filesystem based on the configuration
  */
 public static function setupFS($user = '')
 {
     //setting up the filesystem twice can only lead to trouble
     if (self::$fsSetup) {
         return false;
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     // load all filesystem apps before, so no setup-hook gets lost
     if (!isset($RUNTIME_NOAPPS) || !$RUNTIME_NOAPPS) {
         OC_App::loadApps(array('filesystem'));
     }
     // the filesystem will finish when $user is not empty,
     // mark fs setup here to avoid doing the setup from loading
     // OC_Filesystem
     if ($user != '') {
         self::$fsSetup = true;
     }
     $configDataDirectory = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     //first set up the local "root" storage
     \OC\Files\Filesystem::initMounts();
     if (!self::$rootMounted) {
         \OC\Files\Filesystem::mount('\\OC\\Files\\Storage\\Local', array('datadir' => $configDataDirectory), '/');
         self::$rootMounted = true;
     }
     //if we aren't logged in, there is no use to set up the filesystem
     if ($user != "") {
         \OC\Files\Filesystem::addStorageWrapper(function ($mountPoint, $storage) {
             // set up quota for home storages, even for other users
             // which can happen when using sharing
             if ($storage instanceof \OC\Files\Storage\Home) {
                 $user = $storage->getUser()->getUID();
                 $quota = OC_Util::getUserQuota($user);
                 if ($quota !== \OC\Files\SPACE_UNLIMITED) {
                     return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota));
                 }
             }
             return $storage;
         });
         $userDir = '/' . $user . '/files';
         $userRoot = OC_User::getHome($user);
         $userDirectory = $userRoot . '/files';
         if (!is_dir($userDirectory)) {
             mkdir($userDirectory, 0755, true);
             OC_Util::copySkeleton($userDirectory);
         }
         //jail the user into his "home" directory
         \OC\Files\Filesystem::init($user, $userDir);
         $fileOperationProxy = new OC_FileProxy_FileOperations();
         OC_FileProxy::register($fileOperationProxy);
         OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir));
     }
     return true;
 }
Ejemplo n.º 23
0
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(self::TEST_TRASHBIN_USER1);
     \OC_Config::setValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
     \OC_Config::setValue('trashbin_auto_expire', self::$rememberAutoExpire);
     \OC_Hook::clear();
     \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
     parent::tearDownAfterClass();
 }
Ejemplo n.º 24
0
 public static function setupFS($user = '')
 {
     // configure the initial filesystem based on the configuration
     if (self::$fsSetup) {
         //setting up the filesystem twice can only lead to trouble
         return false;
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     // the filesystem will finish when $user is not empty,
     // mark fs setup here to avoid doing the setup from loading
     // OC_Filesystem
     if ($user != '') {
         self::$fsSetup = true;
     }
     $CONFIG_DATADIRECTORY = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     //first set up the local "root" storage
     if (!self::$rootMounted) {
         OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $CONFIG_DATADIRECTORY), '/');
         self::$rootMounted = true;
     }
     if ($user != "") {
         //if we aren't logged in, there is no use to set up the filesystem
         $user_dir = '/' . $user . '/files';
         $user_root = OC_User::getHome($user);
         $userdirectory = $user_root . '/files';
         if (!is_dir($userdirectory)) {
             mkdir($userdirectory, 0755, true);
         }
         //jail the user into his "home" directory
         OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $user_root), $user);
         OC_Filesystem::init($user_dir);
         $quotaProxy = new OC_FileProxy_Quota();
         OC_FileProxy::register($quotaProxy);
         // Load personal mount config
         if (is_file($user_root . '/mount.php')) {
             $mountConfig = (include $user_root . '/mount.php');
             if (isset($mountConfig['user'][$user])) {
                 foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
                     OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
                 }
             }
             $mtime = filemtime($user_root . '/mount.php');
             $previousMTime = OC_Preferences::getValue($user, 'files', 'mountconfigmtime', 0);
             if ($mtime > $previousMTime) {
                 //mount config has changed, filecache needs to be updated
                 OC_FileCache::triggerUpdate($user);
                 OC_Preferences::setValue($user, 'files', 'mountconfigmtime', $mtime);
             }
         }
         OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
     }
 }
Ejemplo n.º 25
0
 protected function tearDown()
 {
     \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
     $this->logout();
     $user = \OC::$server->getUserManager()->get($this->user);
     if ($user !== null) {
         $user->delete();
     }
     \OC_Hook::clear();
     parent::tearDown();
 }
Ejemplo n.º 26
0
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(self::TEST_TRASHBIN_USER1);
     if (self::$encryptionStatus === true) {
         \OC_App::enable('files_encryption');
     }
     \OC_Config::setValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
     \OC_Config::setValue('trashbin_auto_expire', self::$rememberAutoExpire);
     \OC_Hook::clear();
 }
Ejemplo n.º 27
0
 public static function setUpBeforeClass()
 {
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCA\Files_Versions\Hooks::connectHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // create test user
     self::loginHelper(self::TEST_VERSIONS_USER2, true);
     self::loginHelper(self::TEST_VERSIONS_USER, true);
 }
Ejemplo n.º 28
0
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1);
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->rmdir('public-keys');
     $view->rmdir('owncloud_private_key');
 }
Ejemplo n.º 29
0
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(self::TEST_TRASHBIN_USER1);
     \OC::$server->getConfig()->setSystemValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
     \OC_Hook::clear();
     \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
     if (self::$trashBinStatus) {
         \OC::$server->getAppManager()->enableApp('files_trashbin');
     }
     parent::tearDownAfterClass();
 }
Ejemplo n.º 30
0
 /**
  * get the filesystem info from the cache
  * @param string path
  * @param string root (optional)
  * @return array
  *
  * returns an associative array with the following keys:
  * - size
  * - mtime
  * - ctime
  * - mimetype
  * - encrypted
  * - versioned
  */
 public static function get($path, $root = false)
 {
     if (OC_FileCache_Update::hasUpdated($path, $root)) {
         if ($root === false) {
             //filesystem hooks are only valid for the default root
             OC_Hook::emit('OC_Filesystem', 'post_write', array('path' => $path));
         } else {
             OC_FileCache_Update::update($path, $root);
         }
     }
     return OC_FileCache_Cached::get($path, $root);
 }