aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/hooks/hooks.php133
-rw-r--r--apps/files_encryption/lib/util.php102
-rw-r--r--apps/files_encryption/tests/hooks.php26
-rwxr-xr-xapps/files_encryption/tests/share.php51
-rwxr-xr-xapps/files_encryption/tests/util.php2
5 files changed, 57 insertions, 257 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index 0b6c5adf3fb..5f0494e62ca 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -302,25 +302,6 @@ class Hooks {
*/
public static function postShared($params) {
- // NOTE: $params has keys:
- // [itemType] => file
- // itemSource -> int, filecache file ID
- // [parent] =>
- // [itemTarget] => /13
- // shareWith -> string, uid of user being shared to
- // fileTarget -> path of file being shared
- // uidOwner -> owner of the original file being shared
- // [shareType] => 0
- // [shareWith] => test1
- // [uidOwner] => admin
- // [permissions] => 17
- // [fileSource] => 13
- // [fileTarget] => /test8
- // [id] => 10
- // [token] =>
- // [run] => whether emitting script should continue to run
- // TODO: Should other kinds of item be encrypted too?
-
if (\OCP\App::isEnabled('files_encryption') === false) {
return true;
}
@@ -331,71 +312,22 @@ class Hooks {
$session = new \OCA\Encryption\Session($view);
$userId = \OCP\User::getUser();
$util = new Util($view, $userId);
- $path = $util->fileIdToPath($params['itemSource']);
-
- $share = $util->getParentFromShare($params['id']);
- //if parent is set, then this is a re-share action
- if ($share['parent'] !== null) {
-
- // get the parent from current share
- $parent = $util->getShareParent($params['parent']);
-
- // if parent has the same type than the child it is a 1:1 share
- if ($parent['item_type'] === $params['itemType']) {
-
- // prefix path with Shared
- $path = '/Shared' . $parent['file_target'];
- } else {
-
- // NOTE: parent is folder but shared was a file!
- // we try to rebuild the missing path
- // some examples we face here
- // user1 share folder1 with user2 folder1 has
- // the following structure
- // /folder1/subfolder1/subsubfolder1/somefile.txt
- // user2 re-share subfolder2 with user3
- // user3 re-share somefile.txt user4
- // so our path should be
- // /Shared/subfolder1/subsubfolder1/somefile.txt
- // while user3 is sharing
-
- if ($params['itemType'] === 'file') {
- // get target path
- $targetPath = $util->fileIdToPath($params['fileSource']);
- $targetPathSplit = array_reverse(explode('/', $targetPath));
-
- // init values
- $path = '';
- $sharedPart = ltrim($parent['file_target'], '/');
-
- // rebuild path
- foreach ($targetPathSplit as $pathPart) {
- if ($pathPart !== $sharedPart) {
- $path = '/' . $pathPart . $path;
- } else {
- break;
- }
- }
- // prefix path with Shared
- $path = '/Shared' . $parent['file_target'] . $path;
- } else {
- // prefix path with Shared
- $path = '/Shared' . $parent['file_target'] . $params['fileTarget'];
- }
- }
- }
+ $path = \OC\Files\Filesystem::getPath($params['fileSource']);
$sharingEnabled = \OCP\Share::isEnabled();
// get the path including mount point only if not a shared folder
- if (strncmp($path, '/Shared', strlen('/Shared') !== 0)) {
- // get path including the the storage mount point
- $path = $util->getPathWithMountPoint($params['itemSource']);
+ list($storage, ) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/files' . $path);
+
+ if (!($storage instanceof \OC\Files\Storage\Local)) {
+ $mountPoint = 'files' . $storage->getMountPoint();
+ } else {
+ $mountPoint = '';
}
// if a folder was shared, get a list of all (sub-)folders
if ($params['itemType'] === 'folder') {
- $allFiles = $util->getAllFiles($path);
+ $allFiles = $util->getAllFiles($path, $mountPoint);
} else {
$allFiles = array($path);
}
@@ -412,13 +344,6 @@ class Hooks {
*/
public static function postUnshare($params) {
- // NOTE: $params has keys:
- // [itemType] => file
- // [itemSource] => 13
- // [shareType] => 0
- // [shareWith] => test1
- // [itemParent] =>
-
if (\OCP\App::isEnabled('files_encryption') === false) {
return true;
}
@@ -428,34 +353,7 @@ class Hooks {
$view = new \OC_FilesystemView('/');
$userId = \OCP\User::getUser();
$util = new Util($view, $userId);
- $path = $util->fileIdToPath($params['itemSource']);
-
- // check if this is a re-share
- if ($params['itemParent']) {
-
- // get the parent from current share
- $parent = $util->getShareParent($params['itemParent']);
-
- // get target path
- $targetPath = $util->fileIdToPath($params['itemSource']);
- $targetPathSplit = array_reverse(explode('/', $targetPath));
-
- // init values
- $path = '';
- $sharedPart = ltrim($parent['file_target'], '/');
-
- // rebuild path
- foreach ($targetPathSplit as $pathPart) {
- if ($pathPart !== $sharedPart) {
- $path = '/' . $pathPart . $path;
- } else {
- break;
- }
- }
-
- // prefix path with Shared
- $path = '/Shared' . $parent['file_target'] . $path;
- }
+ $path = \OC\Files\Filesystem::getPath($params['fileSource']);
// for group shares get a list of the group members
if ($params['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) {
@@ -469,14 +367,17 @@ class Hooks {
}
// get the path including mount point only if not a shared folder
- if (strncmp($path, '/Shared', strlen('/Shared') !== 0)) {
- // get path including the the storage mount point
- $path = $util->getPathWithMountPoint($params['itemSource']);
+ list($storage, ) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/files' . $path);
+
+ if (!($storage instanceof \OC\Files\Storage\Local)) {
+ $mountPoint = 'files' . $storage->getMountPoint();
+ } else {
+ $mountPoint = '';
}
// if we unshare a folder we need a list of all (sub-)files
if ($params['itemType'] === 'folder') {
- $allFiles = $util->getAllFiles($path);
+ $allFiles = $util->getAllFiles($path, $mountPoint);
} else {
$allFiles = array($path);
}
@@ -510,6 +411,8 @@ class Hooks {
// otherwise we perform a stream copy, so we get a new set of keys
$mp1 = $view->getMountPoint('/' . $user . '/files/' . $params['oldpath']);
$mp2 = $view->getMountPoint('/' . $user . '/files/' . $params['newpath']);
+ list($storage1, ) = Filesystem::resolvePath($params['oldpath']);
+
if ($mp1 === $mp2) {
self::$renamedFiles[$params['oldpath']] = array(
'uid' => $ownerOld,
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index b86815021a8..6372ab31b6e 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -970,33 +970,6 @@ class Util {
}
/**
- * @brief get path of a file.
- * @param int $fileId id of the file
- * @return string path of the file
- */
- public static function fileIdToPath($fileId) {
-
- $sql = 'SELECT `path` FROM `*PREFIX*filecache` WHERE `fileid` = ?';
-
- $query = \OCP\DB::prepare($sql);
-
- $result = $query->execute(array($fileId));
-
- $path = false;
- if (\OCP\DB::isError($result)) {
- \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
- } else {
- $row = $result->fetchRow();
- if ($row) {
- $path = substr($row['path'], strlen('files'));
- }
- }
-
- return $path;
-
- }
-
- /**
* @brief Filter an array of UIDs to return only ones ready for sharing
* @param array $unfilteredUsers users to be checked for sharing readiness
* @return array as multi-dimensional array. keys: ready, unready
@@ -1398,7 +1371,7 @@ class Util {
* @param string $dir relative to the users files folder
* @return array with list of files relative to the users files folder
*/
- public function getAllFiles($dir) {
+ public function getAllFiles($dir, $mountPoint = '') {
$result = array();
$dirList = array($dir);
@@ -1408,11 +1381,13 @@ class Util {
$this->userFilesDir . '/' . $dir));
foreach ($content as $c) {
- $usersPath = isset($c['usersPath']) ? $c['usersPath'] : $c['path'];
+ // getDirectoryContent() returns the paths relative to the mount points, so we need
+ // to re-construct the complete path
+ $path = ($mountPoint !== '') ? $mountPoint . '/' . $c['path'] : $c['path'];
if ($c['type'] === 'dir') {
- $dirList[] = substr($usersPath, strlen("files"));
+ $dirList[] = substr($path, strlen("files"));
} else {
- $result[] = substr($usersPath, strlen("files"));
+ $result[] = substr($path, strlen("files"));
}
}
@@ -1422,54 +1397,6 @@ class Util {
}
/**
- * @brief get shares parent.
- * @param int $id of the current share
- * @return array of the parent
- */
- public static function getShareParent($id) {
-
- $sql = 'SELECT `file_target`, `item_type` FROM `*PREFIX*share` WHERE `id` = ?';
-
- $query = \OCP\DB::prepare($sql);
-
- $result = $query->execute(array($id));
-
- $row = array();
- if (\OCP\DB::isError($result)) {
- \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
- } else {
- $row = $result->fetchRow();
- }
-
- return $row;
-
- }
-
- /**
- * @brief get shares parent.
- * @param int $id of the current share
- * @return array of the parent
- */
- public static function getParentFromShare($id) {
-
- $sql = 'SELECT `parent` FROM `*PREFIX*share` WHERE `id` = ?';
-
- $query = \OCP\DB::prepare($sql);
-
- $result = $query->execute(array($id));
-
- $row = array();
- if (\OCP\DB::isError($result)) {
- \OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
- } else {
- $row = $result->fetchRow();
- }
-
- return $row;
-
- }
-
- /**
* @brief get owner of the shared files.
* @param $id
* @internal param int $Id of a share
@@ -1711,23 +1638,6 @@ class Util {
}
/**
- * Get the path including the storage mount point
- * @param int $id
- * @return string the path including the mount point like AmazonS3/folder/file.txt
- */
- public function getPathWithMountPoint($id) {
- list($storage, $internalPath) = \OC\Files\Cache\Cache::getById($id);
- $mount = \OC\Files\Filesystem::getMountByStorageId($storage);
- $mountPoint = $mount[0]->getMountPoint();
- $path = \OC\Files\Filesystem::normalizePath($mountPoint . '/' . $internalPath);
-
- // reformat the path to be relative e.g. /user/files/folder becomes /folder/
- $relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
-
- return $relativePath;
- }
-
- /**
* @brief check if the file is stored on a system wide mount point
* @param $path relative to /data/user with leading '/'
* @return boolean
diff --git a/apps/files_encryption/tests/hooks.php b/apps/files_encryption/tests/hooks.php
index d0e4b5f732e..047084ca2c1 100644
--- a/apps/files_encryption/tests/hooks.php
+++ b/apps/files_encryption/tests/hooks.php
@@ -219,18 +219,20 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
\Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
\OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2);
- // user2 has a local file with the same name
+ // user2 update the shared file
$this->user2View->file_put_contents($this->filename, $this->data);
- // check if all keys are generated
- $this->assertTrue($this->rootView->file_exists(
+ // keys should be stored at user1s dir, not in user2s
+ $this->assertFalse($this->rootView->file_exists(
self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/share-keys/'
. $this->filename . '.' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
- $this->assertTrue($this->rootView->file_exists(
+ $this->assertFalse($this->rootView->file_exists(
self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keyfiles/' . $this->filename . '.key'));
// delete the Shared file from user1 in data/user2/files/Shared
- $this->user2View->unlink('/Shared/' . $this->filename);
+ $result = $this->user2View->unlink($this->filename);
+
+ $this->assertTrue($result);
// now keys from user1s home should be gone
$this->assertFalse($this->rootView->file_exists(
@@ -242,26 +244,12 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase {
$this->assertFalse($this->rootView->file_exists(
self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/' . $this->filename . '.key'));
- // but user2 keys should still exist
- $this->assertTrue($this->rootView->file_exists(
- self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/share-keys/'
- . $this->filename . '.' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey'));
- $this->assertTrue($this->rootView->file_exists(
- self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keyfiles/' . $this->filename . '.key'));
-
// cleanup
- $this->user2View->unlink($this->filename);
-
\Test_Encryption_Util::logoutHelper();
\Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
\OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1);
- // unshare the file
- \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_HOOKS_USER2);
-
- $this->user1View->unlink($this->filename);
-
if ($stateFilesTrashbin) {
OC_App::enable('files_trashbin');
}
diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php
index 1f57d7cb635..512671c5767 100755
--- a/apps/files_encryption/tests/share.php
+++ b/apps/files_encryption/tests/share.php
@@ -175,7 +175,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// get file contents
$retrievedCryptedFile = $this->view->file_get_contents(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared/' . $this->filename);
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename);
// check if data is the same as we previously written
$this->assertEquals($this->dataShort, $retrievedCryptedFile);
@@ -213,14 +213,14 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
function testReShareFile($withTeardown = true) {
$this->testShareFile(false);
- // login as user1
+ // login as user2
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
// get the file info
$fileInfo = $this->view->getFileInfo(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared/' . $this->filename);
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename);
- // share the file with user2
+ // share the file with user3
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, OCP\PERMISSION_ALL);
// login as admin
@@ -236,7 +236,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// get file contents
$retrievedCryptedFile = $this->view->file_get_contents(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/Shared/' . $this->filename);
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->filename);
// check if data is the same as previously written
$this->assertEquals($this->dataShort, $retrievedCryptedFile);
@@ -333,7 +333,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// get file contents
$retrievedCryptedFile = $this->view->file_get_contents(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared' . $this->folder1
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1
. $this->subfolder . $this->subsubfolder . '/' . $this->filename);
// check if data is the same
@@ -376,7 +376,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
function testReShareFolder($withTeardown = true) {
$fileInfoFolder1 = $this->testShareFolder(false);
- // login as user1
+ // login as user2
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
// disable encryption proxy to prevent recursive calls
@@ -385,7 +385,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// get the file info from previous created folder
$fileInfoSubFolder = $this->view->getFileInfo(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared' . $this->folder1
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1
. $this->subfolder);
// check if we have a valid file info
@@ -394,24 +394,24 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// re-enable the file proxy
\OC_FileProxy::$enabled = $proxyStatus;
- // share the file with user2
+ // share the file with user3
\OCP\Share::shareItem('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, OCP\PERMISSION_ALL);
// login as admin
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
- // check if share key for user2 exists
+ // check if share key for user3 exists
$this->assertTrue($this->view->file_exists(
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys' . $this->folder1
. $this->subfolder . $this->subsubfolder . '/'
. $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey'));
- // login as user2
+ // login as user3
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3);
// get file contents
$retrievedCryptedFile = $this->view->file_get_contents(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/Shared' . $this->subfolder
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->subfolder
. $this->subsubfolder . '/' . $this->filename);
// check if data is the same
@@ -419,7 +419,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// get the file info
$fileInfo = $this->view->getFileInfo(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/Shared' . $this->subfolder
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->subfolder
. $this->subsubfolder . '/' . $this->filename);
// check if we have fileInfos
@@ -442,7 +442,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// get file contents
$retrievedCryptedFile = $this->view->file_get_contents(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '/files/Shared/' . $this->filename);
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '/files/' . $this->filename);
// check if data is the same
$this->assertEquals($this->dataShort, $retrievedCryptedFile);
@@ -624,7 +624,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// get file contents
$retrievedCryptedFile = $this->view->file_get_contents(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/Shared/' . $this->filename);
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->filename);
// check if data is the same as we previously written
$this->assertEquals($this->dataShort, $retrievedCryptedFile);
@@ -676,6 +676,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// enable recovery for admin
$this->assertTrue($util->setRecoveryForUser(1));
+ $util->addRecoveryKeys();
// create folder structure
$this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1);
@@ -981,7 +982,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// share the file
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, OCP\PERMISSION_ALL);
- // check if share key for user2exists
+ // check if share key for user2 exists
$this->assertTrue($this->view->file_exists(
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/share-keys/'
. $this->filename . '.' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey'));
@@ -990,31 +991,29 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
// login as user2
\Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2);
- $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared/' . $this->filename));
+ $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename));
// get file contents
$retrievedCryptedFile = $this->view->file_get_contents(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared/' . $this->filename);
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename);
// check if data is the same as we previously written
$this->assertEquals($this->dataShort, $retrievedCryptedFile);
- // move the file out of the shared folder
- $this->view->rename('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/Shared/' . $this->filename,
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename);
+ // move the file to a subfolder
+ $this->view->rename('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename,
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 . $this->filename);
// check if we can read the moved file
$retrievedRenamedFile = $this->view->file_get_contents(
- '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename);
+ '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 . $this->filename);
// check if data is the same as we previously written
$this->assertEquals($this->dataShort, $retrievedRenamedFile);
- // the owners file should be deleted
- $this->assertFalse($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename));
-
// cleanup
- $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename);
+ \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1);
+ $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
}
}
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index 203ba55dbfd..717b66b86af 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -520,8 +520,8 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
- \OC_Util::setupFS($user);
\OC_User::setUserId($user);
+ \OC_Util::setupFS($user);
$params['uid'] = $user;
$params['password'] = $password;