From 496fdfbf4e41994b8ff4c3e356a04c84cc6a43fd Mon Sep 17 00:00:00 2001 From: Hamza Date: Mon, 20 Apr 2026 14:17:47 +0200 Subject: [PATCH] test(integration): add proper cleanup for caldav scenarios test(integration): add proper cleanup for caldav scenarios Signed-off-by: Hamza --- .../features/bootstrap/CalDavContext.php | 46 +++++++++++++------ .../features/caldav-delegation.feature | 2 + 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/build/integration/features/bootstrap/CalDavContext.php b/build/integration/features/bootstrap/CalDavContext.php index e00588a9428..3d0fd58ad32 100644 --- a/build/integration/features/bootstrap/CalDavContext.php +++ b/build/integration/features/bootstrap/CalDavContext.php @@ -60,21 +60,39 @@ class CalDavContext implements \Behat\Behat\Context\Context { /** @AfterScenario */ public function afterScenario() { - $davUrl = $this->baseUrl. '/remote.php/dav/calendars/admin/MyCalendar'; - try { - $this->client->delete( - $davUrl, - [ - 'auth' => [ - 'admin', - 'admin', - ], - 'headers' => [ - 'X-NC-CalDAV-No-Trashbin' => '1', + foreach (['MyCalendar', 'MyCalendar2'] as $calendarName) { + try { + $this->client->delete( + $this->baseUrl . '/remote.php/dav/calendars/admin/' . $calendarName, + [ + 'auth' => ['admin', 'admin'], + 'headers' => ['X-NC-CalDAV-No-Trashbin' => '1'], ] - ] - ); - } catch (\GuzzleHttp\Exception\ClientException $e) { + ); + } catch (\GuzzleHttp\Exception\ClientException $e) { + } + } + } + + /** @AfterScenario @caldav-delegation */ + public function afterDelegationScenario() { + foreach (['calendar-proxy-read', 'calendar-proxy-write'] as $proxyType) { + try { + $propPatch = new \Sabre\DAV\Xml\Request\PropPatch(); + $propPatch->properties = ['{DAV:}group-member-set' => new \Sabre\DAV\Xml\Property\Href([])]; + $xml = new \Sabre\Xml\Service(); + $body = $xml->write('{DAV:}propertyupdate', $propPatch, '/'); + $this->client->request( + 'PROPPATCH', + $this->baseUrl . '/remote.php/dav/principals/users/admin/' . $proxyType, + [ + 'headers' => ['Content-Type' => 'application/xml; charset=UTF-8'], + 'body' => $body, + 'auth' => ['admin', 'admin'], + ] + ); + } catch (\GuzzleHttp\Exception\ClientException $e) { + } } } diff --git a/build/integration/features/caldav-delegation.feature b/build/integration/features/caldav-delegation.feature index ce52bca6ab8..d4cc781f320 100644 --- a/build/integration/features/caldav-delegation.feature +++ b/build/integration/features/caldav-delegation.feature @@ -4,6 +4,7 @@ Feature: calendar delegation Calendar delegation grants another user/principal control of a calendar account, including all calendars the delegator can access. + @caldav-delegation Scenario: admin grants user0 read access to her calendar account Given user "admin" exists And user "user0" exists @@ -12,6 +13,7 @@ Feature: calendar delegation And The CalDAV response should contain an href "/remote.php/dav/principals/users/admin/calendar-proxy-read" And The CalDAV response should contain a property "{DAV:}group-member-set" + @caldav-delegation Scenario: admin grants write access to her calendar account Given user "admin" exists And user "user0" exists