Skip to content

Commit b52a9ec

Browse files
committed
test(integration): add proper cleanup for caldav scenarios
test(integration): add proper cleanup for caldav scenarios Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
1 parent e119759 commit b52a9ec

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

build/integration/features/bootstrap/CalDavContext.php

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,39 @@ public function setUpScenario() {
6161

6262
/** @AfterScenario */
6363
public function afterScenario() {
64-
$davUrl = $this->baseUrl. '/remote.php/dav/calendars/admin/MyCalendar';
65-
try {
66-
$this->client->delete(
67-
$davUrl,
68-
[
69-
'auth' => [
70-
'admin',
71-
'admin',
72-
],
73-
]
74-
);
75-
} catch (\GuzzleHttp\Exception\ClientException $e) {
64+
foreach (['MyCalendar', 'MyCalendar2'] as $calendarName) {
65+
try {
66+
$this->client->delete(
67+
$this->baseUrl . '/remote.php/dav/calendars/admin/' . $calendarName,
68+
[
69+
'auth' => ['admin', 'admin'],
70+
'headers' => ['X-NC-CalDAV-No-Trashbin' => '1'],
71+
]
72+
);
73+
} catch (\GuzzleHttp\Exception\ClientException $e) {
74+
}
75+
}
76+
}
77+
78+
/** @AfterScenario @caldav-delegation */
79+
public function afterDelegationScenario() {
80+
foreach (['calendar-proxy-read', 'calendar-proxy-write'] as $proxyType) {
81+
try {
82+
$propPatch = new \Sabre\DAV\Xml\Request\PropPatch();
83+
$propPatch->properties = ['{DAV:}group-member-set' => new \Sabre\DAV\Xml\Property\Href([])];
84+
$xml = new \Sabre\Xml\Service();
85+
$body = $xml->write('{DAV:}propertyupdate', $propPatch, '/');
86+
$this->client->request(
87+
'PROPPATCH',
88+
$this->baseUrl . '/remote.php/dav/principals/users/admin/' . $proxyType,
89+
[
90+
'headers' => ['Content-Type' => 'application/xml; charset=UTF-8'],
91+
'body' => $body,
92+
'auth' => ['admin', 'admin'],
93+
]
94+
);
95+
} catch (\GuzzleHttp\Exception\ClientException $e) {
96+
}
7697
}
7798
}
7899

build/integration/features/caldav-delegation.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Feature: calendar delegation
44
Calendar delegation grants another user/principal control of a calendar account,
55
including all calendars the delegator can access.
66

7+
@caldav-delegation
78
Scenario: admin grants user0 read access to her calendar account
89
Given user "admin" exists
910
And user "user0" exists
@@ -12,6 +13,7 @@ Feature: calendar delegation
1213
And The CalDAV response should contain an href "/remote.php/dav/principals/users/admin/calendar-proxy-read"
1314
And The CalDAV response should contain a property "{DAV:}group-member-set"
1415

16+
@caldav-delegation
1517
Scenario: admin grants write access to her calendar account
1618
Given user "admin" exists
1719
And user "user0" exists

0 commit comments

Comments
 (0)