aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
authorJohannes Merkel <mail@johannesgge.de>2023-05-22 15:25:16 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-08-16 10:47:40 +0000
commit8dae579261f23263231b77990ae79965efa61dc0 (patch)
treec5773caff086511fa5ddd698b6bfc99b65f95463 /apps/dav/tests
parent5af9b6cb99313b6572bd669dc1914693c90378b1 (diff)
downloadnextcloud-server-8dae579261f23263231b77990ae79965efa61dc0.tar.gz
nextcloud-server-8dae579261f23263231b77990ae79965efa61dc0.zip
enh(contacts): show/hide addressbooks for all
Signed-off-by: Johannes Merkel <mail@johannesgge.de>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/unit/CardDAV/AddressBookTest.php29
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[] = [