Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ This release works with caldav 3.7.0: the tester carries the definitions of the
- **`save-load.icalendar.attendee-once`** - whether each ATTENDEE of an event comes back once. Bedework 5 stores every ATTENDEE twice, as an exact copy (`quirk`, "stored twice"), which caldav will drop when it reads the data (a caldav change still to be released). caldav does not define this feature yet, so the tester adds its definition itself until a caldav release has it.
- **`url.encode-at.encoded.href`** - whether a calendar-multiget finds an object named by an href with `%40`, as a GET of that URL does. Robur does not decode the `%40` in the href and answers 404; the literal `@` finds the object. caldav does not define this feature yet, so the tester adds its definition itself until a caldav release has it.
- **`search.recurrences.exception.in-calendar-data`** - whether a search returns a recurring event with its exceptions, as a GET has it. Bedework 3.10 and 5 return the master only. caldav does not define this feature yet, so the tester adds its definition itself until a caldav release has it.
- **`save-load.icalendar.tzid-link`** - whether an event whose TZID is a tz database link name (Europe/Oslo, a link to Europe/Berlin), sent with its VTIMEZONE, is stored with that TZID. Bedework 5 refuses it with 403 `unknownTimezone` (`ungraceful`); `quirk` where it is stored as Europe/Berlin, `unsupported` where another TZID comes back. A refusal or another TZID counts only where the same event in Europe/Berlin is stored and kept as such. caldav does not define this feature yet, so the tester adds its definition itself until a caldav release has it.
- **`save-load.todo.dtstart-without-due`** - whether a task with a DTSTART and no DUE keeps its DTSTART, and if not, whether a DUE beside it makes a difference. Zimbra drops it, but keeps it beside a DUE. caldav does not define this feature yet, so the tester adds its definition itself until a caldav release has it.

### Fixed

Expand Down
15 changes: 0 additions & 15 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,21 +482,6 @@ If it is done, the generic shape is a hook in the test-server definition
("expire the change history now"), with the probe `unknown` wherever no hook
is defined; Stalwart would be the only server with one.

# Bedework refuses TZIDs that are tzdata link names

Bedework answers 403 `unknownTimezone` for a TZID that is a tzdata link name
(Europe/Oslo, Europe/Stockholm, Europe/Amsterdam, Europe/Kiev), even with a
matching VTIMEZONE in the object. Canonical names (Europe/Berlin,
Europe/Paris, America/New_York) are accepted. Seen 2026-10-26 on the
Bedework3 docker server.

No probe or hint covers it. The `save-load.icalendar.vtimezone` probe
already sidesteps it by using Europe/Berlin, which is deliberate; only
Bedework 3 was tried, Bedework 5 was not. A probe would save an event with a
link-name TZID (with and without VTIMEZONE) next to a canonical-name control,
and grade the refusal `ungraceful`; it belongs with that probe
(https://github.com/python-caldav/caldav-server-tester/issues/39).

# `delete.if-match: broken` has no consumer

The hint is set for Zimbra, SOGo, Bedework 3 and 5, and Posteo, but nothing
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ known-first-party = ["caldav_server_tester"]
[tool.pytest.ini_options]
testpaths = ["tests"]
filterwarnings = ["error"]
# No async tests here; a pytest-asyncio installed system-wide would
# otherwise fail the run with a deprecation warning made fatal above.
addopts = "-p no:asyncio"
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
]
Expand Down
118 changes: 117 additions & 1 deletion src/caldav_server_tester/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5581,7 +5581,7 @@ class CheckVtimezone(_RoundTrip, Check):
Checks whether the VTIMEZONE sent with an event comes back with it. CCS
returns the event's TZID without the VTIMEZONE that defines it.

Europe/Berlin rather than a zone such as Europe/Oslo: Bedework refuses
Europe/Berlin rather than a zone such as Europe/Oslo: Bedework 5 refuses
TZIDs that are tzdata link names, which would hide what is asked here.
"""

Expand Down Expand Up @@ -5631,6 +5631,76 @@ def _grade(self, raw):
return self._graded("unsupported", f"the event comes back with TZID={tzid} but no VTIMEZONE for it")


class CheckTzidLink(_RoundTrip, Check):
"""
Checks whether an event whose TZID is a tz database link name, sent with
its VTIMEZONE, is stored with that TZID. Europe/Oslo has been a link to
Europe/Berlin since tzdata 2022b. Bedework 5 refuses it with 403
unknownTimezone: its time zone service knows a zone only by the TZID
inside its definition, and a link's definition carries its target's.

