Beispiel #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getOption('debug')) {
         $this->scanner->listen('\\OCA\\Music\\Utility\\Scanner', 'update', function ($path) use($output) {
             $output->writeln("Scanning <info>{$path}</info>");
         });
     }
     $inputPath = $input->getOption('path');
     $path = false;
     if ($inputPath) {
         $path = '/' . trim($inputPath, '/');
         list(, $user, ) = explode('/', $path, 3);
         $users = array($user);
     } else {
         if ($input->getOption('all')) {
             $users = $this->userManager->search('');
         } else {
             $users = $input->getArgument('user_id');
         }
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($user);
         $output->writeln("Start scan for <info>{$user}</info>");
         $this->scanner->rescan($user, true, $path ? $path : $this->resolveUserFolder($user), $input->getOption('debug'), $output);
     }
 }
Beispiel #2
0
 public static function getByShareToken($token)
 {
     $linkItem = \OCP\Share::getShareByToken($token);
     if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
         // seems to be a valid share
         $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
         $fileOwner = $rootLinkItem['uid_owner'];
     } else {
         throw new \Exception('This file was probably unshared');
     }
     if (!isset($rootLinkItem['path']) && isset($rootLinkItem['file_target'])) {
         $rootLinkItem['path'] = 'files/' . $rootLinkItem['file_target'];
     }
     $file = new File($rootLinkItem['file_source'], array($rootLinkItem));
     if (isset($rootLinkItem['uid_owner'])) {
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($rootLinkItem['uid_owner']);
         $file->setOwner($rootLinkItem['uid_owner']);
         $file->setPath('/files' . \OC\Files\Filesystem::getPath($linkItem['file_source']));
     }
     if (isset($linkItem['share_with']) && !empty($linkItem['share_with'])) {
         $file->setPasswordProtected(true);
     }
     return $file;
 }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 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);
 }
Beispiel #5
0
 /**
  * Act on behalf on trash item owner
  * @param string $user
  * @return boolean
  */
 private function setupFS($user)
 {
     if (!$this->userManager->userExists($user)) {
         return false;
     }
     \OC_Util::tearDownFS();
     \OC_Util::setupFS($user);
     return true;
 }
Beispiel #6
0
 /**
  * @param IUser $user
  */
 protected function runScanner(IUser $user)
 {
     try {
         $scanner = new Scanner($user->getUID(), $this->dbConnection, $this->logger);
         $scanner->backgroundScan('');
     } catch (\Exception $e) {
         $this->logger->logException($e, ['app' => 'files']);
     }
     \OC_Util::tearDownFS();
 }
 public function setUp()
 {
     parent::setUp();
     $this->userSession->setUser(null);
     \OC_Util::tearDownFS();
     $job = new IndexJob();
     $job->run(array('user' => 'test'));
     $this->userSession->setUser(null);
     \OC_Util::tearDownFS();
 }
 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);
 }
Beispiel #9
0
 /**
  * Generates a test user and sets up their file system
  * @return string the test users id
  */
 public function generateUser()
 {
     $username = uniqid();
     \OC_User::createUser($username, 'password');
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     \OC\Files\Filesystem::tearDown();
     \OC_Util::setupFS($username);
     $this->users[] = $username;
     return $username;
 }
 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());
 }
Beispiel #11
0
 public function handle()
 {
     $userManager = \OC::$server->getUserManager();
     if (!$userManager->userExists($this->user)) {
         // User has been deleted already
         return;
     }
     \OC_Util::setupFS($this->user);
     Storage::expire($this->fileName, $this->versionsSize, $this->neededSpace);
     \OC_Util::tearDownFS();
 }
