summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
authorRobert C. Schaller <gtbc_robert.schaller@rsxc.de>2024-03-25 02:18:02 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-03-26 08:49:34 +0000
commit823a07bb1d4959e994572c776dca8529e0640d07 (patch)
tree86a17a5327adcb7d26f1ced79471c120a8bf082a /apps/dav/tests
parentbfa6ef849758115b4fc195e3da5f7117257802e6 (diff)
downloadnextcloud-server-823a07bb1d4959e994572c776dca8529e0640d07.tar.gz
nextcloud-server-823a07bb1d4959e994572c776dca8529e0640d07.zip
fix(dav): wrong comparison method between two events
Old comparison implementation compares each element of the array against each other with no respect for the associated array label, which leads to wrongful removals because one value is accidentally present in a completely different label. New comparison works 'by-label' individually. Partly fixes #41084 because changes between 'SEQUENCE' not present, 'SEQUENCE:0' and 'SEQUENCE:1' were not detected in the old implementation and thus no email update sent. Co-authored-by: Christoph Wurst <ChristophWurst@users.noreply.github.com> Signed-off-by: Robert C. Schaller <gtbc_robert.schaller@rsxc.de>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php b/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php
index efc9ef32afc..836ec46db30 100644
--- a/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php
+++ b/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
/**
* @copyright 2023 Daniel Kesselberg <mail@danielkesselberg.de>
+ * @copyright 2024 Robert C. Schaller <gtbc_robert.schaller@rsxc.de>
*
* @author 2023 Daniel Kesselberg <mail@danielkesselberg.de>
*
@@ -137,4 +138,70 @@ class EventComparisonServiceTest extends TestCase {
$this->assertEquals([$vEventOld2], $result['old']);
$this->assertEquals([$vEventNew2], $result['new']);
}
+
+ // First test to certify fix for issue nextcloud/server#41084
+ public function testSequenceNumberIncrementDetectedForFirstModificationToEventWithoutZeroInit(): void {
+ $vCalendarOld = new VCalendar();
+ $vCalendarNew = new VCalendar();
+
+ $vEventOld = $vCalendarOld->add('VEVENT', [
+ 'UID' => 'uid-1234',
+ 'LAST-MODIFIED' => 123456,
+ // 'SEQUENCE' => 0, // sequence number may not be set to zero during event creation and instead fully omitted
+ 'SUMMARY' => 'Fellowship meeting',
+ 'DTSTART' => new \DateTime('2016-01-01 00:00:00'),
+ 'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z',
+ ]);
+ $vEventOld->add('ORGANIZER', 'mailto:gandalf@wiz.ard');
+ $vEventOld->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);
+
+ $vEventNew = $vCalendarNew->add('VEVENT', [
+ 'UID' => 'uid-1234',
+ 'LAST-MODIFIED' => 123456,
+ 'SEQUENCE' => 1,
+ 'SUMMARY' => 'Fellowship meeting',
+ 'DTSTART' => new \DateTime('2016-01-01 00:00:00'),
+ 'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z',
+ ]);
+ $vEventNew->add('ORGANIZER', 'mailto:gandalf@wiz.ard');
+ $vEventNew->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);
+
+ $result = $this->eventComparisonService->findModified($vCalendarNew, $vCalendarOld);
+ $this->assertEquals([$vEventOld], $result['old']);
+ $this->assertEquals([$vEventNew], $result['new']);
+ }
+
+ // Second test to certify fix for issue nextcloud/server#41084
+ public function testSequenceNumberIncrementDetectedForFirstModificationToEventWithZeroInit(): void {
+ $vCalendarOld = new VCalendar();
+ $vCalendarNew = new VCalendar();
+
+ $vEventOld = $vCalendarOld->add('VEVENT', [
+ 'UID' => 'uid-1234',
+ 'LAST-MODIFIED' => 123456,
+ 'SEQUENCE' => 0,
+ 'SUMMARY' => 'Fellowship meeting',
+ 'DTSTART' => new \DateTime('2016-01-01 00:00:00'),
+ 'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z',
+ ]);
+ $vEventOld->add('ORGANIZER', 'mailto:gandalf@wiz.ard');
+ $vEventOld->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);
+
+ $vEventNew = $vCalendarNew->add('VEVENT', [
+ 'UID' => 'uid-1234',
+ 'LAST-MODIFIED' => 123456,
+ 'SEQUENCE' => 1,
+ 'SUMMARY' => 'Fellowship meeting',
+ 'DTSTART' => new \DateTime('2016-01-01 00:00:00'),
+ 'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z',
+ ]);
+ $vEventNew->add('ORGANIZER', 'mailto:gandalf@wiz.ard');
+ $vEventNew->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);
+
+ $result = $this->eventComparisonService->findModified($vCalendarNew, $vCalendarOld);
+ $this->assertEquals([$vEventOld], $result['old']);
+ $this->assertEquals([$vEventNew], $result['new']);
+ }
+
+
}