aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-09-19 16:40:19 +0200
committerLukas Reschke <lukas@owncloud.com>2014-09-19 16:40:19 +0200
commitfb033cce980ba58b64eed0cd0882c31021f43df0 (patch)
tree7dc40e73fb8bf0ede1746b18b001ef8cb36bc753 /apps/files_encryption/tests
parente94ec409aea074add6b1402b899ad549c1d3db7f (diff)
parenta280859bf888b0573e24f47b335ba3d65b9212ae (diff)
downloadnextcloud-server-fb033cce980ba58b64eed0cd0882c31021f43df0.tar.gz
nextcloud-server-fb033cce980ba58b64eed0cd0882c31021f43df0.zip
Merge pull request #11104 from owncloud/enc_create_backup_on_recovery
[encryption] create backup from all keys before recovery
Diffstat (limited to 'apps/files_encryption/tests')
-rwxr-xr-xapps/files_encryption/tests/util.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index f337eb46355..f2db21be4c2 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -398,6 +398,48 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
}
+ /**
+ * test if all keys get moved to the backup folder correctly
+ */
+ function testBackupAllKeys() {
+ self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1);
+
+ // create some dummy key files
+ $encPath = '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '/files_encryption';
+ $this->view->file_put_contents($encPath . '/keyfiles/foo.key', 'key');
+ $this->view->file_put_contents($encPath . '/share-keys/foo.user1.shareKey', 'share key');
+
+ $util = new \OCA\Encryption\Util($this->view, self::TEST_ENCRYPTION_UTIL_USER1);
+
+ $util->backupAllKeys('testing');
+
+ $encFolderContent = $this->view->getDirectoryContent($encPath);
+
+ $backupPath = '';
+ foreach ($encFolderContent as $c) {
+ $name = $c['name'];
+ if (substr($name, 0, strlen('backup')) === 'backup') {
+ $backupPath = $encPath . '/'. $c['name'];
+ break;
+ }
+ }
+
+ $this->assertTrue($backupPath !== '');
+
+ // check backupDir Content
+ $this->assertTrue($this->view->is_dir($backupPath . '/keyfiles'));
+ $this->assertTrue($this->view->is_dir($backupPath . '/share-keys'));
+ $this->assertTrue($this->view->file_exists($backupPath . '/keyfiles/foo.key'));
+ $this->assertTrue($this->view->file_exists($backupPath . '/share-keys/foo.user1.shareKey'));
+ $this->assertTrue($this->view->file_exists($backupPath . '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '.private.key'));
+ $this->assertTrue($this->view->file_exists($backupPath . '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '.public.key'));
+
+ //cleanup
+ $this->view->deleteAll($backupPath);
+ $this->view->unlink($encPath . '/keyfiles/foo.key', 'key');
+ $this->view->unlink($encPath . '/share-keys/foo.user1.shareKey', 'share key');
+ }
+
function testDescryptAllWithBrokenFiles() {