A refusal, or a TZID other than either coming back ("unsupported"), counts
only where the same event in Europe/Berlin is stored, and is read back as
Europe/Berlin in the second case.
"""

depends_on = {PrepareCalendar}
LABEL = "tzid-link"
FEATURE = "save-load.icalendar.tzid-link"
features_to_be_checked = {FEATURE}
UID = "csc_tzid_link_event"
WHAT = "an event in Europe/Oslo"
LINK = "Europe/Oslo"
TARGET = "Europe/Berlin"

def _body(self, tzid=LINK):
return self._ical(self.uid, vtimezone=CheckVtimezone.VTIMEZONE.replace(self.TARGET, tzid))

def _round_trip(self):
verdict = super()._round_trip()
support = verdict["support"] if isinstance(verdict, dict) else verdict
if support not in ("ungraceful", "unsupported"):
return verdict
## The control: the same event in the zone the link points to
url = self._url(f"{self.uid}_control")
try:
status = self._status(self._put(url, self._body(self.TARGET)))
if status is None:
return self._graded("unknown", f"cannot test, an event in {self.TARGET} got no answer")
if not 200 <= status < 300:
return self._graded("unknown", f"cannot test, an event in {self.TARGET} is refused too ({status})")
if support == "ungraceful":
return verdict
response = self._answer(self.client.request, url)
if not self._ok(response):
return self._unreadable(self._status(response))
tzid = self._tzid(response.raw)
if tzid != self.TARGET:
return self._graded(
"unknown", f"cannot test, every TZID is renamed: {self.TARGET} comes back as TZID={tzid}"
)
return verdict
finally:
self._delete(url)

@staticmethod
def _tzid(raw):
"""The TZID of the event's DTSTART, or None"""
dtstart = next((line for line in component_lines(raw, "VEVENT") if line.upper().startswith("DTSTART")), "")
tzid = re.search(r";TZID=([^;:]*)", dtstart, re.IGNORECASE)
return tzid[1].strip('"') if tzid else None

def _grade(self, raw):
tzid = self._tzid(raw)
if not tzid:
return self._graded("unknown", "cannot test, the event came back without a TZID")
if tzid == self.LINK:
return "full"
if tzid == self.TARGET:
return self._graded("quirk", f"stored as TZID={self.TARGET}, the zone {self.LINK} points to")
return self._graded("unsupported", f"the event comes back with TZID={tzid}")


