diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2018-07-25 10:19:14 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2018-07-31 12:24:38 +0200 |
commit | a9e22c5f1ccdc148d8ea8a1e2f5e8baac6f19e90 (patch) | |
tree | c4e7d88363686a63b12c1141243e73774b1c34be /tests | |
parent | c39bc1638b812ef9660cfdb0ab6ca58d70ad68d8 (diff) | |
download | nextcloud-server-a9e22c5f1ccdc148d8ea8a1e2f5e8baac6f19e90.tar.gz nextcloud-server-a9e22c5f1ccdc148d8ea8a1e2f5e8baac6f19e90.zip |
make file cache updates more robust
only update the encrypted version after the write operation is finished and the stream is closed
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/Stream/EncryptionTest.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php index 983428ee51d..d7a5554acfd 100644 --- a/tests/lib/Files/Stream/EncryptionTest.php +++ b/tests/lib/Files/Stream/EncryptionTest.php @@ -2,8 +2,10 @@ namespace Test\Files\Stream; +use OC\Files\Cache\CacheEntry; use OC\Files\View; use OC\Memcache\ArrayCache; +use OCP\Files\Cache\ICache; use OCP\IConfig; class EncryptionTest extends \Test\TestCase { @@ -26,6 +28,7 @@ class EncryptionTest extends \Test\TestCase { $header = []; $uid = ''; $this->encryptionModule = $this->buildMockModule(); + $cache = $this->createMock(ICache::class); $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); $encStorage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') @@ -49,6 +52,13 @@ class EncryptionTest extends \Test\TestCase { $util->expects($this->any()) ->method('getUidAndFilename') ->willReturn(['user1', $internalPath]); + $storage->expects($this->any())->method('getCache')->willReturn($cache); + $entry = new CacheEntry([ + 'fileid' => 5, + 'encryptedVersion' => 2, + ]); + $cache->expects($this->any())->method('get')->willReturn($entry ); + $cache->expects($this->any())->method('update')->with(5, ['encrypted' => 3, 'encryptedVersion' => 3]); return $wrapper::wrap($source, $internalPath, @@ -208,6 +218,7 @@ class EncryptionTest extends \Test\TestCase { public function testSeek() { $fileName = tempnam("/tmp", "FOO"); + $stream = $this->getStream($fileName, 'w+', 0); $this->assertEquals(6, fwrite($stream, 'foobar')); $this->assertEquals(0, fseek($stream, 3)); |