Beispiel #12
0
 /**
  * Act on behalf on trash item owner
  * @param string $user
  * @return boolean
  */
 protected function setupFS($user)
 {
     \OC_Util::tearDownFS();
     \OC_Util::setupFS($user);
     // Check if this user has a versions directory
     $view = new \OC\Files\View('/' . $user);
     if (!$view->is_dir('/files_versions')) {
         return false;
     }
     return true;
 }
 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);
 }
 protected function setupForUser($name, $password)
 {
     \OC_Util::tearDownFS();
     \OC_Util::setupFS($name);
     $container = $this->encryptionApp->getContainer();
     /** @var KeyManager $keyManager */
     $keyManager = $container->query('KeyManager');
     /** @var Setup $userSetup */
     $userSetup = $container->query('UserSetup');
     $userSetup->setupUser($name, $password);
     $keyManager->init($name, $password);
 }
Beispiel #15
0
 /**
  * get all storages for $dir
  *
  * @param string $dir
  * @return \OC\Files\Mount\MountPoint[]
  */
 protected function getMounts($dir)
 {
     //TODO: move to the node based fileapi once that's done
     \OC_Util::tearDownFS();
     \OC_Util::setupFS($this->user);
     $mountManager = Filesystem::getMountManager();
     $mounts = $mountManager->findIn($dir);
     $mounts[] = $mountManager->find($dir);
     $mounts = array_reverse($mounts);
     //start with the mount of $dir
     return $mounts;
 }
Beispiel #16
0
 public function handle()
 {
     $userManager = \OC::$server->getUserManager();
     if (!$userManager->userExists($this->user)) {
         // User has been deleted already
         return;
     }
     \OC_Util::tearDownFS();
     \OC_Util::setupFS($this->user);
     Trashbin::expire($this->trashBinSize, $this->user);
     \OC_Util::tearDownFS();
 }
Beispiel #17
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);
     $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);
 }
Beispiel #18
0
 /**
  * Sets up the filesystem and user for public sharing
  * @param string $token string share token
  * @param string $relativePath optional path relative to the share
  * @param string $password optional password
  * @return array
  */
 public static function setupFromToken($token, $relativePath = null, $password = null)
 {
     \OC_User::setIncognitoMode(true);
     $linkItem = \OCP\Share::getShareByToken($token, !$password);
     if ($linkItem === false || $linkItem['item_type'] !== 'file' && $linkItem['item_type'] !== 'folder') {
         \OC_Response::setStatus(404);
         \OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG);
         exit;
     }
     if (!isset($linkItem['uid_owner']) || !isset($linkItem['file_source'])) {
         \OC_Response::setStatus(500);
         \OCP\Util::writeLog('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OCP\Util::WARN);
         exit;
     }
     $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
     $path = null;
     if (isset($rootLinkItem['uid_owner'])) {
         \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($rootLinkItem['uid_owner']);
     }
     try {
         $path = Filesystem::getPath($linkItem['file_source']);
     } catch (NotFoundException $e) {
         \OCP\Util::writeLog('share', 'could not resolve linkItem', \OCP\Util::DEBUG);
         \OC_Response::setStatus(404);
         \OCP\JSON::error(array('success' => false));
         exit;
     }
     if (!isset($linkItem['item_type'])) {
         \OCP\Util::writeLog('share', 'No item type set for share id: ' . $linkItem['id'], \OCP\Util::ERROR);
         \OC_Response::setStatus(404);
         \OCP\JSON::error(array('success' => false));
         exit;
     }
     if (isset($linkItem['share_with']) && (int) $linkItem['share_type'] === \OCP\Share::SHARE_TYPE_LINK) {
         if (!self::authenticate($linkItem, $password)) {
             \OC_Response::setStatus(403);
             \OCP\JSON::error(array('success' => false));
             exit;
         }
     }
     $basePath = $path;
     if ($relativePath !== null && Filesystem::isReadable($basePath . $relativePath)) {
         $path .= Filesystem::normalizePath($relativePath);
     }
     return array('linkItem' => $linkItem, 'basePath' => $basePath, 'realPath' => $path);
 }
