summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2020-03-16 15:04:21 +0100
committerGeorg Ehrke <developer@georgehrke.com>2020-03-16 15:36:13 +0100
commitbd1f98cba37ceb6c0d07a1d5764ec4eb22f369ed (patch)
treee513277122d21eb915b6074c4f6f924a08665f01 /apps/dav
parent48bdd322a210e5e80ad1bb80ecbe86fad5ba28d1 (diff)
downloadnextcloud-server-bd1f98cba37ceb6c0d07a1d5764ec4eb22f369ed.tar.gz
nextcloud-server-bd1f98cba37ceb6c0d07a1d5764ec4eb22f369ed.zip
RefreshWebcalService: randomly generate calendar-object uri
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php14
-rw-r--r--apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php12
2 files changed, 20 insertions, 6 deletions
diff --git a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php
index beab0271d8f..a057e29eb2c 100644
--- a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php
+++ b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php
@@ -47,6 +47,7 @@ use Sabre\VObject\InvalidDataException;
use Sabre\VObject\ParseException;
use Sabre\VObject\Reader;
use Sabre\VObject\Splitter\ICalendar;
+use Sabre\VObject\UUIDUtil;
use function count;
class RefreshWebcalService {
@@ -113,7 +114,6 @@ class RefreshWebcalService {
while ($vObject = $splitter->getNext()) {
/** @var Component $vObject */
- $uid = null;
$compName = null;
foreach ($vObject->getComponents() as $component) {
@@ -121,7 +121,6 @@ class RefreshWebcalService {
continue;
}
- $uid = $component->{'UID'}->getValue();
$compName = $component->name;
if ($stripAlarms) {
@@ -136,7 +135,7 @@ class RefreshWebcalService {
continue;
}
- $uri = $uid . '.ics';
+ $uri = $this->getRandomCalendarObjectUri();
$calendarData = $vObject->serialize();
try {
$this->calDavBackend->createCalendarObject($subscription['id'], $uri, $calendarData, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
@@ -413,4 +412,13 @@ class RefreshWebcalService {
return $cleanURL;
}
+
+ /**
+ * Returns a random uri for a calendar-object
+ *
+ * @return string
+ */
+ public function getRandomCalendarObjectUri():string {
+ return UUIDUtil::getUUID() . '.ics';
+ }
}
diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
index 01e541ec20e..b1d341c2e4e 100644
--- a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
+++ b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
@@ -69,8 +69,14 @@ class RefreshWebcalServiceTest extends TestCase {
* @dataProvider runDataProvider
*/
public function testRun(string $body, string $contentType, string $result) {
- $refreshWebcalService = new RefreshWebcalService($this->caldavBackend,
- $this->clientService, $this->config, $this->logger);
+ $refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class)
+ ->setMethods(['getRandomCalendarObjectUri'])
+ ->setConstructorArgs([$this->caldavBackend, $this->clientService, $this->config, $this->logger])
+ ->getMock();
+
+ $refreshWebcalService
+ ->method('getRandomCalendarObjectUri')
+ ->willReturn('uri-1.ics');
$this->caldavBackend->expects($this->once())
->method('getSubscriptionsForUser')
@@ -130,7 +136,7 @@ class RefreshWebcalServiceTest extends TestCase {
$this->caldavBackend->expects($this->once())
->method('createCalendarObject')
- ->with(42, '12345.ics', $result, 1);
+ ->with(42, 'uri-1.ics', $result, 1);
$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}