summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/tests/util.php
diff options
context:
space:
mode:
authorFlorin Peter <github@florin-peter.de>2013-05-22 00:55:16 +0200
committerFlorin Peter <github@florin-peter.de>2013-05-22 01:11:55 +0200
commitafbfa742d7848089523262f5c234035db1b20d3b (patch)
tree5856a08428df91068cfcd2f3f7600718880eef3e /apps/files_encryption/tests/util.php
parent9ca9a22c6a6495e657290195c97282aee8976282 (diff)
downloadnextcloud-server-afbfa742d7848089523262f5c234035db1b20d3b.tar.gz
nextcloud-server-afbfa742d7848089523262f5c234035db1b20d3b.zip
improved tests
Diffstat (limited to 'apps/files_encryption/tests/util.php')
-rwxr-xr-xapps/files_encryption/tests/util.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index 667ee24f04a..a2be8a40417 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -217,4 +217,61 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
$this->assertEquals($file, $filename);
}
+
+ function testIsSharedPath() {
+ $sharedPath = '/user1/files/Shared/test';
+ $path = '/user1/files/test';
+
+ $this->assertTrue($this->util->isSharedPath($sharedPath));
+
+ $this->assertFalse($this->util->isSharedPath($path));
+ }
+
+ function testEncryptLagacyFiles()
+ {
+ $userView = new \OC_FilesystemView( '/' . $this->userId);
+ $view = new \OC_FilesystemView( '/' . $this->userId . '/files' );
+
+ // Disable encryption proxy to prevent recursive calls
+ $proxyStatus = \OC_FileProxy::$enabled;
+ \OC_FileProxy::$enabled = false;
+
+ $encryptionKeyContent = file_get_contents($this->legacyEncryptedDataKey);
+ $userView->file_put_contents('/encryption.key', $encryptionKeyContent);
+
+ $legacyEncryptedData = file_get_contents($this->legacyEncryptedData);
+ $view->mkdir('/test/');
+ $view->mkdir('/test/subtest/');
+ $view->file_put_contents('/test/subtest/legacy-encrypted-text.txt', $legacyEncryptedData);
+
+ $fileInfo = $view->getFileInfo('/test/subtest/legacy-encrypted-text.txt');
+ $fileInfo['encrypted'] = true;
+ $view->putFileInfo('/test/subtest/legacy-encrypted-text.txt', $fileInfo);
+
+ \OC_FileProxy::$enabled = $proxyStatus;
+
+ $params['uid'] = $this->userId;
+ $params['password'] = $this->pass;
+
+ $util = new Encryption\Util($this->view, $this->userId);
+ $util->setMigrationStatus(0);
+
+ $this->assertTrue(OCA\Encryption\Hooks::login($params));
+
+ $this->assertEquals($this->lagacyKey, $_SESSION['legacyKey']);
+
+ $files = $util->findEncFiles('/' . $this->userId . '/files/');
+
+ $this->assertTrue(is_array($files));
+
+ $found = false;
+ foreach($files['encrypted'] as $encryptedFile) {
+ if($encryptedFile['name'] === 'legacy-encrypted-text.txt') {
+ $found = true;
+ break;
+ }
+ }
+
+ $this->assertTrue($found);
+ }
} \ No newline at end of file