Skip to content

Commit ff0c679

Browse files
tobixenclaude
andcommitted
test: pre-populate scheduling_users in Cyrus and Baikal server classes
Rather than requiring a caldav_test_servers.yaml file to be written by CI (or manually by the user), bake the scheduling_users directly into CyrusTestServer and BaikalTestServer.__init__. - Cyrus: user1-user3 / password 'x' (pre-created by the docker image) - Baikal: user1-user3 / testpass1-3 (pre-seeded in the committed db.sqlite) The per-server TestSchedulingForServer{Cyrus,Baikal} classes are now generated automatically whenever those servers are running, with no additional configuration required. Also drop the now-unnecessary CI step that wrote caldav_test_servers.yaml. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8ac202d commit ff0c679

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

.github/workflows/tests.yaml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -276,36 +276,6 @@ jobs:
276276
echo "✗ Error: Bedework CalDAV access failed"
277277
exit 1
278278
fi
279-
- name: Configure RFC6638 scheduling test users
280-
run: |
281-
# Write test config with scheduling_users for each server that supports it.
282-
# Cyrus pre-creates user1-user5 (password 'x') with scheduling support.
283-
# Baikal users user1-user3 are in the pre-seeded db.sqlite.
284-
# These configs are merged into auto-discovered servers by the registry.
285-
cat > tests/caldav_test_servers.yaml << 'EOF'
286-
cyrus:
287-
scheduling_users:
288-
- url: http://localhost:8802/dav/calendars/user/user1
289-
username: user1
290-
password: x
291-
- url: http://localhost:8802/dav/calendars/user/user2
292-
username: user2
293-
password: x
294-
- url: http://localhost:8802/dav/calendars/user/user3
295-
username: user3
296-
password: x
297-
baikal:
298-
scheduling_users:
299-
- url: http://localhost:8800/dav.php/
300-
username: user1
301-
password: testpass1
302-
- url: http://localhost:8800/dav.php/
303-
username: user2
304-
password: testpass2
305-
- url: http://localhost:8800/dav.php/
306-
username: user3
307-
password: testpass3
308-
EOF
309279
- run: tox -e py
310280
env:
311281
NEXTCLOUD_URL: http://localhost:8801

tests/test_servers/docker.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,22 @@ class BaikalTestServer(DockerTestServer):
3030

3131
def __init__(self, config: dict[str, Any] | None = None) -> None:
3232
config = config or {}
33-
config.setdefault("host", os.environ.get("BAIKAL_HOST", "localhost"))
34-
config.setdefault("port", int(os.environ.get("BAIKAL_PORT", "8800")))
33+
host = config.get("host") or os.environ.get("BAIKAL_HOST", "localhost")
34+
port = int(config.get("port") or os.environ.get("BAIKAL_PORT", "8800"))
35+
config.setdefault("host", host)
36+
config.setdefault("port", port)
3537
config.setdefault("username", os.environ.get("BAIKAL_USERNAME", "testuser"))
3638
config.setdefault("password", os.environ.get("BAIKAL_PASSWORD", "testpass"))
3739
# Set up Baikal-specific compatibility hints
3840
if "features" not in config:
3941
config["features"] = compatibility_hints.baikal.copy()
42+
# user1-user3 are pre-seeded in the committed db.sqlite for scheduling tests
43+
if "scheduling_users" not in config:
44+
base = f"http://{host}:{port}/dav.php"
45+
config["scheduling_users"] = [
46+
{"url": base, "username": f"user{i}", "password": f"testpass{i}"}
47+
for i in range(1, 4)
48+
]
4049
super().__init__(config)
4150

4251
def _default_port(self) -> int:
@@ -88,21 +97,35 @@ class CyrusTestServer(DockerTestServer):
8897
Cyrus IMAP server with CalDAV support in Docker.
8998
9099
Cyrus is a mail server that also supports CalDAV/CardDAV.
100+
The ghcr.io/cyrusimap/cyrus-docker-test-server image pre-creates
101+
user1-user5 (password 'x') with CalDAV scheduling support.
91102
"""
92103

93104
name = "Cyrus"
94105

95106
def __init__(self, config: dict[str, Any] | None = None) -> None:
96107
config = config or {}
97-
config.setdefault("host", os.environ.get("CYRUS_HOST", "localhost"))
98-
config.setdefault("port", int(os.environ.get("CYRUS_PORT", "8802")))
108+
host = config.get("host") or os.environ.get("CYRUS_HOST", "localhost")
109+
port = int(config.get("port") or os.environ.get("CYRUS_PORT", "8802"))
110+
config.setdefault("host", host)
111+
config.setdefault("port", port)
99112
config.setdefault("username", os.environ.get("CYRUS_USERNAME", "user1"))
100113
config.setdefault(
101114
"password", os.environ.get("CYRUS_PASSWORD", "any-password-seems-to-work")
102115
)
103116
# Set up Cyrus-specific compatibility hints
104117
if "features" not in config:
105118
config["features"] = compatibility_hints.cyrus.copy()
119+
# The docker image pre-creates user1-user5 with password 'x'
120+
if "scheduling_users" not in config:
121+
config["scheduling_users"] = [
122+
{
123+
"url": f"http://{host}:{port}/dav/calendars/user/user{i}",
124+
"username": f"user{i}",
125+
"password": "x",
126+
}
127+
for i in range(1, 4)
128+
]
106129
super().__init__(config)
107130

108131
def _default_port(self) -> int:

0 commit comments

Comments
 (0)