mirror of
https://github.com/nextcloud/server.git
synced 2026-02-24 18:37:44 -05:00
When hitting the `/contactsmenu/contacts` endpoint with the `dav.system_addressbook_exposed` config switch set to `"no"`, the system address book content is still listed in the response. This ensure that we do not expose unexpectedly the system address book. Signed-off-by: Louis Chemineau <louis@chmn.me>
42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
namespace OCA\DAV\Tests\unit\CardDAV;
|
|
|
|
use OCA\DAV\CardDAV\CardDavBackend;
|
|
use OCA\DAV\CardDAV\ContactsManager;
|
|
use OCA\DAV\Db\PropertyMapper;
|
|
use OCP\Contacts\IManager;
|
|
use OCP\IAppConfig;
|
|
use OCP\IL10N;
|
|
use OCP\IURLGenerator;
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
use Test\TestCase;
|
|
|
|
class ContactsManagerTest extends TestCase {
|
|
public function test(): void {
|
|
/** @var IManager&MockObject $cm */
|
|
$cm = $this->createMock(IManager::class);
|
|
$cm->expects($this->exactly(1))->method('registerAddressBook');
|
|
/** @var IURLGenerator&MockObject $urlGenerator */
|
|
$urlGenerator = $this->createMock(IURLGenerator::class);
|
|
/** @var CardDavBackend&MockObject $backEnd */
|
|
$backEnd = $this->createMock(CardDavBackend::class);
|
|
$backEnd->method('getAddressBooksForUser')->willReturn([
|
|
['{DAV:}displayname' => 'Test address book', 'uri' => 'default'],
|
|
]);
|
|
$propertyMapper = $this->createMock(PropertyMapper::class);
|
|
/** @var IAppConfig&MockObject $appConfig */
|
|
$appConfig = $this->createMock(IAppConfig::class);
|
|
|
|
/** @var IL10N&MockObject $l */
|
|
$l = $this->createMock(IL10N::class);
|
|
$app = new ContactsManager($backEnd, $l, $propertyMapper, $appConfig);
|
|
$app->setupContactsProvider($cm, 'user01', $urlGenerator);
|
|
}
|
|
}
|