Skip to content

Commit 223815a

Browse files
authored
Merge pull request #59762 from nextcloud/backport/59693/stable32
2 parents 7e32578 + d6f4de3 commit 223815a

2 files changed

Lines changed: 75 additions & 14 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
Feature: calendar delegation
4+
Calendar delegation grants another user/principal control of a calendar account,
5+
including all calendars the delegator can access.
6+
7+
@caldav-delegation
8+
Scenario: admin grants user0 read access to her calendar account
9+
Given user "admin" exists
10+
And user "user0" exists
11+
When "admin" updates property "{DAV:}group-member-set" to href "/remote.php/dav/principals/users/user0" of principal "users/admin/calendar-proxy-read" on the endpoint "/remote.php/dav/principals/"
12+
Then The CalDAV response should be multi status
13+
And The CalDAV response should contain an href "/remote.php/dav/principals/users/admin/calendar-proxy-read"
14+
And The CalDAV response should contain a property "{DAV:}group-member-set"
15+
16+
@caldav-delegation
17+
Scenario: admin grants write access to her calendar account
18+
Given user "admin" exists
19+
And user "user0" exists
20+
When "admin" updates property "{DAV:}group-member-set" to href "/remote.php/dav/principals/users/user0" of principal "users/admin/calendar-proxy-write" on the endpoint "/remote.php/dav/principals/"
21+
Then The CalDAV response should be multi status
22+
And The CalDAV response should contain an href "/remote.php/dav/principals/users/admin/calendar-proxy-write"
23+
And The CalDAV response should contain a property "{DAV:}group-member-set"

build/integration/features/bootstrap/CalDavContext.php

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,39 @@ public function setUpScenario() {
4242

4343
/** @AfterScenario */
4444
public function afterScenario() {
45-
$davUrl = $this->baseUrl . '/remote.php/dav/calendars/admin/MyCalendar';
46-
try {
47-
$this->client->delete(
48-
$davUrl,
49-
[
50-
'auth' => [
51-
'admin',
52-
'admin',
53-
],
54-
'headers' => [
55-
'X-NC-CalDAV-No-Trashbin' => '1',
45+
foreach (['MyCalendar', 'MyCalendar2'] as $calendarName) {
46+
try {
47+
$this->client->delete(
48+
$this->baseUrl . '/remote.php/dav/calendars/admin/' . $calendarName,
49+
[
50+
'auth' => ['admin', 'admin'],
51+
'headers' => ['X-NC-CalDAV-No-Trashbin' => '1'],
5652
]
57-
]
58-
);
59-
} catch (\GuzzleHttp\Exception\ClientException $e) {
53+
);
54+
} catch (\GuzzleHttp\Exception\ClientException $e) {
55+
}
56+
}
57+
}
58+
59+
/** @AfterScenario @caldav-delegation */
60+
public function afterDelegationScenario() {
61+
foreach (['calendar-proxy-read', 'calendar-proxy-write'] as $proxyType) {
62+
try {
63+
$propPatch = new \Sabre\DAV\Xml\Request\PropPatch();
64+
$propPatch->properties = ['{DAV:}group-member-set' => new \Sabre\DAV\Xml\Property\Href([])];
65+
$xml = new \Sabre\Xml\Service();
66+
$body = $xml->write('{DAV:}propertyupdate', $propPatch, '/');
67+
$this->client->request(
68+
'PROPPATCH',
69+
$this->baseUrl . '/remote.php/dav/principals/users/admin/' . $proxyType,
70+
[
71+
'headers' => ['Content-Type' => 'application/xml; charset=UTF-8'],
72+
'body' => $body,
73+
'auth' => ['admin', 'admin'],
74+
]
75+
);
76+
} catch (\GuzzleHttp\Exception\ClientException $e) {
77+
}
6078
}
6179
}
6280

@@ -174,6 +192,26 @@ public function theCaldavResponseShouldContainAPropertyWithHrefValue(
174192
}
175193
}
176194

195+
/**
196+
* @Then The CalDAV response should contain an href :href
197+
* @throws \Exception
198+
*/
199+
public function theCaldavResponseShouldContainAnHref(string $href): void {
200+
/** @var \Sabre\DAV\Xml\Response\MultiStatus $multiStatus */
201+
$multiStatus = $this->responseXml['value'];
202+
foreach ($multiStatus->getResponses() as $response) {
203+
if ($response->getHref() === $href) {
204+
return;
205+
}
206+
}
207+
throw new \Exception(
208+
sprintf(
209+
'Expected href %s not found in response',
210+
$href,
211+
)
212+
);
213+
}
214+
177215
/**
178216
* @Then The CalDAV response should be multi status
179217
* @throws \Exception

0 commit comments

Comments
 (0)