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
29 changes: 27 additions & 2 deletions caldav/compatibility_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1771,8 +1771,10 @@ def compare(self, observed):
},
}

## Zimbra is not very good at it's caldav support
zimbra = {
## Zimbra is not very good at it's caldav support. Measured against the
## zimbra/zcs-foss:latest docker image (Zimbra 8.8, built 2017); upgrades
## have been known to bring regressions, hence the version-stamped name.
zimbra_8_8 = {
## Measured with caldav-server-tester, 2026-10-27: the UID filter works although search.text does not.
'search.text.uid': {'support': 'full'},
## Measured with caldav-server-tester, 2026-10-19.
Expand Down Expand Up @@ -1899,6 +1901,29 @@ def compare(self, observed):
"scheduling.auto-schedule": {"support": "unsupported"},
}

## Zimbra 10.1.21, measured with caldav-server-tester 2026-10-29 against an
## external server; there is no docker image of Zimbra 10. Only the differences found
## so far - everything else is assumed to be as in 8.8.
zimbra_10_1 = zimbra_8_8 | {
"save.no-uid-conflict": {"support": "quirk", "status": 412, "precondition": True, "behaviour": "refused with 412 and the precondition"},
"save.no-uid-conflict.href-given": {"support": "full"},
}

def __getattr__(name: str) -> Any:
"""Resolve a renamed profile, such as ``zimbra``, with a DeprecationWarning."""
from caldav.config import DEPRECATED_FEATURE_PROFILES

if name in DEPRECATED_FEATURE_PROFILES:
new_name, reason = DEPRECATED_FEATURE_PROFILES[name]
warnings.warn(
f"compatibility_hints.{name} has been renamed to {new_name} - {reason}",
DeprecationWarning,
stacklevel=2,
)
return globals()[new_name]
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


## Measured against the `ioggstream/bedework:latest` docker image, which is
## a quickstart-3.10.3 tree on openjdk-8 and was built 2018-11-05 - the image
## cannot even be rebuilt, as the quickstart zip its Dockerfile fetches from
Expand Down
26 changes: 25 additions & 1 deletion caldav/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ def read_config(fn, interactive_error=False):
),
}

## Profiles that have been renamed, but whose old name still resolves to the
## profile it always described. Named in a config, it gives a FutureWarning -
## a DeprecationWarning raised here would be hidden by Python's default
## filters, so the user would never learn to update the config. Accessed as
## an attribute of compatibility_hints, it gives a DeprecationWarning.
DEPRECATED_FEATURE_PROFILES = {
"zimbra": (
"zimbra_8_8",
"the profile was measured against a Zimbra 8.8 docker image; use "
"zimbra_10_1 for a current Zimbra",
),
}


