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
13 changes: 8 additions & 5 deletions docs/design/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions news/+native-id-if-none-match.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions src/calendaring/_caldav_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
27 changes: 27 additions & 0 deletions tests/test_caldav_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading