summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-03-10 15:58:24 +0100
committerLukas Reschke <lukas@owncloud.com>2016-03-16 10:36:15 +0100
commit676041ba7edaf668c9e6c1bb6f1c25ff7635960a (patch)
tree31abdb75eaecc7f8552f742b9c0378d69867e820 /tests
parent631ae2f0f4eda0da1c03bfc1a9a32e8cf7a926a7 (diff)
downloadnextcloud-server-676041ba7edaf668c9e6c1bb6f1c25ff7635960a.tar.gz
nextcloud-server-676041ba7edaf668c9e6c1bb6f1c25ff7635960a.zip
Ensure that stored version is at least 1 for cross-storage copy
In case of a move operation from an unencrypted to an encrypted storage the old encrypted version would stay with "0" while the correct value would be "1". Thus we manually set the value to "1" for those cases. See also https://github.com/owncloud/core/issues/23078
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/storage/wrapper/encryption.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/lib/files/storage/wrapper/encryption.php b/tests/lib/files/storage/wrapper/encryption.php
index b5ec15b12bf..bde920e440e 100644
--- a/tests/lib/files/storage/wrapper/encryption.php
+++ b/tests/lib/files/storage/wrapper/encryption.php
@@ -672,6 +672,48 @@ class Encryption extends Storage {
];
}
+ public function testCopyBetweenStorageMinimumEncryptedVersion() {
+ $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);
+ });
+ $cache = $this->getMock('\OCP\Files\Cache\ICache');
+ $cache->expects($this->once())
+ ->method('get')
+ ->with($sourceInternalPath)
+ ->willReturn(['encryptedVersion' => 0]);
+ $storage2->expects($this->once())
+ ->method('getCache')
+ ->willReturn($cache);
+ $this->encryptionManager->expects($this->any())
+ ->method('isEnabled')
+ ->willReturn(true);
+ global $mockedMountPointEncryptionEnabled;
+ $mockedMountPointEncryptionEnabled = true;
+
+ $expectedCachePut = [
+ 'encrypted' => true,
+ ];
+ $expectedCachePut['encryptedVersion'] = 1;
+
+ $this->cache->expects($this->once())
+ ->method('put')
+ ->with($sourceInternalPath, $expectedCachePut);
+
+ $this->invokePrivate($this->instance, 'copyBetweenStorage', [$storage2, $sourceInternalPath, $targetInternalPath, $preserveMtime, $isRename]);
+
+ $this->assertFalse(false);
+ }
+
/**
* @dataProvider dataCopyBetweenStorage
*