Beispiel #19
0
 /**
  * @param string $userId
  * @return \OCP\Files\Folder
  * @throws SetUpException
  */
 public function setUpUserHome($userId = null)
 {
     if (is_null($userId)) {
         $user = $this->userSession->getUser();
     } else {
         $user = $this->userManager->get($userId);
     }
     if (is_null($user) || !$this->userManager->userExists($user->getUID())) {
         throw new SetUpException('could not set up user home for ' . json_encode($user));
     }
     if ($user !== $this->userSession->getUser()) {
         \OC_Util::tearDownFS();
         $this->userSession->setUser($user);
     }
     \OC_Util::setupFS($user->getUID());
     return $this->getOrCreateSubFolder($this->rootFolder, '/' . $user->getUID());
 }
 /**
  * A method that does the common steps of test cases 1 and 2. The evaluation
  * is not happening here.
  *
  * @param string $dn
  * @param string $username
  * @param string $image
  */
 private function execFetchTest($dn, $username, $image)
 {
     $this->setJpegPhotoAttribute($dn, $image);
     // assigns our self-picked oc username to the dn
     $this->mapping->map($dn, $username, 'fakeUUID-' . $username);
     // initialize home folder and make sure that the user will update
     // also remove an possibly existing avatar
     \OC_Util::tearDownFS();
     \OC_Util::setupFS($username);
     \OC::$server->getUserFolder($username);
     \OC::$server->getConfig()->deleteUserValue($username, 'user_ldap', User::USER_PREFKEY_LASTREFRESH);
     if (\OC::$server->getAvatarManager()->getAvatar($username)->exists()) {
         \OC::$server->getAvatarManager()->getAvatar($username)->remove();
     }
     // finally attempt to get the avatar set
     $user = $this->userManager->get($dn);
     $user->updateAvatar();
 }
Beispiel #21
0
 function testIndexJob()
 {
     // preparation
     $app = new Application();
     $container = $app->getContainer();
     $this->userSession->setUser(null);
     \OC_Util::tearDownFS();
     $job = new IndexJob();
     $job->run(array('user' => 'test'));
     // get an index
     /** @var Index $index */
     $index = $container->query('Index');
     // search for it
     /** @var QueryHit[] $hits */
     $hits = $index->find('foo');
     // get the document from the query hit
     $foundDoc = $hits[0]->getDocument();
     $this->assertSame('document.txt', basename($foundDoc->getFieldValue('path')));
 }
Beispiel #22
0
 /**
  * Tests that the home storage is not wrapped when no quota exists.
  */
 function testHomeStorageWrapperWithQuota()
 {
     $user1 = $this->getUniqueID();
     \OC_User::createUser($user1, 'test');
     \OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', '1024');
     \OC_User::setUserId($user1);
     \OC_Util::setupFS($user1);
     $userMount = \OC\Files\Filesystem::getMountManager()->find('/' . $user1 . '/');
     $this->assertNotNull($userMount);
     $this->assertTrue($userMount->getStorage()->instanceOfStorage('\\OC\\Files\\Storage\\Wrapper\\Quota'));
     // ensure that root wasn't wrapped
     $rootMount = \OC\Files\Filesystem::getMountManager()->find('/');
     $this->assertNotNull($rootMount);
     $this->assertNotInstanceOf('\\OC\\Files\\Storage\\Wrapper\\Quota', $rootMount->getStorage());
     // clean up
     \OC_User::setUserId('');
     \OC_User::deleteUser($user1);
     \OC::$server->getConfig()->deleteAllUserValues($user1);
     \OC_Util::tearDownFS();
 }
