Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2021-04-06 14:45:10 +0300
committerGitHub <noreply@github.com>2021-04-06 14:45:10 +0300
commit4b4971ab5245dd1b9dd27fd2e293367c8fa037c0 (patch)
tree7c1787792a2f7457c991773df8ae6b82a29fd434 /tests
parent2056b76c5fb29fa9273c50e17e54c5cf43f8a5fc (diff)
parent40fde94b4d019f5c1914225d5be6854241abeb9c (diff)
Merge pull request #24966 from nextcloud/jknockaert-patch-1
avoid fread on directories and unencrypted files
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index 8bdb48fd854..a4ee5e45bd5 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -584,6 +584,14 @@ class EncryptionTest extends Storage {
$this->arrayCache
]
)->getMock();
+
+ $cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
+ ->disableOriginalConstructor()->getMock();
+ $cache->expects($this->any())
+ ->method('get')
+ ->willReturnCallback(function ($path) {
+ return ['encrypted' => true, 'path' => $path];
+ });
$instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption')
->setConstructorArgs(
@@ -597,9 +605,11 @@ class EncryptionTest extends Storage {
$this->encryptionManager, $util, $this->logger, $this->file, null, $this->keyStore, $this->update, $this->mountManager, $this->arrayCache
]
)
- ->setMethods(['readFirstBlock', 'parseRawHeader'])
+ ->setMethods(['getCache','readFirstBlock', 'parseRawHeader'])
->getMock();
-
+
+ $instance->expects($this->once())->method('getCache')->willReturn($cache);
+
$instance->expects($this->once())->method(('parseRawHeader'))
->willReturn([Util::HEADER_ENCRYPTION_MODULE_KEY => 'OC_DEFAULT_MODULE']);
@@ -677,8 +687,8 @@ class EncryptionTest extends Storage {
->setMethods(['readFirstBlock', 'parseRawHeader', 'getCache'])
->getMock();
- $instance->expects($this->once())->method(('parseRawHeader'))->willReturn($header);
- $instance->expects($this->any())->method('getCache')->willReturn($cache);
+ $instance->expects($this->any())->method(('parseRawHeader'))->willReturn($header);
+ $instance->expects($this->once())->method('getCache')->willReturn($cache);
$result = $this->invokePrivate($instance, 'getHeader', ['test.txt']);
$this->assertSameSize($expected, $result);