diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2021-09-23 11:05:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 11:05:05 +0300 |
commit | 8687bec176cf4a783e6e7c26ce93b741bced0a40 (patch) | |
tree | 1bef00486781494cc9f6791a34a877a913df6f31 /tests | |
parent | 7a34dd4a97a65943c6292d5d0c88efcb9e996bab (diff) | |
parent | 8466c53e0055558a7719de382ae148424f018513 (diff) |
Merge pull request #27407 from nextcloud/backport/24966/stable20
[stable20] avoid fread on directories and unencrypted files
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/Storage/Wrapper/EncryptionTest.php | 18 |
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 eccec7c28d5..d152a51ed85 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -573,6 +573,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( @@ -586,9 +594,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']); @@ -661,8 +671,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); |