aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-04-25 11:47:06 +0200
committerRobin Appelman <icewind@owncloud.com>2014-04-25 11:47:06 +0200
commit6c20a014eaecd19c3f68143485c6f74891ee9643 (patch)
tree84bd8e37536e7f28a25afd7586c209d38a25d610 /apps/files_encryption
parentcd0c5990f895bcdce47acf2dbf11ebadd920a404 (diff)
parent3fc809dfd80a296d7da922a06f9e13d446b3d3f0 (diff)
downloadnextcloud-server-6c20a014eaecd19c3f68143485c6f74891ee9643.tar.gz
nextcloud-server-6c20a014eaecd19c3f68143485c6f74891ee9643.zip
merge master into webdav-injection
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/hooks/hooks.php133
-rw-r--r--apps/files_encryption/l10n/es_AR.php1
-rw-r--r--apps/files_encryption/l10n/pt_PT.php3
-rw-r--r--apps/files_encryption/l10n/sk_SK.php1
-rw-r--r--apps/files_encryption/l10n/zh_TW.php2
-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
9 files changed, 64 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/l10n/es_AR.php b/apps/files_encryption/l10n/es_AR.php
index bc1eedbf5eb..b885716f89b 100644
--- a/apps/files_encryption/l10n/es_AR.php
+++ b/apps/files_encryption/l10n/es_AR.php
@@ -16,6 +16,7 @@ $TRANSLATIONS = array(
"Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled." => "Por favor, asegúrese de que PHP 5.3.3 o una versión más reciente esté instalado y que OpenSSL junto con la extensión PHP esté habilitado y configurado apropiadamente. Por ahora, la aplicación de encriptación ha sido deshabilitada.",
"Following users are not set up for encryption:" => "Los siguientes usuarios no fueron configurados para encriptar:",
"Initial encryption started... This can take some time. Please wait." => "Encriptación inicial comenzada... Esto puede durar un tiempo. Por favor espere.",
+"Initial encryption running... Please try again later." => "Encriptación inicial corriendo... Por favor intente mas tarde. ",
"Go directly to your " => "Ve directamente a tu",
"personal settings" => "Configuración personal",
"Encryption" => "Encriptación",
diff --git a/apps/files_encryption/l10n/pt_PT.php b/apps/files_encryption/l10n/pt_PT.php
index d6d3c260363..9a1963953e3 100644
--- a/apps/files_encryption/l10n/pt_PT.php
+++ b/apps/files_encryption/l10n/pt_PT.php
@@ -7,8 +7,11 @@ $TRANSLATIONS = array(
"Password successfully changed." => "Password alterada com sucesso.",
"Could not change the password. Maybe the old password was not correct." => "Não foi possivel alterar a password. Possivelmente a password antiga não está correcta.",
"Could not update the private key password. Maybe the old password was not correct." => "Não foi possível alterar a chave. Possivelmente a password antiga não está correcta.",
+"Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you." => "Não foi possível desencriptar este ficheiro, possivelmente é um ficheiro partilhado. Peça ao proprietário do ficheiro para voltar a partilhar o ficheiro consigo.",
+"Unknown error please check your system settings or contact your administrator" => "Erro desconhecido. Verifique por favor as definições do sistema ou contacte o seu administrador",
"Missing requirements." => "Faltam alguns requisitos.",
"Following users are not set up for encryption:" => "Os utilizadores seguintes não estão marcados para cifragem:",
+"Go directly to your " => "Ir directamente para o seu",
"personal settings" => "configurações personalizadas ",
"Encryption" => "Encriptação",
"Enable recovery key (allow to recover users files in case of password loss):" => "Active a chave de recuperação (permite recuperar os ficheiros no caso de perda da password):",
diff --git a/apps/files_encryption/l10n/sk_SK.php b/apps/files_encryption/l10n/sk_SK.php
index 5fcd0a9f060..53ee2bc0303 100644
--- a/apps/files_encryption/l10n/sk_SK.php
+++ b/apps/files_encryption/l10n/sk_SK.php
@@ -16,6 +16,7 @@ $TRANSLATIONS = array(
"Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled." => "Prosím uistite sa, že PHP verzie 5.3.3 alebo novšej je nainštalované a tiež, že OpenSSL knižnica spolu z PHP rozšírením je povolená a konfigurovaná správne. Nateraz bola aplikácia šifrovania zablokovaná.",
"Following users are not set up for encryption:" => "Nasledujúci používatelia nie sú nastavení pre šifrovanie:",
"Initial encryption started... This can take some time. Please wait." => "Počiatočné šifrovanie započalo ... To môže nejakú dobu trvať. Čakajte prosím.",
+"Initial encryption running... Please try again later." => "Počiatočné šifrovanie beží... Skúste to neskôr znovu.",
"Go directly to your " => "Choďte priamo do vášho",
"personal settings" => "osobné nastavenia",
"Encryption" => "Šifrovanie",
diff --git a/apps/files_encryption/l10n/zh_TW.php b/apps/files_encryption/l10n/zh_TW.php
index 390e6aff8c6..84146437ac0 100644
--- a/apps/files_encryption/l10n/zh_TW.php
+++ b/apps/files_encryption/l10n/zh_TW.php
@@ -15,6 +15,8 @@ $TRANSLATIONS = array(
"Missing requirements." => "遺失必要條件。",
"Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled." => "請確認已安裝 PHP 5.3.3 或是更新的版本以及 OpenSSL 也一併安裝在 PHP extension 裡面並啟用及設置完成。現在,加密功能是停用的。",
"Following users are not set up for encryption:" => "以下的使用者無法設定加密:",
+"Initial encryption started... This can take some time. Please wait." => "加密初始已啟用...這個需要一些時間。請稍等。",
+"Initial encryption running... Please try again later." => "加密初始執行中...請晚點再試。",
"Go directly to your " => "直接到您的",
"personal settings" => "個人設定",
"Encryption" => "加密",
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 55a056613e4..a29ef831a52 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -524,8 +524,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;