Beispiel #23
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $scanner = $this->container['Scanner'];
     $scanner->listen('\\OCA\\Music\\Utility\\Scanner', 'update', function ($path) use($output) {
         $output->writeln("Scanning <info>{$path}</info>");
     });
     if ($input->getOption('all')) {
         $users = $this->userManager->search('');
     } else {
         $users = $input->getArgument('user_id');
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($user);
         $output->writeln("Start scan for <info>{$user}</info>");
         $scanner->rescan($user, true);
     }
 }
 public function testNewUser()
 {
     $user1 = $this->getUniqueID('user_');
     $this->userBackend->createUser($user1, '');
     \OC_Util::tearDownFS();
     \OC_User::setUserId($user1);
     \OC_Util::setupFS($user1);
     Filesystem::mkdir('/folder');
     Filesystem::mkdir('/folder/subfolder');
     Filesystem::file_put_contents('/foo.txt', 'asd');
     Filesystem::file_put_contents('/folder/bar.txt', 'fgh');
     Filesystem::file_put_contents('/folder/subfolder/qwerty.txt', 'jkl');
     $files = array('/foo.txt', '/folder/bar.txt', '/folder/subfolder', '/folder/subfolder/qwerty.txt');
     $originalEtags = $this->getEtags($files);
     $scanner = new \OC\Files\Utils\Scanner($user1, \OC::$server->getDatabaseConnection());
     $scanner->backgroundScan('/');
     $newEtags = $this->getEtags($files);
     // loop over array and use assertSame over assertEquals to prevent false positives
     foreach ($originalEtags as $file => $originalEtag) {
         $this->assertSame($originalEtag, $newEtags[$file]);
     }
 }
Beispiel #25
0
 public function setUp()
 {
     $app = new Application();
     $container = $app->getContainer();
     // reset backend
     $um = $container->getServer()->getUserManager();
     $this->userSession = $container->getServer()->getUserSession();
     $um->clearBackends();
     $um->registerBackend(new \OC_User_Database());
     // create test user
     $this->userName = '******';
     \OC_User::deleteUser($this->userName);
     $um->createUser($this->userName, $this->userName);
     \OC_Util::tearDownFS();
     $this->userSession->setUser(null);
     Filesystem::tearDown();
     \OC_Util::setupFS($this->userName);
     $this->userSession->setUser($um->get($this->userName));
     $view = new \OC\Files\View('/' . $this->userName . '/files');
     // setup files
     $filesToCopy = array('documents' => array('document.pdf', 'document.docx', 'document.odt', 'document.txt'));
     $count = 0;
     foreach ($filesToCopy as $folder => $files) {
         foreach ($files as $file) {
             $imgData = file_get_contents(__DIR__ . '/data/' . $file);
             $view->mkdir($folder);
             $path = $folder . '/' . $file;
             $view->file_put_contents($path, $imgData);
             // set mtime to get fixed sorting with respect to recentFiles
             $count++;
             $view->touch($path, 1000 + $count);
         }
     }
     list($storage, ) = $view->resolvePath('');
     /** @var $storage Storage */
     $this->storage = $storage;
     $this->scanner = $storage->getScanner();
     $this->scanner->scan('');
 }
Beispiel #26
0
 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // disable file proxy by default
     \OC_FileProxy::$enabled = false;
     // setup filesystem
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     \OC\Files\Filesystem::tearDown();
     \OC_Util::setupFS('admin');
     \OC_User::setUserId('admin');
     // login admin
     $params['uid'] = 'admin';
     $params['password'] = '******';
     OCA\Encryption\Hooks::login($params);
 }
