diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2023-08-16 15:44:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-16 15:44:16 +0200 |
commit | 8065a2f6359b25f3028775d8c6e5adcf4e520313 (patch) | |
tree | 5f63469f0c296ba280481ba4ebebdc3e375e4a99 /apps/dav/tests | |
parent | f95ed098c56359151432e5640c8b43ce4958cd93 (diff) | |
parent | 8dae579261f23263231b77990ae79965efa61dc0 (diff) | |
download | nextcloud-server-8065a2f6359b25f3028775d8c6e5adcf4e520313.tar.gz nextcloud-server-8065a2f6359b25f3028775d8c6e5adcf4e520313.zip |
Merge pull request #39904 from nextcloud/backport/38397/stable27
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/CardDAV/AddressBookTest.php | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/apps/dav/tests/unit/CardDAV/AddressBookTest.php b/apps/dav/tests/unit/CardDAV/AddressBookTest.php index 81361d02068..9aa7eb14fff 100644 --- a/apps/dav/tests/unit/CardDAV/AddressBookTest.php +++ b/apps/dav/tests/unit/CardDAV/AddressBookTest.php @@ -29,6 +29,7 @@ namespace OCA\DAV\Tests\unit\CardDAV; use OCA\DAV\CardDAV\AddressBook; use OCA\DAV\CardDAV\Card; use OCA\DAV\CardDAV\CardDavBackend; +use OCA\DAV\DAV\CustomPropertiesBackend; use OCP\IL10N; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; @@ -101,11 +102,10 @@ class AddressBookTest extends TestCase { } - public function testPropPatch(): void { - $this->expectException(Forbidden::class); - + public function testPropPatchShared(): void { /** @var MockObject | CardDavBackend $backend */ $backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock(); + $backend->expects($this->never())->method('updateAddressBook'); $addressBookInfo = [ '{http://owncloud.org/ns}owner-principal' => 'user1', '{DAV:}displayname' => 'Test address book', @@ -116,7 +116,24 @@ class AddressBookTest extends TestCase { $l10n = $this->createMock(IL10N::class); $logger = $this->createMock(LoggerInterface::class); $addressBook = new AddressBook($backend, $addressBookInfo, $l10n, $logger); - $addressBook->propPatch(new PropPatch([])); + $addressBook->propPatch(new PropPatch(['{DAV:}displayname' => 'Test address book'])); + } + + public function testPropPatchNotShared(): void { + /** @var MockObject | CardDavBackend $backend */ + $backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock(); + $backend->expects($this->atLeast(1))->method('updateAddressBook'); + $addressBookInfo = [ + '{http://owncloud.org/ns}owner-principal' => 'user1', + '{DAV:}displayname' => 'Test address book', + 'principaluri' => 'user1', + 'id' => 666, + 'uri' => 'default', + ]; + $l10n = $this->createMock(IL10N::class); + $logger = $this->createMock(LoggerInterface::class); + $addressBook = new AddressBook($backend, $addressBookInfo, $l10n, $logger); + $addressBook->propPatch(new PropPatch(['{DAV:}displayname' => 'Test address book'])); } /** @@ -152,6 +169,10 @@ class AddressBookTest extends TestCase { 'privilege' => '{DAV:}write', 'principal' => $hasOwnerSet ? 'user1' : 'user2', 'protected' => true + ], [ + 'privilege' => '{DAV:}write-properties', + 'principal' => '{DAV:}authenticated', + 'protected' => true ]]; if ($hasOwnerSet) { $expectedAcl[] = [ |