From a8505bc70a0e38e1056c447c9d0c69f8be4e89c9 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 20 Apr 2020 19:18:42 +0545 Subject: [PATCH 1/4] Adjust Files/Storage/Wrapper/EncryptionTest.php to avoid array offset on value of type null --- tests/lib/Files/Storage/Wrapper/EncryptionTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index e44a49c94e42..42976d23fb0d 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -273,9 +273,16 @@ function ($path) use ($encrypted) { ->method('getCache') ->with($path) ->willReturn($fileEntry); + + if (isset($metaData['fileid'])) { + $fileId = $metaData['fileid']; + } else { + $fileId = null; + } + $fileEntry->expects($this->any()) ->method('get') - ->with($metaData['fileid']); + ->with($fileId); $this->instance->expects($this->any())->method('getCache')->willReturn($cache); $this->instance->expects($this->any())->method('verifyUnencryptedSize') @@ -295,7 +302,7 @@ function ($path) use ($encrypted) { public function dataTestGetMetaData() { return [ ['/test.txt', ['size' => 42, 'encrypted' => 2, 'encryptedVersion' => 2, 'fileid' => 1], true, true, 12, ['size' => 12, 'encrypted' => true, 'encryptedVersion' => 2]], - ['/test.txt', null, true, true, 12, null], + ['/test.txt', [], true, true, 12, ['size' => 12]], ['/test.txt', ['size' => 42, 'encrypted' => 0, 'fileid' => 1], false, false, 12, ['size' => 42, 'encrypted' => false]], ['/test.txt', ['size' => 42, 'encrypted' => false, 'fileid' => 1], true, false, 12, ['size' => 12, 'encrypted' => true]] ]; From dc5213d6cd80d4963b4945609cb07fd944085b48 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Mon, 20 Apr 2020 19:10:03 +0300 Subject: [PATCH 2/4] Fix EncryptionTest::testStreamOpen --- tests/lib/Files/Stream/EncryptionTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php index 2821fff3a2ca..efd82c55675a 100644 --- a/tests/lib/Files/Stream/EncryptionTest.php +++ b/tests/lib/Files/Stream/EncryptionTest.php @@ -97,6 +97,10 @@ public function testStreamOpen($mode, // get a instance of the stream wrapper $streamWrapper = $this->getMockBuilder('\OC\Files\Stream\Encryption') ->setMethods(['loadContext', 'writeHeader', 'skipHeader'])->disableOriginalConstructor()->getMock(); + $streamWrapper->expects($this->once()) + ->method('loadContext') + ->with('ocencryption') + ->willReturn(['sourceFileOfRename' => 'dummyfile']); // set internal properties of the stream wrapper $stream = new \ReflectionClass('\OC\Files\Stream\Encryption'); From b59f53b2cb61330ad40065949f06893f8fbbaf52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Tue, 21 Apr 2020 11:20:55 +0200 Subject: [PATCH 3/4] Fixes for the dav app for php 7.4 --- apps/dav/lib/Connector/Sabre/File.php | 5 +++-- apps/dav/tests/unit/CardDAV/SyncServiceTest.php | 9 +++++++++ apps/dav/tests/unit/Meta/MetaPluginTest.php | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php index d19c5d5c63b3..16f0258b31e5 100644 --- a/apps/dav/lib/Connector/Sabre/File.php +++ b/apps/dav/lib/Connector/Sabre/File.php @@ -570,10 +570,11 @@ private function createFileChunked($data) { $info = $this->fileView->getFileInfo($targetPath); if (isset($partStorage, $partInternalPath)) { - $checksums = $partStorage->getMetaData($partInternalPath)['checksum']; + $metadata = $partStorage->getMetaData($partInternalPath); } else { - $checksums = $targetStorage->getMetaData($targetInternalPath)['checksum']; + $metadata = $targetStorage->getMetaData($targetInternalPath); } + $checksums = (isset($metadata['checksum'])) ? $metadata['checksum'] : null; $this->fileView->putFileInfo( $targetPath, diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php index 2c55a1626afa..3d4ecd019554 100644 --- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php @@ -90,6 +90,15 @@ public function testUpdateAndDeleteUser() { $backend->method('getCard')->willReturnOnConsecutiveCalls(false, [ 'carddata' => "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 3.4.8//EN\r\nUID:test-user\r\nFN:test-user\r\nN:test-user;;;;\r\nEND:VCARD\r\n\r\n" ]); + $backend->method('getAddressBooksByUri')->willReturn([ + 'id' => 40, + 'uri' => 'contacts', + 'principaluri' => 'principals/users/admin', + '{DAV:}displayname' => 'Contacts', + '{urn:ietf:params:xml:ns:carddav}addressbook-description' => null, + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, + ]); /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject $userManager */ $userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock(); diff --git a/apps/dav/tests/unit/Meta/MetaPluginTest.php b/apps/dav/tests/unit/Meta/MetaPluginTest.php index 8c033567738a..66d75f95e3c9 100644 --- a/apps/dav/tests/unit/Meta/MetaPluginTest.php +++ b/apps/dav/tests/unit/Meta/MetaPluginTest.php @@ -29,6 +29,7 @@ use PHPUnit\Framework\MockObject\MockObject; use Sabre\DAV\PropFind; use Sabre\DAV\Server; +use Sabre\DAV\Xml\Service as XMLService; use Test\TestCase; class MetaPluginTest extends TestCase { @@ -75,6 +76,9 @@ public function setUp(): void { /** @var Server | MockObject $server */ $this->server = $this->createMock(Server::class); + + $xmlService = $this->createMock(XMLService::class); + $this->server->xml = $xmlService; } public function testInit() { From e4cc9fa705da1388f4b57b98a784d9dc2fed2fd4 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Wed, 22 Apr 2020 11:25:47 +0300 Subject: [PATCH 4/4] Fix ViewTest::testLockBasicOperationUnlocksAfterException --- tests/lib/Files/ViewTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index b250f3a4b4d6..8bb3dba3749a 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -2064,7 +2064,7 @@ public function testLockBasicOperationUnlocksAfterException( /** @var Temporary | \PHPUnit\Framework\MockObject\MockObject $storage */ $storage = $this->getMockBuilder(Temporary::class) - ->setMethods([$operation]) + ->setMethods([$operation, 'getEtag']) ->getMock(); Filesystem::mount($storage, [], $this->user . '/'); @@ -2076,6 +2076,8 @@ public function testLockBasicOperationUnlocksAfterException( \file_put_contents($realPath . '/files/test.txt', 'blah'); $this->shallThrow = false; + $storage->method('getETag') + ->willReturn('abcd'); $storage ->method($operation) ->willReturnCallback(function ($path) {