diff --git a/docs/design/ROADMAP.md b/docs/design/ROADMAP.md index ff87401..6410ba3 100644 --- a/docs/design/ROADMAP.md +++ b/docs/design/ROADMAP.md @@ -392,13 +392,16 @@ therefore has a committed downstream consumer and should not be trimmed. - [x] Config file discovery (XDG paths, explicit path, environment) - [x] Credential handling: keyring integration, and never requiring secrets in plaintext config -- [ ] Settle the shared file with the caldav and calendaring-jmap +- [x] Settle the shared file with the caldav and calendaring-jmap maintainers: see [CONFIGURATION_PROPOSAL.md](CONFIGURATION_PROPOSAL.md). The parser is now a package of its own, - [calendaring-config](https://github.com/pycalendar/calendaring-config); - caldav has yet to adopt it - ([caldav issue #786](https://github.com/python-caldav/caldav/issues/786)), - and the file name is still open. + [calendaring-config](https://github.com/pycalendar/calendaring-config), + and caldav reads its configuration through it since 3.6.0 + ([caldav PR #804](https://github.com/python-caldav/caldav/pull/804), + closing [caldav issue #786](https://github.com/python-caldav/caldav/issues/786)). + `$XDG_CONFIG_HOME/pycal/calendar.yaml` is searched first, with caldav's + old paths as fallbacks. calendaring-jmap keeps its own flat file for + standalone use, and gets its section passed from calendaring. - [x] Check existing conventions first — `caldav`, `plann`, `vdirsyncer`, `khal`, etc — rather than inventing a fifth format (probably build on the caldav format) - [x] Leave room for backends beyond the funded ones without format changes: diff --git a/news/+native-id-if-none-match.bugfix.rst b/news/+native-id-if-none-match.bugfix.rst new file mode 100644 index 0000000..0697b1b --- /dev/null +++ b/news/+native-id-if-none-match.bugfix.rst @@ -0,0 +1 @@ +On SOGo, which ignores ``If-None-Match: *``, ``identity.client-native-id`` is now declared ``emulated``: caldav looks the name up before creating an object there, so a create under a name already taken is refused, with a short window between the look-up and the write. diff --git a/src/calendaring/_caldav_features.py b/src/calendaring/_caldav_features.py index df9c0ee..4a47d05 100644 --- a/src/calendaring/_caldav_features.py +++ b/src/calendaring/_caldav_features.py @@ -152,6 +152,21 @@ def _table(features: Any) -> dict[Feature, Any]: notes.append("made for one component only, the first in sorted order") if notes: table[Feature.CREATE_COLLECTION] = {"level": L, "note": "; ".join(notes)} + if _level(features, "save.if-none-match") is U: # the server overwrites a name already taken + # caldav then GETs the name before the PUT where a duplicate UID is refused and names are kept (SOGo), + # and otherwise searches by UID, which leaves the name unguarded + if str(features.is_supported("save.no-uid-conflict", str)) in {"full", "quirk", "ungraceful"} and ( + features.is_supported("save-load.stable-url") + ): + table[Feature.IDENTITY_CLIENT_NATIVE_ID] = { + "level": E, + "note": "caldav looks the name up before the PUT, racily", + } + else: + table[Feature.IDENTITY_CLIENT_NATIVE_ID] = { + "level": U, + "note": "the server overwrites an object under a name already taken", + } return table diff --git a/tests/test_caldav_features.py b/tests/test_caldav_features.py index 3e33a2b..f02f7ae 100644 --- a/tests/test_caldav_features.py +++ b/tests/test_caldav_features.py @@ -357,6 +357,33 @@ def test_a_calendar_does_not_hold_what_the_server_refuses_to_store() -> None: assert stored_components(features(), listed) == listed # unhinted: nothing known +def test_a_name_is_checked_before_the_put_where_the_server_ignores_if_none_match() -> None: + # SOGo: caldav GETs the name first, as the server refuses a duplicate UID and keeps the name + ignoring = {"save-load": {"support": "full"}, "save.if-none-match": {"support": "unsupported"}} + refusing = {"save.no-uid-conflict": {"support": "quirk", "status": 409, "precondition": False}} + server = features({**ignoring, **refusing}) + table = collection_capabilities(server, ALL) + assert table.level(Feature.IDENTITY_CLIENT_NATIVE_ID) is Support.EMULATED + assert "before" in (table[Feature.IDENTITY_CLIENT_NATIVE_ID].note or "") + assert ( + collection_capabilities(hinted(save_load="full"), ALL).level(Feature.IDENTITY_CLIENT_NATIVE_ID) is Support.FULL + ) + # Zimbra ignores it too, but renames every object: no native id at all + renaming = features( + { + "save-load": {"support": "full"}, + "save.if-none-match": {"support": "unsupported"}, + "save-load.stable-url": {"support": "unsupported", "forces_uid_ics": True}, + } + ) + assert collection_capabilities(renaming, ALL).level(Feature.IDENTITY_CLIENT_NATIVE_ID) is Support.UNSUPPORTED + # Not known to refuse a duplicate UID: caldav searches by UID, which leaves the name unguarded + searching = features(ignoring) + assert collection_capabilities(searching, ALL).level(Feature.IDENTITY_CLIENT_NATIVE_ID) is Support.UNSUPPORTED + unstable = features({**ignoring, **refusing, "save-load.stable-url": {"support": "unsupported"}}) + assert collection_capabilities(unstable, ALL).level(Feature.IDENTITY_CLIENT_NATIVE_ID) is Support.UNSUPPORTED + + def test_a_calendar_is_made_lossily_where_the_server_ignores_the_component_set() -> None: server = hinted(save_load="full", create_calendar="full") assert backend_capabilities(server).level(Feature.CREATE_COLLECTION) is Support.FULL