Generische iCal-Kanäle mit Bestandsklärung und sicheren Exporten bereitstellen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m33s

This commit is contained in:
Lars committed 2026-10-27 17:14:45 +01:00
1 parent 6fe5bbc6e3
commit 783068501c
42 files changed
+2646 -248

No files matched your search

+10 -3
View File
@@ -61,6 +61,7 @@ public function test_parser_reads_dates_datetimes_folded_lines_and_skips_cancell
{
$ics = implode("\r\n", [
'BEGIN:VCALENDAR',
'VERSION:2.0', 'PRODID:-//Synthetic Test//EN',
'BEGIN:VEVENT', 'UID:a1', 'DTSTART;VALUE=DATE:20261107', 'DTEND;VALUE=DATE:20261110', 'SUMMARY:Reserviert \, Familie', 'END:VEVENT',
'BEGIN:VEVENT', 'UID:a2', 'DTSTART;TZID=Europe/Berlin:20261201T160000', 'DTEND;TZID=Europe/Berlin:20261205T100000', 'END:VEVENT',
'BEGIN:VEVENT', 'UID:a3-very-long-uid-that-is-', ' folded', 'DTSTART:20261231T230000Z', 'DTEND:20270102T090000Z', 'END:VEVENT',
@@ -69,6 +70,7 @@ public function test_parser_reads_dates_datetimes_folded_lines_and_skips_cancell
'END:VCALENDAR',
]);
$ics = str_replace("BEGIN:VEVENT\r\n", "BEGIN:VEVENT\r\nDTSTAMP:20261022T080000Z\r\n", $ics);
$periods = (new ICalParser)->parse($ics);
$this->assertSame(
@@ -99,7 +101,9 @@ public function test_sync_adds_changes_and_removes_imported_occupations(): void
$this->fakeFeed([['x1', '20261107', '20261111']]);
$second = (new SyncChannel)->handle($channel);
$this->assertSame([0, 1, 1], [$second->added, $second->changed, $second->removed]);
$this->assertSame([0, 1, 0], [$second->added, $second->changed, $second->removed]);
$third = (new SyncChannel)->handle($channel);
$this->assertSame([0, 0, 1], [$third->added, $third->changed, $third->removed]);
$this->assertSame('2026-11-11', $channel->blockedPeriods()->sole()->ends_on->toDateString());
$this->assertNotNull($channel->fresh()->last_success_at);
}
@@ -251,6 +255,9 @@ public function test_channels_are_managed_and_tasks_completed_in_the_admin(): vo
->callAction(TestAction::make(CreateAction::class)->table(), [
'name' => 'FeWo-direkt',
'connector' => 'ical',
'status' => 'active',
'import_enabled' => true,
'export_enabled' => true,
'settings' => ['import_url' => 'https://www.fewo-direkt.de/icalendar/abc.ics'],
'requires_manual_blocking' => true,
'manage_url' => 'https://www.fewo-direkt.de/vermieter/kalender',
@@ -282,8 +289,8 @@ private function channel(string $name, bool $manual = false): Channel
*/
private function fakeFeed(array $events): void
{
$body = "BEGIN:VCALENDAR\r\n".collect($events)
->map(fn (array $event): string => "BEGIN:VEVENT\r\nUID:{$event[0]}\r\nDTSTART;VALUE=DATE:{$event[1]}\r\nDTEND;VALUE=DATE:{$event[2]}\r\nEND:VEVENT\r\n")
$body = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Synthetic Test//EN\r\n".collect($events)
->map(fn (array $event): string => "BEGIN:VEVENT\r\nDTSTAMP:20261022T080000Z\r\nUID:{$event[0]}\r\nDTSTART;VALUE=DATE:{$event[1]}\r\nDTEND;VALUE=DATE:{$event[2]}\r\nEND:VEVENT\r\n")
->implode('')."END:VCALENDAR\r\n";
$this->httpResponse = Http::response($body, 200, ['Content-Type' => 'text/calendar']);