def _lookup_feature_profile(name):
"""Look up a named profile in compatibility_hints.
Expand All @@ -102,6 +115,15 @@ def _lookup_feature_profile(name):
f"The compatibility profile '{name}' has been renamed to "
f"'{new_name}' - {reason}. Update your configuration."
)
if name in DEPRECATED_FEATURE_PROFILES:
new_name, reason = DEPRECATED_FEATURE_PROFILES[name]
warnings.warn(
f"The compatibility profile '{name}' has been renamed to "
f"'{new_name}' - {reason}. Update your configuration.",
FutureWarning,
stacklevel=2,
)
name = new_name
try:
return copy.deepcopy(getattr(caldav.compatibility_hints, name))
except AttributeError:
Expand Down Expand Up @@ -175,7 +197,9 @@ def get_test_setting(section_data: dict[str, Any], key: str, default: Any = None
if old_key and old_key in section_data:
warnings.warn(
f"The config key '{old_key}' is deprecated, use '{key}' instead",
DeprecationWarning,
## Not DeprecationWarning: that would be hidden by default, and
## the one to act on it is whoever edits the config file
FutureWarning,
stacklevel=2,
)
return section_data[old_key]
Expand Down
2 changes: 1 addition & 1 deletion caldav/testing/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def __init__(self, config: dict[str, Any] | None = None) -> None:
config.setdefault("password", os.environ.get("ZIMBRA_PASSWORD", "testpass"))
config.setdefault("ssl_verify_cert", False)
if "features" not in config:
config["features"] = compatibility_hints.zimbra.copy()
config["features"] = compatibility_hints.zimbra_8_8.copy()
# testuser/testuser2/testuser3 are created by start.sh for scheduling tests
if "scheduling_users" not in config:
domain = os.environ.get("ZIMBRA_DOMAIN", "zimbra.io")
Expand Down
1 change: 1 addition & 0 deletions changes/+config-deprecations-visible.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The deprecated config keys `testing_allowed` and `priority` now give a FutureWarning instead of a DeprecationWarning, which Python hides by default, so whoever edits the config file actually gets to see it.
1 change: 1 addition & 0 deletions changes/+zimbra-versioned-profiles.deprecated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The `zimbra` compatibility profile is renamed `zimbra_8_8`, as it was measured against a Zimbra 8.8 docker image, and `zimbra_10_1` is added: Zimbra 10.1 refuses a PUT of a UID the calendar already holds with 412 rather than 403 or 409. The old name still works, as `zimbra_8_8`: `features: zimbra` or `base: zimbra` in a config gives a FutureWarning, and `compatibility_hints.zimbra` in code a DeprecationWarning.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ filterwarnings = [
"ignore:You need to install the `build` package:UserWarning",

# An old key in the developer's own config file should not break the test run
"default:The config key '.*' is deprecated:DeprecationWarning",
"default:The config key '.*' is deprecated:FutureWarning",
"default:The compatibility profile '.*' has been renamed:FutureWarning",

# Ignore deprecation warnings from external libraries we can't control
# https://github.com/jawah/niquests/pull/327 https://github.com/jawah/niquests/issues/326
Expand Down
1 change: 1 addition & 0 deletions tests/docker-test-servers/zimbra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Zimbra Collaboration Suite running in Docker for the caldav library test suite.
## Overview

- **Image**: `zimbra/zcs-foss:latest` (Zimbra 8.8.3 pre-installed)
- **Compatibility profile**: `zimbra_8_8`. `zimbra_10_1` describes Zimbra 10.1, which has no docker image.
- **Port**: 8808 (mapped to container's 443/HTTPS)
- **Users**: testuser@zimbra.io / testpass, testuser2@zimbra.io / testpass
- **Protocol**: HTTPS with self-signed certificate (`ssl_verify_cert=False`)
Expand Down
10 changes: 2 additions & 8 deletions tests/test_async_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from caldav import Event, FreeBusy, Todo
from caldav.compatibility_hints import FeatureSet, write_delay
from caldav.config import resolve_features
from caldav.lib import error

from .search_cache_delay import SearchCacheDelay
Expand Down Expand Up @@ -175,14 +176,7 @@ class AsyncFunctionalTestsBaseClass:
def _features(self):
"""Cached FeatureSet from server config."""
if not hasattr(self.__class__, "_feature_set_cache"):
features = self.server.features
if isinstance(features, str):
import caldav.compatibility_hints

name = features
if name.startswith("compatibility_hints."):
name = name[len("compatibility_hints.") :]
features = getattr(caldav.compatibility_hints, name)
features = resolve_features(self.server.features)
self.__class__._feature_set_cache = FeatureSet(features)
return self.__class__._feature_set_cache

Expand Down
21 changes: 16 additions & 5 deletions tests/test_caldav_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4974,9 +4974,18 @@ def test_testing_allowed_is_deprecated(self, tmp_path):
from caldav.config import get_all_test_servers

config_file = self._write(tmp_path, {"testing_allowed": True})
with pytest.warns(DeprecationWarning, match="test_allowed"):
with pytest.warns(FutureWarning, match="test_allowed"):
assert "srv" in get_all_test_servers(config_file)

def test_deprecated_key_does_not_break_the_test_run(self, tmp_path):
"""pyproject.toml's filterwarnings must let the warning through
rather than turn the developer's own config into a test error."""
from caldav.config import get_all_test_servers, resolve_features

config_file = self._write(tmp_path, {"testing_allowed": True})
assert "srv" in get_all_test_servers(config_file)
resolve_features("zimbra")

def test_test_priority(self, tmp_path):
from caldav.config import _ConfiguredServer, get_all_test_servers

Expand All @@ -4989,15 +4998,15 @@ def test_priority_is_deprecated(self, tmp_path):
from caldav.config import _ConfiguredServer, get_all_test_servers

config_file = self._write(tmp_path, {"test_allowed": True, "priority": 5})
with pytest.warns(DeprecationWarning, match="test_priority"):
with pytest.warns(FutureWarning, match="test_priority"):
params = get_all_test_servers(config_file)["srv"]
assert _ConfiguredServer("srv", params).priority == 5

def test_embedded_server_priority(self):
from caldav.testing import RadicaleServer

assert RadicaleServer({"test_priority": 3}).priority == 3
with pytest.warns(DeprecationWarning, match="test_priority"):
with pytest.warns(FutureWarning, match="test_priority"):
assert RadicaleServer({"priority": 4}).priority == 4


Expand Down Expand Up @@ -8630,7 +8639,7 @@ def test_recurrence_instance_keeps_search(self, base) -> None:
assert [m for m, _ in sent][0] == "REPORT"
assert sent[-1][1]["if-none-match"] == "*"

@pytest.mark.parametrize("server", ["zimbra", "sogo"])
@pytest.mark.parametrize("server", ["zimbra_8_8", "zimbra_10_1", "sogo"])
def test_hints_of_servers_overwriting(self, server) -> None:
from caldav import compatibility_hints
from caldav.compatibility_hints import FeatureSet
Expand Down Expand Up @@ -8975,7 +8984,9 @@ def test_recurrence_instance_keeps_search(self, base) -> None:
)
assert [m for m, _ in sent] == ["REPORT"]

