summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-07-27 16:06:39 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-07-27 16:06:39 +0200
commit68f14a943acb7b2f51a4f717cd043f2ac2d4def8 (patch)
tree327cfa7a504b5196b08a483899b25e3c3e0c535e /tests
parentc030ae9decd1558a7ececf1dcbc556c293d00ea2 (diff)
parent5923270004ac0b74ab464dd8c058c59628c960b0 (diff)
downloadnextcloud-server-68f14a943acb7b2f51a4f717cd043f2ac2d4def8.tar.gz
nextcloud-server-68f14a943acb7b2f51a4f717cd043f2ac2d4def8.zip
Merge pull request #17840 from owncloud/fix-enc-wrapper-without-encryption
Only set is encrypted when encryption is enabled
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/storage/wrapper/encryption.php61
1 files changed, 60 insertions, 1 deletions
diff --git a/tests/lib/files/storage/wrapper/encryption.php b/tests/lib/files/storage/wrapper/encryption.php
index 677bbffc3d2..612cf827975 100644
--- a/tests/lib/files/storage/wrapper/encryption.php
+++ b/tests/lib/files/storage/wrapper/encryption.php
@@ -139,7 +139,15 @@ class Encryption extends \Test\Files\Storage\Storage {
->disableOriginalConstructor()
->setMethods(['getOption'])
->getMock();
- $this->mount->expects($this->any())->method('getOption')->willReturn(true);
+ $this->mount->expects($this->any())->method('getOption')->willReturnCallback(function ($option, $default) {
+ if ($option === 'encrypt' && $default === true) {
+ global $mockedMountPointEncryptionEnabled;
+ if ($mockedMountPointEncryptionEnabled !== null) {
+ return $mockedMountPointEncryptionEnabled;
+ }
+ }
+ return true;
+ });
$this->cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
->disableOriginalConstructor()->getMock();
@@ -542,4 +550,55 @@ class Encryption extends \Test\Files\Storage\Storage {
];
}
+ public function dataCopyBetweenStorage() {
+ return [
+ [true, true, true],
+ [true, false, false],
+ [false, true, false],
+ [false, false, false],
+ ];
+ }
+
+ /**
+ * @dataProvider dataCopyBetweenStorage
+ *
+ * @param bool $encryptionEnabled
+ * @param bool $mountPointEncryptionEnabled
+ * @param bool $expectedEncrypted
+ */
+ public function testCopyBetweenStorage($encryptionEnabled, $mountPointEncryptionEnabled, $expectedEncrypted) {
+ $storage2 = $this->getMockBuilder('OCP\Files\Storage')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $sourceInternalPath = $targetInternalPath = 'file.txt';
+ $preserveMtime = $isRename = false;
+
+ $storage2->expects($this->any())
+ ->method('fopen')
+ ->willReturnCallback(function($path, $mode) {
+ $temp = \OC::$server->getTempManager();
+ return fopen($temp->getTemporaryFile(), $mode);
+ });
+
+ $this->encryptionManager->expects($this->any())
+ ->method('isEnabled')
+ ->willReturn($encryptionEnabled);
+
+ // FIXME can not overwrite the return after definition
+// $this->mount->expects($this->at(0))
+// ->method('getOption')
+// ->with('encrypt', true)
+// ->willReturn($mountPointEncryptionEnabled);
+ global $mockedMountPointEncryptionEnabled;
+ $mockedMountPointEncryptionEnabled = $mountPointEncryptionEnabled;
+
+ $this->cache->expects($this->once())
+ ->method('put')
+ ->with($sourceInternalPath, ['encrypted' => $expectedEncrypted]);
+
+ $this->invokePrivate($this->instance, 'copyBetweenStorage', [$storage2, $sourceInternalPath, $targetInternalPath, $preserveMtime, $isRename]);
+
+ $this->assertFalse(false);
+ }
}