aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit
diff options
context:
space:
mode:
authorRichard Steinmetz <richard@steinmetz.cloud>2024-06-11 09:42:03 +0200
committerRichard Steinmetz <richard@steinmetz.cloud>2024-06-11 20:08:57 +0200
commit3a975d0a89e4576f60d6b9628c3de902e683fdc0 (patch)
tree15f692f8b9e0c574c815f32ed0639e92cb1ab977 /apps/dav/tests/unit
parent9fbf20885882b914bb689076443ba92c2f6da985 (diff)
downloadnextcloud-server-3a975d0a89e4576f60d6b9628c3de902e683fdc0.tar.gz
nextcloud-server-3a975d0a89e4576f60d6b9628c3de902e683fdc0.zip
fix(caldav): event links in shared calendar notifications
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r--apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php39
1 files changed, 37 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php b/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php
index 27604952124..b0b2cc936a5 100644
--- a/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php
+++ b/apps/dav/tests/unit/CalDAV/Activity/Provider/EventTest.php
@@ -91,7 +91,9 @@ class EventTest extends TestCase {
* @param bool $calendarAppEnabled
*/
public function testGenerateObjectParameter(int $id, string $name, ?array $link, bool $calendarAppEnabled = true): void {
+ $affectedUser = 'otheruser';
if ($link) {
+ $affectedUser = $link['owner'];
$generatedLink = [
'view' => 'dayGridMonth',
'timeRange' => 'now',
@@ -124,7 +126,40 @@ class EventTest extends TestCase {
if ($link && $calendarAppEnabled) {
$result['link'] = 'fullLink';
}
- $this->assertEquals($result, $this->invokePrivate($this->provider, 'generateObjectParameter', [$objectParameter]));
+ $this->assertEquals($result, $this->invokePrivate($this->provider, 'generateObjectParameter', [$objectParameter, $affectedUser]));
+ }
+
+ public function testGenerateObjectParameterWithSharedCalendar(): void {
+ $link = [
+ 'object_uri' => 'someuuid.ics',
+ 'calendar_uri' => 'personal',
+ 'owner' => 'sharer'
+ ];
+ $generatedLink = [
+ 'view' => 'dayGridMonth',
+ 'timeRange' => 'now',
+ 'mode' => 'sidebar',
+ 'objectId' => base64_encode('/remote.php/dav/calendars/sharee/' . $link['calendar_uri'] . '_shared_by_sharer/' . $link['object_uri']),
+ 'recurrenceId' => 'next'
+ ];
+ $this->appManager->expects($this->once())
+ ->method('isEnabledForUser')
+ ->with('calendar')
+ ->willReturn(true);
+ $this->url->expects($this->once())
+ ->method('getWebroot');
+ $this->url->expects($this->once())
+ ->method('linkToRouteAbsolute')
+ ->with('calendar.view.indexview.timerange.edit', $generatedLink)
+ ->willReturn('fullLink');
+ $objectParameter = ['id' => 42, 'name' => 'calendar', 'link' => $link];
+ $result = [
+ 'type' => 'calendar-event',
+ 'id' => 42,
+ 'name' => 'calendar',
+ 'link' => 'fullLink',
+ ];
+ $this->assertEquals($result, $this->invokePrivate($this->provider, 'generateObjectParameter', [$objectParameter, 'sharee']));
}
public function dataGenerateObjectParameterThrows() {
@@ -143,6 +178,6 @@ class EventTest extends TestCase {
public function testGenerateObjectParameterThrows($eventData, string $exception = InvalidArgumentException::class): void {
$this->expectException($exception);
- $this->invokePrivate($this->provider, 'generateObjectParameter', [$eventData]);
+ $this->invokePrivate($this->provider, 'generateObjectParameter', [$eventData, 'no_user']);
}
}