Beispiel #27
0
 /**
  * Function that is called before a user is added to a group.
  * check if we need to create a unique target for the user
  * @param array $arguments
  */
 public static function pre_addToGroup($arguments)
 {
     $currentUser = \OC::$server->getUserSession()->getUser();
     $currentUserID = is_null($currentUser) ? '' : $currentUser->getUID();
     // setup filesystem for added user if it isn't the current user
     if ($currentUserID !== $arguments['uid']) {
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($arguments['uid']);
     }
     /** @var \OC\DB\Connection $db */
     $db = \OC::$server->getDatabaseConnection();
     $insert = $db->createQueryBuilder();
     $select = $db->createQueryBuilder();
     // Find the group shares and check if the user needs a unique target
     $select->select('*')->from('`*PREFIX*share`')->where($select->expr()->andX($select->expr()->eq('`share_type`', ':shareType'), $select->expr()->eq('`share_with`', ':shareWith')))->setParameter('shareType', self::SHARE_TYPE_GROUP)->setParameter('shareWith', $arguments['gid']);
     $result = $select->execute();
     while ($item = $result->fetch()) {
         $itemTarget = Helper::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, $arguments['uid'], $item['uid_owner'], null, $item['parent']);
         if ($item['item_type'] === 'file' || $item['item_type'] === 'folder') {
             $fileTarget = Helper::generateTarget($item['item_type'], $item['file_target'], self::SHARE_TYPE_USER, $arguments['uid'], $item['uid_owner'], null, $item['parent']);
         } else {
             $fileTarget = null;
         }
         // Insert an extra row for the group share if the item or file target is unique for this user
         if ($fileTarget === null && $itemTarget != $item['item_target'] || $fileTarget !== null && $fileTarget !== $item['file_target']) {
             self::$updateTargets[$arguments['gid']][] = ['`item_type`' => $insert->expr()->literal($item['item_type']), '`item_source`' => $insert->expr()->literal($item['item_source']), '`item_target`' => $insert->expr()->literal($itemTarget), '`file_target`' => $insert->expr()->literal($fileTarget), '`parent`' => $insert->expr()->literal($item['id']), '`share_type`' => $insert->expr()->literal(self::$shareTypeGroupUserUnique), '`share_with`' => $insert->expr()->literal($arguments['uid']), '`uid_owner`' => $insert->expr()->literal($item['uid_owner']), '`permissions`' => $insert->expr()->literal($item['permissions']), '`stime`' => $insert->expr()->literal($item['stime']), '`file_source`' => $insert->expr()->literal($item['file_source'])];
         }
     }
     // re-setup old filesystem state
     if ($currentUserID !== $arguments['uid']) {
         \OC_Util::tearDownFS();
         if ($currentUserID !== '') {
             \OC_Util::setupFS($currentUserID);
         }
     }
 }
Beispiel #28
0
 public function __construct($fileId, $shareOps = null, $token = '')
 {
     if (!$fileId) {
         throw new \Exception('No valid file has been passed');
     }
     $this->fileId = $fileId;
     $this->sharing = $shareOps;
     $this->token = $token;
     if ($this->isPublicShare()) {
         if (isset($this->sharing['uid_owner'])) {
             $this->owner = $this->sharing['uid_owner'];
             if (!\OC::$server->getUserManager()->userExists($this->sharing['uid_owner'])) {
                 throw new \Exception('Share owner' . $this->sharing['uid_owner'] . ' does not exist ');
             }
             \OC_Util::tearDownFS();
             \OC_Util::setupFS($this->sharing['uid_owner']);
         } else {
             throw new \Exception($this->fileId . ' is a broken share');
         }
     } else {
         $this->owner = \OC::$server->getUserSession()->getUser()->getUID();
     }
     $this->initViews();
 }
Beispiel #29
0
 /**
  * Run all commands pushed to the bus
  */
 protected function runCommands()
 {
     // get the user for which the fs is setup
     $view = Filesystem::getView();
     if ($view) {
         list(, $user) = explode('/', $view->getRoot());
     } else {
         $user = null;
     }
     \OC_Util::tearDownFS();
     // command cant reply on the fs being setup
     $this->commandBus->run();
     \OC_Util::tearDownFS();
     if ($user) {
         \OC_Util::setupFS($user);
     }
 }
Beispiel #30
0
 public function testGetPathByIdShareSubFolder()
 {
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OC\Files\Filesystem::mkdir('foo');
     \OC\Files\Filesystem::mkdir('foo/bar');
     \OC\Files\Filesystem::touch('foo/bar/test.txt', 'bar');
     $folderInfo = \OC\Files\Filesystem::getFileInfo('foo');
     $fileInfo = \OC\Files\Filesystem::getFileInfo('foo/bar/test.txt');
     \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL);
     \OC_Util::tearDownFS();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists('/foo'));
     list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo');
     /**
      * @var \OC\Files\Storage\Shared $sharedStorage
      */
     $sharedCache = $sharedStorage->getCache();
     $this->assertEquals('', $sharedCache->getPathById($folderInfo->getId()));
     $this->assertEquals('bar/test.txt', $sharedCache->getPathById($fileInfo->getId()));
 }