From e67fe0336bde1b10c1b2ba3dc455a9106cfc4be9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 3 Dec 2014 17:03:11 +0100 Subject: [PATCH] Use self:: instead of the class name in encryption tests --- apps/files_encryption/tests/crypt.php | 10 +- apps/files_encryption/tests/helper.php | 10 +- apps/files_encryption/tests/hooks.php | 52 +-- apps/files_encryption/tests/keymanager.php | 136 +++---- apps/files_encryption/tests/proxy.php | 26 +- apps/files_encryption/tests/share.php | 452 ++++++++++----------- apps/files_encryption/tests/stream.php | 10 +- apps/files_encryption/tests/trashbin.php | 8 +- apps/files_encryption/tests/util.php | 6 +- apps/files_encryption/tests/webdav.php | 12 +- 10 files changed, 361 insertions(+), 361 deletions(-) diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php index 2a60340405..d57fec18eb 100755 --- a/apps/files_encryption/tests/crypt.php +++ b/apps/files_encryption/tests/crypt.php @@ -34,16 +34,16 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase { parent::setUpBeforeClass(); // create test user - self::loginHelper(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1, true); + self::loginHelper(self::TEST_ENCRYPTION_CRYPT_USER1, true); } protected function setUp() { parent::setUp(); // set user id - self::loginHelper(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1); - $this->userId = \Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1; - $this->pass = \Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1; + self::loginHelper(self::TEST_ENCRYPTION_CRYPT_USER1); + $this->userId = self::TEST_ENCRYPTION_CRYPT_USER1; + $this->pass = self::TEST_ENCRYPTION_CRYPT_USER1; // set content for encrypting / decrypting in tests $this->dataLong = file_get_contents(__DIR__ . '/../lib/crypt.php'); @@ -83,7 +83,7 @@ class Test_Encryption_Crypt extends \OCA\Files_Encryption\Tests\TestCase { public static function tearDownAfterClass() { // cleanup test user - \OC_User::deleteUser(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1); + \OC_User::deleteUser(self::TEST_ENCRYPTION_CRYPT_USER1); parent::tearDownAfterClass(); } diff --git a/apps/files_encryption/tests/helper.php b/apps/files_encryption/tests/helper.php index a767861187..32a962f7a3 100644 --- a/apps/files_encryption/tests/helper.php +++ b/apps/files_encryption/tests/helper.php @@ -18,14 +18,14 @@ class Test_Encryption_Helper extends \OCA\Files_Encryption\Tests\TestCase { protected function setUpUsers() { // create test user - self::loginHelper(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2, true); - self::loginHelper(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1, true); + self::loginHelper(self::TEST_ENCRYPTION_HELPER_USER2, true); + self::loginHelper(self::TEST_ENCRYPTION_HELPER_USER1, true); } protected function cleanUpUsers() { // cleanup test user - \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1); - \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2); + \OC_User::deleteUser(self::TEST_ENCRYPTION_HELPER_USER1); + \OC_User::deleteUser(self::TEST_ENCRYPTION_HELPER_USER2); } public static function setupHooks() { @@ -113,7 +113,7 @@ class Test_Encryption_Helper extends \OCA\Files_Encryption\Tests\TestCase { $this->assertFalse(Helper::getUser($path4)); // Log-in again - self::loginHelper(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1); + self::loginHelper(self::TEST_ENCRYPTION_HELPER_USER1); self::cleanUpUsers(); } diff --git a/apps/files_encryption/tests/hooks.php b/apps/files_encryption/tests/hooks.php index b4a28dd24a..dc347d1adc 100644 --- a/apps/files_encryption/tests/hooks.php +++ b/apps/files_encryption/tests/hooks.php @@ -66,20 +66,20 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { ); // create test user - self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true); - self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true); + self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER1, true); + self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER2, true); } protected function setUp() { parent::setUp(); // set user id - self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1); - \OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1); + self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER1); + \OC_User::setUserId(self::TEST_ENCRYPTION_HOOKS_USER1); // init filesystem view - $this->user1View = new \OC\Files\View('/'. \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1 . '/files'); - $this->user2View = new \OC\Files\View('/'. \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '/files'); + $this->user1View = new \OC\Files\View('/'. self::TEST_ENCRYPTION_HOOKS_USER1 . '/files'); + $this->user2View = new \OC\Files\View('/'. self::TEST_ENCRYPTION_HOOKS_USER2 . '/files'); $this->rootView = new \OC\Files\View('/'); // init short data @@ -91,8 +91,8 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { public static function tearDownAfterClass() { // cleanup test user - \OC_User::deleteUser(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1); - \OC_User::deleteUser(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2); + \OC_User::deleteUser(self::TEST_ENCRYPTION_HOOKS_USER1); + \OC_User::deleteUser(self::TEST_ENCRYPTION_HOOKS_USER2); parent::tearDownAfterClass(); } @@ -136,14 +136,14 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { // check if all keys are generated $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey')); $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/fileKey')); self::logoutHelper(); - self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2); - \OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2); + self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER2); + \OC_User::setUserId(self::TEST_ENCRYPTION_HOOKS_USER2); $this->user2View->file_put_contents($this->filename, $this->data); @@ -151,7 +151,7 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { // check if all keys are generated $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' . $this->filename . '/fileKey')); @@ -166,7 +166,7 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { // all keys should still exist $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' . $this->filename . '/fileKey')); @@ -178,14 +178,14 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { // check if keys from user2 are really deleted $this->assertFalse($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); $this->assertFalse($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' . $this->filename . '/fileKey')); // but user1 keys should still exist $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey')); $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/fileKey')); @@ -200,8 +200,8 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { function testDeleteHooksForSharedFiles() { self::logoutHelper(); - self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1); - \OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1); + self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER1); + \OC_User::setUserId(self::TEST_ENCRYPTION_HOOKS_USER1); // remember files_trashbin state $stateFilesTrashbin = OC_App::isEnabled('files_trashbin'); @@ -217,7 +217,7 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { // check if all keys are generated $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey')); $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/fileKey')); @@ -233,11 +233,11 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { // check if new share key exists $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); self::logoutHelper(); - self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2); - \OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2); + self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER2); + \OC_User::setUserId(self::TEST_ENCRYPTION_HOOKS_USER2); // user2 update the shared file $this->user2View->file_put_contents($this->filename, $this->data); @@ -245,7 +245,7 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { // keys should be stored at user1s dir, not in user2s $this->assertFalse($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); $this->assertFalse($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER2 . '/files_encryption/keys/' . $this->filename . '/fileKey')); @@ -257,18 +257,18 @@ class Test_Encryption_Hooks extends \OCA\Files_Encryption\Tests\TestCase { // share key for user2 from user1s home should be gone, all other keys should still exists $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey')); $this->assertFalse($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_HOOKS_USER2 . '.shareKey')); $this->assertTrue($this->rootView->file_exists( self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keys/' . $this->filename . '/fileKey')); // cleanup self::logoutHelper(); - self::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1); - \OC_User::setUserId(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1); + self::loginHelper(self::TEST_ENCRYPTION_HOOKS_USER1); + \OC_User::setUserId(self::TEST_ENCRYPTION_HOOKS_USER1); if ($stateFilesTrashbin) { OC_App::enable('files_trashbin'); diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php index f10940e441..b0f0abce13 100644 --- a/apps/files_encryption/tests/keymanager.php +++ b/apps/files_encryption/tests/keymanager.php @@ -40,8 +40,8 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase { \OC_App::disable('files_trashbin'); // create test user - \OC_User::deleteUser(\Test_Encryption_Keymanager::TEST_USER); - parent::loginHelper(\Test_Encryption_Keymanager::TEST_USER, true); + \OC_User::deleteUser(self::TEST_USER); + parent::loginHelper(self::TEST_USER, true); } protected function setUp() { @@ -60,16 +60,16 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase { $this->view = new \OC\Files\View('/'); - self::loginHelper(Test_Encryption_Keymanager::TEST_USER); - $this->userId = \Test_Encryption_Keymanager::TEST_USER; - $this->pass = \Test_Encryption_Keymanager::TEST_USER; + self::loginHelper(self::TEST_USER); + $this->userId = self::TEST_USER; + $this->pass = self::TEST_USER; $userHome = \OC_User::getHome($this->userId); $this->dataDir = str_replace('/' . $this->userId, '', $userHome); } function tearDown() { - $this->view->deleteAll('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys'); + $this->view->deleteAll('/' . self::TEST_USER . '/files_encryption/keys'); parent::tearDown(); } @@ -77,7 +77,7 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase { \OC_FileProxy::$enabled = true; // cleanup test user - \OC_User::deleteUser(\Test_Encryption_Keymanager::TEST_USER); + \OC_User::deleteUser(self::TEST_USER); // reset app files_trashbin if (self::$stateFilesTrashbin) { OC_App::enable('files_trashbin'); @@ -217,85 +217,85 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase { */ function testRecursiveDelShareKeysFolder() { - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files/folder1'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files/folder1/existingFile.txt', 'data'); + $this->view->mkdir('/' . self::TEST_USER . '/files/folder1'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files/folder1/existingFile.txt', 'data'); // create folder structure for some dummy share key files - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1'); - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/existingFile.txt'); - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1'); - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file2'); - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder'); - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/file2'); - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/subsubfolder'); - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/subsubfolder/file1'); - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/subsubfolder/file2'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/keys/folder1'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/keys/folder1/existingFile.txt'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/keys/folder1/file1'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/keys/folder1/file2'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/file2'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/subsubfolder'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/subsubfolder/file1'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/subsubfolder/file2'); // create some dummy share keys - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/existingFile.txt/user1.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/existingFile.txt/' . Test_Encryption_Keymanager::TEST_USER . '.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/user1.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/user1.test.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/test-keymanager-userxdot.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/userx.' . Test_Encryption_Keymanager::TEST_USER . '.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/' . Test_Encryption_Keymanager::TEST_USER . '.userx.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/user1.' . Test_Encryption_Keymanager::TEST_USER . '.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/' . Test_Encryption_Keymanager::TEST_USER . '.user1.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file2/user2.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file2/user3.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/file2/user3.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/subsubfolder/file1/user1.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/subsubfolder/file2/user2.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/subsubfolder/file2/user3.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/existingFile.txt/user1.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/existingFile.txt/' . self::TEST_USER . '.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/user1.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/user1.test.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/test-keymanager-userxdot.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/userx.' . self::TEST_USER . '.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/' . self::TEST_USER . '.userx.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/user1.' . self::TEST_USER . '.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/' . self::TEST_USER . '.user1.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/file2/user2.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/file2/user3.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/file2/user3.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/subsubfolder/file1/user1.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/subsubfolder/file2/user2.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/subsubfolder/file2/user3.shareKey', 'data'); // recursive delete share keys from user1 and user2 Keymanager::delShareKey($this->view, - array('user1', 'user2', Test_Encryption_Keymanager::TEST_USER), - Keymanager::getKeyPath($this->view, new Util($this->view, Test_Encryption_Keymanager::TEST_USER), '/folder1'), - Test_Encryption_Keymanager::TEST_USER, + array('user1', 'user2', self::TEST_USER), + Keymanager::getKeyPath($this->view, new Util($this->view, self::TEST_USER), '/folder1'), + self::TEST_USER, '/folder1'); // check if share keys from user1 and user2 are deleted $this->assertFalse($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/existingFile.txt/user1.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/existingFile.txt/user1.shareKey')); $this->assertFalse($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/file1/user1.shareKey')); + '/' . self::TEST_USER . '/files_encryption/share-keys/folder1/file1/user1.shareKey')); $this->assertFalse($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/file2/user2.shareKey')); + '/' . self::TEST_USER . '/files_encryption/share-keys/folder1/file2/user2.shareKey')); $this->assertFalse($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/subfolder/subsubfolder/file1/user1.shareKey')); + '/' . self::TEST_USER . '/files_encryption/share-keys/folder1/subfolder/subsubfolder/file1/user1.shareKey')); $this->assertFalse($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/subfolder/subsubfolder/file2/user2.shareKey')); + '/' . self::TEST_USER . '/files_encryption/share-keys/folder1/subfolder/subsubfolder/file2/user2.shareKey')); // check if share keys from user3 still exists $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file2/user3.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/file2/user3.shareKey')); $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/subsubfolder/file2/user3.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/subsubfolder/file2/user3.shareKey')); $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/subfolder/file2/user3.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/subfolder/file2/user3.shareKey')); // check if share keys for user or file with similar name $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/user1.test.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/user1.test.shareKey')); $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/test-keymanager-userxdot.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/test-keymanager-userxdot.shareKey')); $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/' . Test_Encryption_Keymanager::TEST_USER . '.userx.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/' . self::TEST_USER . '.userx.shareKey')); // FIXME: this case currently cannot be distinguished, needs further fixing $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/userx.' . Test_Encryption_Keymanager::TEST_USER . '.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/userx.' . self::TEST_USER . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/user1.' . Test_Encryption_Keymanager::TEST_USER . '.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/user1.' . self::TEST_USER . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/file1/' . Test_Encryption_Keymanager::TEST_USER . '.user1.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/file1/' . self::TEST_USER . '.user1.shareKey')); // owner key from existing file should still exists because the file is still there $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/keys/folder1/existingFile.txt/' . Test_Encryption_Keymanager::TEST_USER . '.shareKey')); + '/' . self::TEST_USER . '/files_encryption/keys/folder1/existingFile.txt/' . self::TEST_USER . '.shareKey')); // cleanup - $this->view->deleteAll('/'.Test_Encryption_Keymanager::TEST_USER.'/files/folder1'); + $this->view->deleteAll('/' . self::TEST_USER . '/files/folder1'); } @@ -304,44 +304,44 @@ class Test_Encryption_Keymanager extends \OCA\Files_Encryption\Tests\TestCase { */ function testRecursiveDelShareKeysFile() { - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files/folder1'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files/folder1/existingFile.txt', 'data'); + $this->view->mkdir('/' . self::TEST_USER . '/files/folder1'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files/folder1/existingFile.txt', 'data'); // create folder structure for some dummy share key files - $this->view->mkdir('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1'); + $this->view->mkdir('/' . self::TEST_USER . '/files_encryption/share-keys/folder1'); // create some dummy share keys - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.txt.user1.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.txt.user2.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.txt.user3.shareKey', 'data'); - $this->view->file_put_contents('/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.txt.' . Test_Encryption_Keymanager::TEST_USER . '.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/share-keys/folder1/existingFile.txt.user1.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/share-keys/folder1/existingFile.txt.user2.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/share-keys/folder1/existingFile.txt.user3.shareKey', 'data'); + $this->view->file_put_contents('/' . self::TEST_USER . '/files_encryption/share-keys/folder1/existingFile.txt.' . self::TEST_USER . '.shareKey', 'data'); // recursive delete share keys from user1 and user2 Keymanager::delShareKey($this->view, - array('user1', 'user2', Test_Encryption_Keymanager::TEST_USER), - Keymanager::getKeyPath($this->view, new Util($this->view, Test_Encryption_Keymanager::TEST_USER), '/folder1/existingFile.txt'), - Test_Encryption_Keymanager::TEST_USER, + array('user1', 'user2', self::TEST_USER), + Keymanager::getKeyPath($this->view, new Util($this->view, self::TEST_USER), '/folder1/existingFile.txt'), + self::TEST_USER, '/folder1/existingFile.txt'); // check if share keys from user1 and user2 are deleted $this->assertFalse($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.user1.shareKey')); + '/' . self::TEST_USER . '/files_encryption/share-keys/folder1/existingFile.user1.shareKey')); $this->assertFalse($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.user2.shareKey')); + '/' . self::TEST_USER . '/files_encryption/share-keys/folder1/existingFile.user2.shareKey')); // check if share keys for user3 and owner $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.txt.' . Test_Encryption_Keymanager::TEST_USER . '.shareKey')); + '/' . self::TEST_USER . '/files_encryption/share-keys/folder1/existingFile.txt.' . self::TEST_USER . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/'.Test_Encryption_Keymanager::TEST_USER.'/files_encryption/share-keys/folder1/existingFile.txt.user3.shareKey')); + '/' . self::TEST_USER . '/files_encryption/share-keys/folder1/existingFile.txt.user3.shareKey')); // cleanup - $this->view->deleteAll('/'.Test_Encryption_Keymanager::TEST_USER.'/files/folder1'); + $this->view->deleteAll('/' . self::TEST_USER . '/files/folder1'); } function testKeySetPreperation() { - $basePath = '/'.Test_Encryption_Keymanager::TEST_USER.'/files'; + $basePath = '/' . self::TEST_USER . '/files'; $path = '/folder1/subfolder/subsubfolder/file.txt'; $this->assertFalse($this->view->is_dir($basePath . '/testKeySetPreperation')); diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php index 3cc668e636..72f223123e 100644 --- a/apps/files_encryption/tests/proxy.php +++ b/apps/files_encryption/tests/proxy.php @@ -43,20 +43,20 @@ class Test_Encryption_Proxy extends \OCA\Files_Encryption\Tests\TestCase { parent::setUpBeforeClass(); // create test user - self::loginHelper(\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1, true); + self::loginHelper(self::TEST_ENCRYPTION_PROXY_USER1, true); } protected function setUp() { parent::setUp(); // set user id - \OC_User::setUserId(\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1); - $this->userId = \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1; - $this->pass = \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1; + \OC_User::setUserId(self::TEST_ENCRYPTION_PROXY_USER1); + $this->userId = self::TEST_ENCRYPTION_PROXY_USER1; + $this->pass = self::TEST_ENCRYPTION_PROXY_USER1; // init filesystem view - $this->view = new \OC\Files\View('/'. \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files'); - $this->rootView = new \OC\Files\View('/'. \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 ); + $this->view = new \OC\Files\View('/'. self::TEST_ENCRYPTION_PROXY_USER1 . '/files'); + $this->rootView = new \OC\Files\View('/'. self::TEST_ENCRYPTION_PROXY_USER1 ); // init short data $this->data = 'hats'; @@ -67,7 +67,7 @@ class Test_Encryption_Proxy extends \OCA\Files_Encryption\Tests\TestCase { public static function tearDownAfterClass() { // cleanup test user - \OC_User::deleteUser(\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1); + \OC_User::deleteUser(self::TEST_ENCRYPTION_PROXY_USER1); parent::tearDownAfterClass(); } @@ -135,13 +135,13 @@ class Test_Encryption_Proxy extends \OCA\Files_Encryption\Tests\TestCase { public function isExcludedPathProvider() { return array( - array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files/test.txt', false), - array (\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files/test.txt', false), + array ('/' . self::TEST_ENCRYPTION_PROXY_USER1 . '/files/test.txt', false), + array (self::TEST_ENCRYPTION_PROXY_USER1 . '/files/test.txt', false), array ('/files/test.txt', true), - array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files/versions/test.txt', false), - array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files_versions/test.txt', false), - array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files_trashbin/test.txt', true), - array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/file/test.txt', true), + array ('/' . self::TEST_ENCRYPTION_PROXY_USER1 . '/files/versions/test.txt', false), + array ('/' . self::TEST_ENCRYPTION_PROXY_USER1 . '/files_versions/test.txt', false), + array ('/' . self::TEST_ENCRYPTION_PROXY_USER1 . '/files_trashbin/test.txt', true), + array ('/' . self::TEST_ENCRYPTION_PROXY_USER1 . '/file/test.txt', true), ); } diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php index 0eaff6bf87..3dd7dadcb4 100755 --- a/apps/files_encryption/tests/share.php +++ b/apps/files_encryption/tests/share.php @@ -61,15 +61,15 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \OC_FileProxy::register(new OCA\Files\Share\Proxy()); // create users - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true); - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true); - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true); - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1, true); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2, true); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER3, true); + self::loginHelper(self::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); + \OC_Group::createGroup(self::TEST_ENCRYPTION_SHARE_GROUP1); + \OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER3, self::TEST_ENCRYPTION_SHARE_GROUP1); + \OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER4, self::TEST_ENCRYPTION_SHARE_GROUP1); } protected function setUp() { @@ -91,7 +91,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \OC_App::disable('files_trashbin'); // login as first user - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); } protected function tearDown() { @@ -107,13 +107,13 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { public static function tearDownAfterClass() { // clean group - \OC_Group::deleteGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); + \OC_Group::deleteGroup(self::TEST_ENCRYPTION_SHARE_GROUP1); // cleanup users - \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); - \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); - \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); - \OC_User::deleteUser(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4); + \OC_User::deleteUser(self::TEST_ENCRYPTION_SHARE_USER1); + \OC_User::deleteUser(self::TEST_ENCRYPTION_SHARE_USER2); + \OC_User::deleteUser(self::TEST_ENCRYPTION_SHARE_USER3); + \OC_User::deleteUser(self::TEST_ENCRYPTION_SHARE_USER4); parent::tearDownAfterClass(); } @@ -125,10 +125,10 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { */ function testShareFile($withTeardown = true) { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // save file with content - $cryptedFile = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); + $cryptedFile = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); // test that data was successfully written $this->assertTrue(is_int($cryptedFile)); @@ -139,7 +139,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // get the file info from previous created file $fileInfo = $this->view->getFileInfo( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); @@ -151,22 +151,22 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \OC_FileProxy::$enabled = $proxyStatus; // share the file - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user1 exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // login as user1 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2); // get file contents $retrievedCryptedFile = $this->view->file_get_contents( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename); // check if data is the same as we previously written $this->assertEquals($this->dataShort, $retrievedCryptedFile); @@ -175,25 +175,25 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { if ($withTeardown) { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // unshare the file - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // cleanup - $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); + $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); $this->view->unlink($this->filename); $this->view->chroot('/'); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } } @@ -205,29 +205,29 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $this->testShareFile(false); // login as user2 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2); // get the file info $fileInfo = $this->view->getFileInfo( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename); // share the file with user3 - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER3, \OCP\Constants::PERMISSION_ALL); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user2 exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // login as user2 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER3); // get file contents $retrievedCryptedFile = $this->view->file_get_contents( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->filename); // check if data is the same as previously written $this->assertEquals($this->dataShort, $retrievedCryptedFile); @@ -236,36 +236,36 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { if ($withTeardown) { // login as user1 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2); // unshare the file with user2 - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER3); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // unshare the file with user1 - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // cleanup - $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); + $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); $this->view->unlink($this->filename); $this->view->chroot('/'); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } } @@ -276,18 +276,18 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { */ function testShareFolder($withTeardown = true) { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // create folder structure - $this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); + $this->view->mkdir('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); $this->view->mkdir( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder); $this->view->mkdir( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder . $this->subsubfolder); // save file with content - $cryptedFile = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + $cryptedFile = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename, $this->dataShort); // test that data was successfully written @@ -299,7 +299,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // get the file info from previous created folder $fileInfo = $this->view->getFileInfo( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); // check if we have a valid file info $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); @@ -308,23 +308,23 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \OC_FileProxy::$enabled = $proxyStatus; // share the folder with user1 - \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user1 exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // login as user1 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2); // get file contents $retrievedCryptedFile = $this->view->file_get_contents( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename); // check if data is the same @@ -334,27 +334,27 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { if ($withTeardown) { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // unshare the folder with user1 - \OCP\Share::unshare('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + \OCP\Share::unshare('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // cleanup - $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files'); + $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files'); $this->view->unlink($this->folder1); $this->view->chroot('/'); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } return $fileInfo; @@ -368,7 +368,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $fileInfoFolder1 = $this->testShareFolder(false); // login as user2 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2); // disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; @@ -376,7 +376,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // get the file info from previous created folder $fileInfoSubFolder = $this->view->getFileInfo( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 . $this->subfolder); // check if we have a valid file info @@ -386,23 +386,23 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \OC_FileProxy::$enabled = $proxyStatus; // share the file with user3 - \OCP\Share::shareItem('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER3, \OCP\Constants::PERMISSION_ALL); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user3 exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // login as user3 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER3); // get file contents $retrievedCryptedFile = $this->view->file_get_contents( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->subfolder + '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->subfolder . $this->subsubfolder . '/' . $this->filename); // check if data is the same @@ -410,30 +410,30 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // get the file info $fileInfo = $this->view->getFileInfo( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->subfolder + '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->subfolder . $this->subsubfolder . '/' . $this->filename); // check if we have fileInfos $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // share the file with user3 - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER4, \OCP\Constants::PERMISSION_ALL); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user3 exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); // login as user3 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER4); // get file contents $retrievedCryptedFile = $this->view->file_get_contents( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER4 . '/files/' . $this->filename); // check if data is the same $this->assertEquals($this->dataShort, $retrievedCryptedFile); @@ -442,61 +442,61 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { if ($withTeardown) { // login as user2 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER3); // unshare the file with user3 - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER4); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); // login as user1 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2); // unshare the folder with user2 - \OCP\Share::unshare('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); + \OCP\Share::unshare('folder', $fileInfoSubFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER3); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // unshare the folder1 with user1 - \OCP\Share::unshare('folder', $fileInfoFolder1['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + \OCP\Share::unshare('folder', $fileInfoFolder1['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // cleanup - $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files'); + $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files'); $this->view->unlink($this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename); $this->view->chroot('/'); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } } function testPublicShareFile() { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // save file with content - $cryptedFile = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); + $cryptedFile = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); // test that data was successfully written $this->assertTrue(is_int($cryptedFile)); @@ -507,7 +507,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // get the file info from previous created file $fileInfo = $this->view->getFileInfo( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); @@ -522,22 +522,22 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, false, \OCP\Constants::PERMISSION_ALL); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); $publicShareKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'publicShareKeyId'); // check if share key for public exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->filename . '/' . $publicShareKeyId . '.shareKey')); // some hacking to simulate public link //$GLOBALS['app'] = 'files_sharing'; - //$GLOBALS['fileOwner'] = \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1; + //$GLOBALS['fileOwner'] = self::TEST_ENCRYPTION_SHARE_USER1; self::logoutHelper(); // get file contents - $retrievedCryptedFile = file_get_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); + $retrievedCryptedFile = file_get_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if data is the same as we previously written $this->assertEquals($this->dataShort, $retrievedCryptedFile); @@ -545,25 +545,25 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // tear down // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // unshare the file \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_LINK, null); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->filename . '/' . $publicShareKeyId . '.shareKey')); // cleanup - $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); + $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); $this->view->unlink($this->filename); $this->view->chroot('/'); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } /** @@ -571,10 +571,10 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { */ function testShareFileWithGroup() { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // save file with content - $cryptedFile = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); + $cryptedFile = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); // test that data was successfully written $this->assertTrue(is_int($cryptedFile)); @@ -585,7 +585,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // get the file info from previous created file $fileInfo = $this->view->getFileInfo( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); @@ -597,52 +597,52 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { \OC_FileProxy::$enabled = $proxyStatus; // share the file - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_ENCRYPTION_SHARE_GROUP1, \OCP\Constants::PERMISSION_ALL); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user2 and user3 exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); // login as user1 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER3); // get file contents $retrievedCryptedFile = $this->view->file_get_contents( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '/files/' . $this->filename); // check if data is the same as we previously written $this->assertEquals($this->dataShort, $retrievedCryptedFile); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // unshare the file - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_ENCRYPTION_SHARE_GROUP1); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER4 . '.shareKey')); // cleanup - $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); + $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); $this->view->unlink($this->filename); $this->view->chroot('/'); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); } @@ -652,15 +652,15 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { function testRecoveryFile() { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); Helper::adminEnableRecovery(null, 'test123'); $recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId'); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); - $util = new Util(new \OC\Files\View('/'), \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + $util = new Util(new \OC\Files\View('/'), self::TEST_ENCRYPTION_SHARE_USER1); // check if recovery password match $this->assertTrue($util->checkRecoveryPassword('test123')); @@ -670,16 +670,16 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $util->addRecoveryKeys(); // create folder structure - $this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); + $this->view->mkdir('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); $this->view->mkdir( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder); $this->view->mkdir( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1 . $this->subfolder . $this->subsubfolder); // save file with content - $cryptedFile1 = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); - $cryptedFile2 = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + $cryptedFile1 = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); + $cryptedFile2 = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename, $this->dataShort); // test that data was successfully written @@ -688,17 +688,17 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // check if share key for admin and recovery exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); @@ -710,10 +710,10 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // check if share key for recovery not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); @@ -725,25 +725,25 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // check if share key for admin and recovery exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); // cleanup - $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); + $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); $this->view->unlink($this->filename); $this->view->unlink($this->folder1); $this->view->chroot('/'); // check if share key for recovery not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); @@ -758,7 +758,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { function testRecoveryForUser() { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); $result = Helper::adminEnableRecovery(null, 'test123'); $this->assertTrue($result); @@ -766,9 +766,9 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId'); // login as user2 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2); - $util = new Util(new \OC\Files\View('/'), \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + $util = new Util(new \OC\Files\View('/'), self::TEST_ENCRYPTION_SHARE_USER2); // enable recovery for admin $this->assertTrue($util->setRecoveryForUser(1)); @@ -777,16 +777,16 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $util->addRecoveryKeys(); // create folder structure - $this->view->mkdir('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1); + $this->view->mkdir('/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1); $this->view->mkdir( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder); + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder); $this->view->mkdir( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder . $this->subsubfolder); // save file with content - $cryptedFile1 = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2. '/files/' . $this->filename, $this->dataShort); - $cryptedFile2 = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' + $cryptedFile1 = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER2. '/files/' . $this->filename, $this->dataShort); + $cryptedFile2 = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename, $this->dataShort); // test that data was successfully written @@ -795,61 +795,61 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // check if share key for user and recovery exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // change password - \OC_User::setPassword(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, 'test', 'test123'); - $params = array('uid' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, + \OC_User::setPassword(self::TEST_ENCRYPTION_SHARE_USER2, 'test', 'test123'); + $params = array('uid' => self::TEST_ENCRYPTION_SHARE_USER2, 'password' => 'test', 'recoveryPassword' => 'test123'); Hooks::setPassphrase($params); // login as user2 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, false, 'test'); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2, false, 'test'); // get file contents - $retrievedCryptedFile1 = file_get_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename); + $retrievedCryptedFile1 = file_get_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename); $retrievedCryptedFile2 = file_get_contents( - 'crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename); + 'crypt:///' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename); // check if data is the same as we previously written $this->assertEquals($this->dataShort, $retrievedCryptedFile1); $this->assertEquals($this->dataShort, $retrievedCryptedFile2); // cleanup - $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/'); + $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/'); $this->view->unlink($this->folder1); $this->view->unlink($this->filename); $this->view->chroot('/'); // check if share key for user and recovery exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->folder1 + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files_encryption/keys/' . $this->folder1 . $this->subfolder . $this->subsubfolder . '/' . $this->filename . '/' . $recoveryKeyId . '.shareKey')); @@ -860,9 +860,9 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $this->assertEquals(0, \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled')); //clean up, reset passwords - \OC_User::setPassword(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, 'test123'); - $params = array('uid' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, - 'password' => \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, + \OC_User::setPassword(self::TEST_ENCRYPTION_SHARE_USER2, self::TEST_ENCRYPTION_SHARE_USER2, 'test123'); + $params = array('uid' => self::TEST_ENCRYPTION_SHARE_USER2, + 'password' => self::TEST_ENCRYPTION_SHARE_USER2, 'recoveryPassword' => 'test123'); Hooks::setPassphrase($params); } @@ -872,10 +872,10 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { */ function testFailShareFile() { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // save file with content - $cryptedFile = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); + $cryptedFile = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); // test that data was successfully written $this->assertTrue(is_int($cryptedFile)); @@ -886,7 +886,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // get the file info from previous created file $fileInfo = $this->view->getFileInfo( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); @@ -895,27 +895,27 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $this->assertGreaterThan(0, $fileInfo['unencrypted_size']); // break users public key - $this->view->rename(Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey', - Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup'); + $this->view->rename(Keymanager::getPublicKeyPath() . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey', + Keymanager::getPublicKeyPath() . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup'); // re-enable the file proxy \OC_FileProxy::$enabled = $proxyStatus; // share the file try { - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_ENCRYPTION_SHARE_GROUP1, \OCP\Constants::PERMISSION_ALL); } catch (Exception $e) { $this->assertEquals(0, strpos($e->getMessage(), "Following users are not set up for encryption")); } // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // check if share key for user1 not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; @@ -923,27 +923,27 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { // break user1 public key $this->view->rename( - Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup', - Keymanager::getPublicKeyPath() . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey'); + Keymanager::getPublicKeyPath() . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup', + Keymanager::getPublicKeyPath() . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey'); // remove share file - $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 + $this->view->unlink('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey'); // re-enable the file proxy \OC_FileProxy::$enabled = $proxyStatus; // unshare the file with user1 - \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1); + \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_ENCRYPTION_SHARE_GROUP1); // check if share key not exists $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey')); // cleanup - $this->view->chroot('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); + $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/'); $this->view->unlink($this->filename); $this->view->chroot('/'); } @@ -955,56 +955,56 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { function testRename() { // login as admin - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // save file with content - $cryptedFile = file_put_contents('crypt:///' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); + $cryptedFile = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort); // test that data was successfully written $this->assertTrue(is_int($cryptedFile)); // get the file info from previous created file $fileInfo = $this->view->getFileInfo( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // share the file - \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); // check if share key for user2 exists $this->assertTrue($this->view->file_exists( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' - . $this->filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' + . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // login as user2 - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2); - $this->assertTrue($this->view->file_exists('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename)); + $this->assertTrue($this->view->file_exists('/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename)); // get file contents $retrievedCryptedFile = $this->view->file_get_contents( - '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename); + '/' . self::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 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); + $this->view->rename('/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->filename, + '/' . self::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->folder1 . $this->filename); + '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '/files/' . $this->folder1 . $this->filename); // check if data is the same as we previously written $this->assertEquals($this->dataShort, $retrievedRenamedFile); // cleanup - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); - $this->view->unlink('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); + $this->view->unlink('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); } /** @@ -1013,7 +1013,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { */ function testMoveFolder() { - $view = new \OC\Files\View('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + $view = new \OC\Files\View('/' . self::TEST_ENCRYPTION_SHARE_USER1); $filename = '/tmp-' . $this->getUniqueID(); $folder = '/folder' . $this->getUniqueID(); @@ -1039,7 +1039,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // share the folder - \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); \OC\Files\Filesystem::rename($folder, $newFolder); @@ -1048,10 +1048,10 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $this->assertEquals($this->dataShort, $newDecrypt); // check if additional share key for user2 exists - $this->assertTrue($view->file_exists('files_encryption/keys' . $newFolder . '/' . $filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + $this->assertTrue($view->file_exists('files_encryption/keys' . $newFolder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // check that old keys were removed/moved properly - $this->assertFalse($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + $this->assertFalse($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // tear down \OC\Files\Filesystem::unlink($newFolder); @@ -1061,9 +1061,9 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { function usersProvider() { return array( // test as owner - array(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1), + array(self::TEST_ENCRYPTION_SHARE_USER1), // test as share receiver - array(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2), + array(self::TEST_ENCRYPTION_SHARE_USER2), ); } @@ -1071,7 +1071,7 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { * @dataProvider usersProvider */ function testMoveFileToFolder($userId) { - $view = new \OC\Files\View('/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + $view = new \OC\Files\View('/' . self::TEST_ENCRYPTION_SHARE_USER1); $filename = '/tmp-' . $this->getUniqueID(); $folder = '/folder' . $this->getUniqueID(); @@ -1097,28 +1097,28 @@ class Test_Encryption_Share extends \OCA\Files_Encryption\Tests\TestCase { $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // share the folder - \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); + \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_SHARE_USER2, \OCP\Constants::PERMISSION_ALL); // check that the share keys exist - $this->assertTrue($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); - $this->assertTrue($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + $this->assertTrue($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + $this->assertTrue($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // move the file into the subfolder as the test user self::loginHelper($userId); \OC\Files\Filesystem::rename($folder . $filename, $subFolder . $filename); - self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); + self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1); // Get file decrypted contents $newDecrypt = \OC\Files\Filesystem::file_get_contents($subFolder . $filename); $this->assertEquals($this->dataShort, $newDecrypt); // check if additional share key for user2 exists - $this->assertTrue($view->file_exists('files_encryption/keys' . $subFolder . '/' . $filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); - $this->assertTrue($view->file_exists('files_encryption/keys' . $subFolder . '/' . $filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + $this->assertTrue($view->file_exists('files_encryption/keys' . $subFolder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + $this->assertTrue($view->file_exists('files_encryption/keys' . $subFolder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // check that old keys were removed/moved properly - $this->assertFalse($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); - $this->assertFalse($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); + $this->assertFalse($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER1 . '.shareKey')); + $this->assertFalse($view->file_exists('files_encryption/keys' . $folder . '/' . $filename . '/' . self::TEST_ENCRYPTION_SHARE_USER2 . '.shareKey')); // tear down \OC\Files\Filesystem::unlink($subFolder); diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php index 08d4ddcf5b..7afe8a8850 100644 --- a/apps/files_encryption/tests/stream.php +++ b/apps/files_encryption/tests/stream.php @@ -41,16 +41,16 @@ class Test_Encryption_Stream extends \OCA\Files_Encryption\Tests\TestCase { parent::setUpBeforeClass(); // create test user - self::loginHelper(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1, true); + self::loginHelper(self::TEST_ENCRYPTION_STREAM_USER1, true); } protected function setUp() { parent::setUp(); // set user id - \OC_User::setUserId(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1); - $this->userId = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1; - $this->pass = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1; + \OC_User::setUserId(self::TEST_ENCRYPTION_STREAM_USER1); + $this->userId = self::TEST_ENCRYPTION_STREAM_USER1; + $this->pass = self::TEST_ENCRYPTION_STREAM_USER1; // init filesystem view $this->view = new \OC\Files\View('/'); @@ -79,7 +79,7 @@ class Test_Encryption_Stream extends \OCA\Files_Encryption\Tests\TestCase { public static function tearDownAfterClass() { // cleanup test user - \OC_User::deleteUser(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1); + \OC_User::deleteUser(self::TEST_ENCRYPTION_STREAM_USER1); parent::tearDownAfterClass(); } diff --git a/apps/files_encryption/tests/trashbin.php b/apps/files_encryption/tests/trashbin.php index d8af31760e..9b2d3039f9 100755 --- a/apps/files_encryption/tests/trashbin.php +++ b/apps/files_encryption/tests/trashbin.php @@ -171,7 +171,7 @@ class Test_Encryption_Trashbin extends \OCA\Files_Encryption\Tests\TestCase { // check if we found the file we created $this->assertNotNull($trashFileSuffix); - $this->assertTrue($this->view->is_dir('/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keys/' . $filename . '.' . $trashFileSuffix)); + $this->assertTrue($this->view->is_dir('/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keys/' . $filename . '.' . $trashFileSuffix)); // check if key for admin not exists $this->assertTrue($this->view->file_exists( @@ -217,10 +217,10 @@ class Test_Encryption_Trashbin extends \OCA\Files_Encryption\Tests\TestCase { // before calling the restore operation the keys shouldn't be there $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' . $filename . '/fileKey')); + '/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' . $filename . '/fileKey')); $this->assertFalse($this->view->file_exists( - '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' - . $filename . '/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey')); + '/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keys/' + . $filename . '/' . self::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey')); // restore first file $this->assertTrue(\OCA\Files_Trashbin\Trashbin::restore($filename . '.' . $trashFileSuffix, $filename, $timestamp)); diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php index 8496772a13..9d8b45213d 100755 --- a/apps/files_encryption/tests/util.php +++ b/apps/files_encryption/tests/util.php @@ -553,13 +553,13 @@ class Test_Encryption_Util extends \OCA\Files_Encryption\Tests\TestCase { $publicShareKeyId, $recoveryKeyId, ); - \Test_Encryption_Util::loginHelper('readyUser', true); - \Test_Encryption_Util::loginHelper('notReadyUser', true); + self::loginHelper('readyUser', true); + self::loginHelper('notReadyUser', true); // delete encryption dir to make it not ready $this->view->unlink('notReadyUser/files_encryption/'); // login as user1 - \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1); + self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1); $result = $this->util->filterShareReadyUsers($usersToTest); $this->assertEquals( diff --git a/apps/files_encryption/tests/webdav.php b/apps/files_encryption/tests/webdav.php index e3c92a4333..d32cb628f8 100755 --- a/apps/files_encryption/tests/webdav.php +++ b/apps/files_encryption/tests/webdav.php @@ -46,7 +46,7 @@ class Test_Encryption_Webdav extends \OCA\Files_Encryption\Tests\TestCase { parent::setUpBeforeClass(); // create test user - self::loginHelper(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1, true); + self::loginHelper(self::TEST_ENCRYPTION_WEBDAV_USER1, true); } @@ -57,9 +57,9 @@ class Test_Encryption_Webdav extends \OCA\Files_Encryption\Tests\TestCase { \OC_User::useBackend('database'); // set user id - \OC_User::setUserId(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1); - $this->userId = \Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1; - $this->pass = \Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1; + \OC_User::setUserId(self::TEST_ENCRYPTION_WEBDAV_USER1); + $this->userId = self::TEST_ENCRYPTION_WEBDAV_USER1; + $this->pass = self::TEST_ENCRYPTION_WEBDAV_USER1; // init filesystem view $this->view = new \OC\Files\View('/'); @@ -74,7 +74,7 @@ class Test_Encryption_Webdav extends \OCA\Files_Encryption\Tests\TestCase { \OC_App::disable('files_trashbin'); // create test user - self::loginHelper(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1); + self::loginHelper(self::TEST_ENCRYPTION_WEBDAV_USER1); } protected function tearDown() { @@ -90,7 +90,7 @@ class Test_Encryption_Webdav extends \OCA\Files_Encryption\Tests\TestCase { public static function tearDownAfterClass() { // cleanup test user - \OC_User::deleteUser(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1); + \OC_User::deleteUser(self::TEST_ENCRYPTION_WEBDAV_USER1); parent::tearDownAfterClass(); }