summaryrefslogtreecommitdiffstats
path: root/tests/lib/encryption
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-06-02 12:33:17 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-06-02 12:33:17 +0200
commit50a31fa8f905c3f9483137bc7b1e57cbf950d2c2 (patch)
tree1a4a588a385ea921b41c8ea9f90b94b2e8822978 /tests/lib/encryption
parent9a4040c7ca2c0e4fc3f213ba3f6144e80f687754 (diff)
downloadnextcloud-server-50a31fa8f905c3f9483137bc7b1e57cbf950d2c2.tar.gz
nextcloud-server-50a31fa8f905c3f9483137bc7b1e57cbf950d2c2.zip
Add unit tests for wrapStorage
Diffstat (limited to 'tests/lib/encryption')
-rw-r--r--tests/lib/encryption/utiltest.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/lib/encryption/utiltest.php b/tests/lib/encryption/utiltest.php
index d3a4e211daa..d5f5ce4c2e9 100644
--- a/tests/lib/encryption/utiltest.php
+++ b/tests/lib/encryption/utiltest.php
@@ -194,4 +194,49 @@ class UtilTest extends TestCase {
);
}
+ /**
+ * @dataProvider provideWrapStorage
+ */
+ public function testWrapStorage($expectedWrapped, $wrappedStorages) {
+ $storage = $this->getMockBuilder('OC\Files\Storage\Storage')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ foreach ($wrappedStorages as $wrapper) {
+ $storage->expects($this->any())
+ ->method('instanceOfStorage')
+ ->willReturnMap([
+ [$wrapper, true],
+ ]);
+ }
+
+ $mount = $this->getMockBuilder('OCP\Files\Mount\IMountPoint')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $returnedStorage = $this->util->wrapStorage('mountPoint', $storage, $mount);
+
+ $this->assertEquals(
+ $expectedWrapped,
+ $returnedStorage->instanceOfStorage('OC\Files\Storage\Wrapper\Encryption'),
+ 'Asserted that the storage is (not) wrapped with encryption'
+ );
+ }
+
+ public function provideWrapStorage() {
+ return [
+ // Wrap when not wrapped or not wrapped with storage
+ [true, []],
+ [true, ['OCA\Files_Trashbin\Storage']],
+
+ // Do not wrap shared storages
+ [false, ['OC\Files\Storage\Shared']],
+ [false, ['OCA\Files_Sharing\External\Storage']],
+ [false, ['OC\Files\Storage\OwnCloud']],
+ [false, ['OC\Files\Storage\Shared', 'OCA\Files_Sharing\External\Storage']],
+ [false, ['OC\Files\Storage\Shared', 'OC\Files\Storage\OwnCloud']],
+ [false, ['OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']],
+ [false, ['OC\Files\Storage\Shared', 'OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']],
+ ];
+ }
}