summaryrefslogtreecommitdiffstats
path: root/tests/lib/encryption
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-02 16:25:01 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:31 +0200
commitfe74a0cb4f319ac9dccfce8c296365c3535ef84e (patch)
treedf5c6034c6722c5687ce6f9c7415d4b8adf8d445 /tests/lib/encryption
parent8991272269632bc094fb8ad537d5af5a1bc372b5 (diff)
downloadnextcloud-server-fe74a0cb4f319ac9dccfce8c296365c3535ef84e.tar.gz
nextcloud-server-fe74a0cb4f319ac9dccfce8c296365c3535ef84e.zip
implement webdav copy
Diffstat (limited to 'tests/lib/encryption')
-rw-r--r--tests/lib/encryption/keys/storage.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/lib/encryption/keys/storage.php b/tests/lib/encryption/keys/storage.php
index c2e5bdbd3d1..be32f0e44a1 100644
--- a/tests/lib/encryption/keys/storage.php
+++ b/tests/lib/encryption/keys/storage.php
@@ -277,4 +277,80 @@ class StorageTest extends TestCase {
);
}
+ /**
+ * @dataProvider dataProviderCopyRename
+ */
+ public function testRenameKeys($source, $target, $systemWideMount, $expectedSource, $expectedTarget) {
+ $this->view->expects($this->any())
+ ->method('file_exists')
+ ->willReturn(true);
+ $this->view->expects($this->any())
+ ->method('is_dir')
+ ->willReturn(true);
+ $this->view->expects($this->once())
+ ->method('rename')
+ ->with(
+ $this->equalTo($expectedSource),
+ $this->equalTo($expectedTarget))
+ ->willReturn(true);
+ $this->util->expects($this->any())
+ ->method('getUidAndFilename')
+ ->will($this->returnCallback(array($this, 'getUidAndFilenameCallback')));
+ $this->util->expects($this->any())
+ ->method('isSystemWideMountPoint')
+ ->willReturn($systemWideMount);
+
+ $storage = new Storage('encModule', $this->view, $this->util);
+ $storage->renameKeys($source, $target);
+ }
+
+ /**
+ * @dataProvider dataProviderCopyRename
+ */
+ public function testCopyKeys($source, $target, $systemWideMount, $expectedSource, $expectedTarget) {
+ $this->view->expects($this->any())
+ ->method('file_exists')
+ ->willReturn(true);
+ $this->view->expects($this->any())
+ ->method('is_dir')
+ ->willReturn(true);
+ $this->view->expects($this->once())
+ ->method('copy')
+ ->with(
+ $this->equalTo($expectedSource),
+ $this->equalTo($expectedTarget))
+ ->willReturn(true);
+ $this->util->expects($this->any())
+ ->method('getUidAndFilename')
+ ->will($this->returnCallback(array($this, 'getUidAndFilenameCallback')));
+ $this->util->expects($this->any())
+ ->method('isSystemWideMountPoint')
+ ->willReturn($systemWideMount);
+
+ $storage = new Storage('encModule', $this->view, $this->util);
+ $storage->copyKeys($source, $target);
+ }
+
+ public function getUidAndFilenameCallback() {
+ $args = func_get_args();
+
+ $path = $args[0];
+ $parts = explode('/', $path);
+
+ return array($parts[1], '/' . implode('/', array_slice($parts, 2)));
+ }
+
+ public function dataProviderCopyRename() {
+ return array(
+ array('/user1/files/foo.txt', '/user1/files/bar.txt', false,
+ '/user1/files_encryption/keys/files/foo.txt/', '/user1/files_encryption/keys/files/bar.txt/'),
+ array('/user1/files/foo/foo.txt', '/user1/files/bar.txt', false,
+ '/user1/files_encryption/keys/files/foo/foo.txt/', '/user1/files_encryption/keys/files/bar.txt/'),
+ array('/user1/files/foo.txt', '/user1/files/foo/bar.txt', false,
+ '/user1/files_encryption/keys/files/foo.txt/', '/user1/files_encryption/keys/files/foo/bar.txt/'),
+ array('/user1/files/foo.txt', '/user1/files/foo/bar.txt', true,
+ '/files_encryption/keys/files/foo.txt/', '/files_encryption/keys/files/foo/bar.txt/'),
+ );
+ }
+
}