@pytest.mark.parametrize("server", ["radicale", "zimbra", "bedework_5_0_0", "sogo"])
@pytest.mark.parametrize(
"server", ["radicale", "zimbra_8_8", "zimbra_10_1", "bedework_5_0_0", "sogo"]
)
def test_hints_of_servers_mishandling_if_match_star(self, server) -> None:
from caldav import compatibility_hints
from caldav.compatibility_hints import FeatureSet
Expand Down
41 changes: 31 additions & 10 deletions tests/test_compatibility_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import pytest

from caldav import compatibility_hints as ch
from caldav.compatibility_hints import VALID_SUPPORT_LEVELS, FeatureSet, write_delay
from caldav.config import resolve_features as _resolve_features

Expand Down Expand Up @@ -549,16 +550,12 @@ def test_none_returns_none(self) -> None:
assert _resolve_features(None) is None

def test_string_resolves_profile(self) -> None:
import caldav.compatibility_hints as ch

result = _resolve_features("synology")
assert result == ch.synology
# deepcopy ensures the caller cannot mutate the shared profile
assert result is not ch.synology

def test_string_with_prefix(self) -> None:
import caldav.compatibility_hints as ch

result = _resolve_features("compatibility_hints.synology")
assert result == ch.synology
assert result is not ch.synology
Expand All @@ -569,8 +566,6 @@ def test_dict_without_base_passes_through(self) -> None:
assert result is features

def test_base_with_overrides(self) -> None:
import caldav.compatibility_hints as ch

original_sync_token = ch.synology.get("sync-token")
features = {
"base": "synology",
Expand Down Expand Up @@ -614,8 +609,6 @@ class TestRenamedProfiles:
"""

def test_bedework_profile_was_version_stamped(self) -> None:
import caldav.compatibility_hints as ch

assert hasattr(ch, "bedework_3_10_3")
assert not hasattr(ch, "bedework")

Expand All @@ -638,12 +631,40 @@ def test_renamed_name_as_base_explains_itself(self) -> None:
assert "bedework_3_10_3" in str(exc_info.value)

def test_new_name_resolves(self) -> None:
import caldav.compatibility_hints as ch

result = _resolve_features("bedework_3_10_3")
assert result == ch.bedework_3_10_3
assert result is not ch.bedework_3_10_3

def test_zimbra_profile_was_version_stamped(self) -> None:
assert hasattr(ch, "zimbra_8_8")
assert hasattr(ch, "zimbra_10_1")
assert "zimbra" not in vars(ch)

def test_deprecated_zimbra_name_still_resolves(self) -> None:
"""A config naming the old profile gets a FutureWarning: a
DeprecationWarning raised inside caldav.config is hidden by Python's
default filters, so the user would never be told to update it."""
for name in ("zimbra", "compatibility_hints.zimbra"):
with pytest.warns(FutureWarning, match="zimbra_10_1"):
assert _resolve_features(name) == ch.zimbra_8_8
with pytest.warns(FutureWarning, match="zimbra_8_8"):
result = _resolve_features({"base": "zimbra", "sync-token": "full"})
assert result["sync-token"] == "full"

def test_deprecated_zimbra_attribute_still_resolves(self) -> None:
with pytest.warns(DeprecationWarning, match="zimbra_8_8"):
assert ch.zimbra is ch.zimbra_8_8
with pytest.warns(DeprecationWarning, match="zimbra_8_8"):
from caldav.compatibility_hints import zimbra
assert zimbra is ch.zimbra_8_8
with pytest.raises(AttributeError):
ch.no_such_profile # noqa: B018

def test_zimbra_10_1_refuses_a_taken_uid_with_412(self) -> None:
assert ch.zimbra_10_1["save.no-uid-conflict"]["status"] == 412
assert ch.zimbra_8_8["save.no-uid-conflict"] == {"support": "full"}
assert ch.zimbra_10_1["save-load.stable-url"] == ch.zimbra_8_8["save-load.stable-url"]

def test_unknown_profile_names_the_offender(self) -> None:
with pytest.raises(ValueError) as exc_info:
_resolve_features("no_such_server")
Expand Down
4 changes: 3 additions & 1 deletion tests/test_uid_lookup_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ def test_robur_skips_the_search(self):
assert cal.get_event_by_uid(UID).id == UID
assert methods(cal) == ["GET", "REPORT"]

@pytest.mark.parametrize("profile", ["zimbra", "bedework_3_10_3", "bedework_5_0_0"])
@pytest.mark.parametrize(
"profile", ["zimbra_8_8", "zimbra_10_1", "bedework_3_10_3", "bedework_5_0_0"]
)
def test_profiles_with_a_working_uid_search_keep_it(self, profile):
from caldav import compatibility_hints

Expand Down
Loading