diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2021-04-06 13:45:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 13:45:10 +0200 |
commit | 4b4971ab5245dd1b9dd27fd2e293367c8fa037c0 (patch) | |
tree | 7c1787792a2f7457c991773df8ae6b82a29fd434 /tests | |
parent | 2056b76c5fb29fa9273c50e17e54c5cf43f8a5fc (diff) | |
parent | 40fde94b4d019f5c1914225d5be6854241abeb9c (diff) | |
download | nextcloud-server-4b4971ab5245dd1b9dd27fd2e293367c8fa037c0.tar.gz nextcloud-server-4b4971ab5245dd1b9dd27fd2e293367c8fa037c0.zip |
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.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 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); |