class CheckXProperty(_RoundTrip, Check):
"""
Checks whether an X- property (RFC 5545 section 3.8.8.2) is stored, in an
Expand Down Expand Up @@ -5669,6 +5739,52 @@ def _grade(self, raw):
return self._kept(raw, "ESTIMATED-DURATION")


class CheckTodoDtstartWithoutDue(_RoundTrip, Check):
"""
Checks whether a task with a DTSTART and no DUE is stored with its
DTSTART. RFC 5545 section 3.6.2 allows either alone. Zimbra drops the
DTSTART of such a task, and keeps both where there is a DUE. Where it is
dropped, the same task with its DUE says which of the two this is.
"""

depends_on = {PrepareCalendar}
LABEL = "todo-dtstart"
FEATURE = "save-load.todo.dtstart-without-due"
features_to_be_checked = {FEATURE}
UID = "csc_todo_dtstart_without_due"
WHAT = "a task with a DTSTART and no DUE"
COMPONENTS = ("VTODO",)

def _body(self):
return re.sub(r"\r\nDUE[^\r\n]*", "", self._ical(self.uid, todo=True))

def _grade(self, raw):
verdict = self._kept(raw, "DTSTART")
if verdict == "full":
return verdict
kept = self._kept_with_due()
if kept is None:
return verdict
return self._graded(
"unsupported",
"the DTSTART is dropped; with a DUE, both are kept" if kept else "the DTSTART is dropped, with a DUE too",
)

def _kept_with_due(self):
"""Whether the same task with its DUE keeps its DTSTART; None where that cannot be told"""
uid = f"{self.uid}_control"
url = self._url(uid)
try:
if not self._ok(self._put(url, self._ical(uid, todo=True))):
return None
response = self._answer(self.client.request, url)
if not self._ok(response):
return None
return self._kept(response.raw, "DTSTART") == "full"
finally:
self._delete(url)


class CheckTodoAttendee(_RoundTrip, Check):
"""
Checks whether a task with an ATTENDEE is stored with it. Ox answers the
Expand Down
12 changes: 12 additions & 0 deletions src/caldav_server_tester/future_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@
"default": {"support": "full"},
"links": ["https://datatracker.ietf.org/doc/html/rfc4791#section-9.9"],
},
## caldav PR (feat/tzid-link)
"save-load.icalendar.tzid-link": {
"description": "An object whose TZID is a link name of the tz database (Europe/Oslo, a link to Europe/Berlin since tzdata 2022b; Asia/Calcutta, to Asia/Kolkata), sent with its VTIMEZONE, is stored with that TZID. 'ungraceful' when it is refused: Bedework 5 answers 403 with valid-calendar-object-resource and unknownTimezone, as its time zone service knows each zone by the TZID inside its definition only, and the definition of a link carries its target's. save() then sends the zone the link points to instead, which keeps every time since 1970 where it was (before 1970 a link may have had rules of its own); save(raw_data=...) does not. 'quirk' when the TZID is stored as the zone it points to, the behaviour saying so. 'unsupported' when it comes back as another TZID while an event in the zone it points to keeps its own.",
"default": {"support": "full"},
"links": ["https://data.iana.org/time-zones/tz-link.html"],
},
## caldav PR (feat/todo-dtstart-hint)
"save-load.todo.dtstart-without-due": {
"description": "A task with a DTSTART and no DUE (RFC 5545 section 3.6.2 allows either alone) is stored with its DTSTART. 'unsupported' when the DTSTART is dropped, the behaviour saying whether it is kept beside a DUE: Zimbra drops it, but keeps it where the task also has a DUE.",
"default": {"support": "full"},
"links": ["https://datatracker.ietf.org/doc/html/rfc5545#section-3.6.2"],
},
}


Expand Down
61 changes: 61 additions & 0 deletions tests/test_todo_dtstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""Whether a task with a DTSTART and no DUE keeps its DTSTART.

Zimbra drops it; with a DUE it keeps both.
"""

import re

from caldav_server_tester.checks import CheckTodoDtstartWithoutDue

from .test_floating_event import RewritingServer
from .test_icalendar_roundtrip import TASKS, _run


def _drop_dtstart(body):
return re.sub(r"DTSTART[^\r\n]*\r\n", "", body)


def test_kept_is_full_and_the_probe_sends_a_task_without_due():
sent = []
server = RewritingServer(rewrite=lambda body: sent.append(body) or body)
assert _run(CheckTodoDtstartWithoutDue, server)["support"] == "full"
[body] = sent
assert "BEGIN:VTODO" in body and "\r\nDTSTART:" in body
assert "DUE" not in body
assert not server.objects


def test_dropped_only_without_a_due_is_unsupported():
"""Zimbra: the control, the same task with its DUE, keeps both."""
server = RewritingServer(rewrite=lambda body: body if "\r\nDUE" in body else _drop_dtstart(body))
verdict = _run(CheckTodoDtstartWithoutDue, server)
assert verdict == {"support": "unsupported", "behaviour": "the DTSTART is dropped; with a DUE, both are kept"}
assert not server.objects


def test_dropped_with_a_due_too_says_so():
server = RewritingServer(rewrite=_drop_dtstart)
verdict = _run(CheckTodoDtstartWithoutDue, server)
assert verdict == {"support": "unsupported", "behaviour": "the DTSTART is dropped, with a DUE too"}
assert not server.objects


def test_refused_is_ungraceful():
assert _run(CheckTodoDtstartWithoutDue, RewritingServer(put_answer=403))["support"] == "ungraceful"


def test_the_task_goes_to_the_task_calendar():
server = RewritingServer()
seen = []
put = server.put
server.put = lambda url, body, headers=None: seen.append(url) or put(url, body, headers)
_run(CheckTodoDtstartWithoutDue, server)
assert seen and all(url.startswith(TASKS) for url in seen)


def test_not_probed_where_tasks_cannot_be_stored():
sent = []
_run(
CheckTodoDtstartWithoutDue, RewritingServer(rewrite=lambda body: sent.append(body) or body), todo="unsupported"
)
assert sent == []
99 changes: 99 additions & 0 deletions tests/test_tzid_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"""Whether a TZID that is a tz database link name is stored.

Bedework 5 refuses Europe/Oslo (a link to Europe/Berlin since tzdata 2022b)
with 403 unknownTimezone, and stores Europe/Berlin.
"""

import re
from unittest.mock import Mock

import pytest
from caldav.lib.error import AuthorizationError

from caldav_server_tester.checks import CheckTzidLink

from .test_floating_event import RewritingServer
from .test_icalendar_roundtrip import _run

FEATURE = CheckTzidLink.FEATURE


class RefusingLinks(RewritingServer):
"""Refuses a body naming ``refused``: Bedework 5, where it is a link name."""

def __init__(self, refused="Europe/Oslo", answer=AuthorizationError("403 Forbidden"), **kwargs):
super().__init__(**kwargs)
self.refused = refused
self.answer = answer
self.sent = []

def put(self, url, body, headers=None):
self.sent.append(body)
if any(f"TZID={tzid}" in body or f"TZID:{tzid}" in body for tzid in self.refused.split()):
if isinstance(self.answer, Exception):
raise self.answer
return Mock(status=self.answer, headers={})
return super().put(url, body, headers)


def test_kept_is_full_and_the_probe_sends_a_link_with_its_vtimezone():
server = RefusingLinks(refused="nothing")
assert _run(CheckTzidLink, server)["support"] == "full"
[body] = server.sent
assert re.search(r"\r\nDTSTART;TZID=Europe/Oslo:", body)
assert "BEGIN:VTIMEZONE\r\nTZID:Europe/Oslo\r\n" in body
assert not server.objects


@pytest.mark.parametrize("answer", [AuthorizationError("403 Forbidden"), 403, 400])
def test_refused_while_the_zone_it_points_to_is_stored_is_ungraceful(answer):
server = RefusingLinks(answer=answer)
verdict = _run(CheckTzidLink, server)
assert verdict["support"] == "ungraceful"
assert "Europe/Berlin" in server.sent[-1], "the control is the zone the link points to"
assert not server.objects


def test_refused_with_the_zone_it_points_to_too_says_nothing():
verdict = _run(CheckTzidLink, RefusingLinks(refused="Europe/Oslo Europe/Berlin"))
assert verdict["support"] == "unknown"


def test_refused_with_no_answer_for_the_zone_it_points_to_is_unknown():
server = RefusingLinks(refused="Europe/Oslo")
put = server.put
server.put = lambda url, body, headers=None: (
Mock(status=503, headers={}) if "TZID=Europe/Berlin" in body else put(url, body, headers)
)
verdict = _run(CheckTzidLink, server)
assert verdict["support"] == "unknown"
assert "no answer" in verdict["behaviour"]
assert not server.objects


def test_stored_as_the_zone_it_points_to_is_a_quirk():
verdict = _run(CheckTzidLink, RewritingServer(rewrite=lambda body: body.replace("Europe/Oslo", "Europe/Berlin")))
assert verdict["support"] == "quirk"
assert "Europe/Berlin" in verdict["behaviour"]


def test_unanswered_or_unreadable_is_unknown():
assert _run(CheckTzidLink, RewritingServer(put_answer=503))["support"] == "unknown"
assert _run(CheckTzidLink, RewritingServer(get_status=500))["support"] == "unknown"


def test_stored_under_another_name_is_unsupported():
server = RewritingServer(rewrite=lambda body: body.replace("Europe/Oslo", "Europe/Paris"))
verdict = _run(CheckTzidLink, server)
assert verdict["support"] == "unsupported"
assert "Europe/Paris" in verdict["behaviour"]
assert not server.objects


def test_every_tzid_renamed_says_nothing():
"""A server renaming every TZID says nothing about link names."""
server = RewritingServer(rewrite=lambda body: re.sub(r"TZID([=:])Europe/", r"TZID\1/vendor/Europe/", body))
verdict = _run(CheckTzidLink, server)
assert verdict["support"] == "unknown"
assert "/vendor/Europe/Berlin" in verdict["behaviour"]
assert not server.objects
Loading