Skip to content

Commit b8d54a1

Browse files
tobixenclaude
andcommitted
Overhaul test infrastructure: Docker servers, fixture helpers, config migration
New Docker test servers: - CCS (Apple CalendarServer): full setup with caldavd.plist, auth config - Davis (sabre/dav): setup with SQLite migrations and user provisioning - DAViCal: add start/stop scripts and setup automation - Zimbra: Docker compose using zimbra/zcs-foss image (HTTPS, ~6 GB RAM) Existing Docker servers: - Update README files for Baikal, Cyrus, Nextcloud, SOGo Test configuration: - Add caldav_test_servers.yaml.example documenting YAML-based config - Update tests/test_servers/ framework: docker.py, config_loader.py, registry.py, base.py — add Zimbra/Davis/DAViCal/CCS registration - Add tests/test_servers/test_config_loader.py - Add tools/convert_conf_private.py migration helper Fixture helpers: - Consolidate _fixCalendar_ into get_or_create_test_calendar - Unify sync/async helpers; add cleanup of objects in pre-configured calendars - Simplify test cleanup: wipe calendars instead of tracking known objects - Accept CLASS:PUBLIC as a server-supplied default (relax assertion) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bd8e3c1 commit b8d54a1

39 files changed

Lines changed: 1918 additions & 338 deletions

tests/README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,24 @@ pytest tests/test_caldav_unit.py
3939
Test configuration uses YAML or JSON files. The configuration loader searches
4040
these locations in order:
4141

42-
1. `tests/test_servers.yaml`
43-
2. `tests/test_servers.json`
42+
1. `tests/caldav_test_servers.yaml`
43+
2. `tests/caldav_test_servers.json`
4444
3. `~/.config/caldav/test_servers.yaml`
4545
4. `~/.config/caldav/test_servers.json`
4646

4747
### Setting Up Test Configuration
4848

4949
1. Copy the example configuration:
5050
```bash
51-
cp tests/test_servers.yaml.example tests/test_servers.yaml
51+
cp tests/caldav_test_servers.yaml.example tests/caldav_test_servers.yaml
5252
```
5353

54-
2. Edit `test_servers.yaml` to enable/configure servers:
54+
2. If you want to populate it with private passwords, remember to protect it:
55+
```sh
56+
chmod og-r tests/caldav_test_servers.yaml
57+
```
58+
59+
3. Edit `caldav_test_servers.yaml` to enable/configure servers:
5560
```yaml
5661
test-servers:
5762
radicale:
@@ -99,7 +104,7 @@ If you have an existing `conf_private.py`, a migration script is provided:
99104
python tests/tools/convert_conf_private.py
100105
```
101106

102-
This generates a `test_servers.yaml` from your existing configuration.
107+
This generates a `caldav_test_servers.yaml` from your existing configuration.
103108
The old `conf_private.py` format is deprecated and will be removed in v3.0.
104109

105110
## Test Server Types
@@ -213,7 +218,7 @@ coverage html # Generate HTML report
213218

214219
If you see warnings about no test servers being configured:
215220

216-
1. Set up `test_servers.yaml` with your server details, or
221+
1. Set up `caldav_test_servers.yaml` with your server details, or
217222
2. Install embedded servers: `pip install radicale xandikos`, or
218223
3. Use the Docker test servers
219224

tests/_test_absolute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TestRadicale:
1515
def setup(self):
1616
URL = "http://localhost:8080/nicoe/perso/"
1717
self.client = caldav.DAVClient(URL)
18-
self.calendar = caldav.objects.Calendar(self.client, URL)
18+
self.calendar = caldav.Calendar(self.client, URL)
1919

2020
def test_eventslist(self):
2121
events = self.calendar.get_events()
@@ -36,7 +36,7 @@ class TestTryton:
3636
def setup(self):
3737
URL = "http://admin:admin@localhost:9080/caldav/Calendars/Test"
3838
self.client = caldav.DAVClient(URL)
39-
self.calendar = caldav.objects.Calendar(self.client, URL)
39+
self.calendar = caldav.Calendar(self.client, URL)
4040

4141
def test_eventslist(self):
4242
events = self.calendar.get_events()
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Test server configuration for caldav tests
2+
#
3+
# Copy this file to caldav_test_servers.yaml and customize for your setup.
4+
# See tests/README.md for documentation.
5+
#
6+
# Environment variables can be used with ${VAR} or ${VAR:-default} syntax.
7+
8+
test-servers:
9+
# =========================================================================
10+
# Embedded servers (run in-process, no external setup required)
11+
# =========================================================================
12+
13+
radicale:
14+
type: embedded
15+
enabled: true
16+
host: ${RADICALE_HOST:-localhost}
17+
port: ${RADICALE_PORT:-5232}
18+
username: user1
19+
password: ""
20+
21+
xandikos:
22+
type: embedded
23+
enabled: true
24+
host: ${XANDIKOS_HOST:-localhost}
25+
port: ${XANDIKOS_PORT:-8993}
26+
username: sometestuser
27+
password: ""
28+
29+
# =========================================================================
30+
# Docker servers (require docker-compose, see docker-test-servers/)
31+
# =========================================================================
32+
#
33+
# Set enabled to:
34+
# - true: always enable
35+
# - false: always disable
36+
# - "auto": enable if docker is available (default for docker servers)
37+
38+
baikal:
39+
type: docker
40+
enabled: ${TEST_BAIKAL:-auto}
41+
host: ${BAIKAL_HOST:-localhost}
42+
port: ${BAIKAL_PORT:-8800}
43+
username: ${BAIKAL_USERNAME:-testuser}
44+
password: ${BAIKAL_PASSWORD:-testpass}
45+
# Path within the CalDAV server
46+
# path: /dav.php
47+
48+
nextcloud:
49+
type: docker
50+
enabled: ${TEST_NEXTCLOUD:-false}
51+
host: ${NEXTCLOUD_HOST:-localhost}
52+
port: ${NEXTCLOUD_PORT:-8801}
53+
username: ${NEXTCLOUD_USERNAME:-testuser}
54+
password: ${NEXTCLOUD_PASSWORD:-testpass}
55+
56+
cyrus:
57+
type: docker
58+
enabled: ${TEST_CYRUS:-false}
59+
host: ${CYRUS_HOST:-localhost}
60+
port: ${CYRUS_PORT:-8802}
61+
username: ${CYRUS_USERNAME:-testuser@test.local}
62+
password: ${CYRUS_PASSWORD:-testpassword}
63+
64+
sogo:
65+
type: docker
66+
enabled: ${TEST_SOGO:-false}
67+
host: ${SOGO_HOST:-localhost}
68+
port: ${SOGO_PORT:-8803}
69+
username: ${SOGO_USERNAME:-testuser}
70+
password: ${SOGO_PASSWORD:-testpassword}
71+
72+
bedework:
73+
type: docker
74+
enabled: ${TEST_BEDEWORK:-false}
75+
host: ${BEDEWORK_HOST:-localhost}
76+
port: ${BEDEWORK_PORT:-8804}
77+
username: ${BEDEWORK_USERNAME:-admin}
78+
password: ${BEDEWORK_PASSWORD:-bedework}
79+
80+
davical:
81+
type: docker
82+
enabled: ${TEST_DAVICAL:-false}
83+
host: ${DAVICAL_HOST:-localhost}
84+
port: ${DAVICAL_PORT:-8805}
85+
username: ${DAVICAL_USERNAME:-testuser}
86+
password: ${DAVICAL_PASSWORD:-testpass}
87+
88+
davis:
89+
type: docker
90+
enabled: ${TEST_DAVIS:-false}
91+
host: ${DAVIS_HOST:-localhost}
92+
port: ${DAVIS_PORT:-8806}
93+
username: ${DAVIS_USERNAME:-testuser}
94+
password: ${DAVIS_PASSWORD:-testpass}
95+
96+
ccs:
97+
type: docker
98+
enabled: ${TEST_CCS:-false}
99+
host: ${CCS_HOST:-localhost}
100+
port: ${CCS_PORT:-8807}
101+
username: ${CCS_USERNAME:-user01}
102+
password: ${CCS_PASSWORD:-user01}
103+
104+
zimbra:
105+
type: docker
106+
enabled: ${TEST_ZIMBRA:-false}
107+
host: ${ZIMBRA_HOST:-zimbra-docker.zimbra.io}
108+
port: ${ZIMBRA_PORT:-8808}
109+
username: ${ZIMBRA_USERNAME:-testuser@zimbra.io}
110+
password: ${ZIMBRA_PASSWORD:-testpass}
111+
112+
# =========================================================================
113+
# External/private servers (your own CalDAV server)
114+
# =========================================================================
115+
#
116+
# Uncomment and configure to test against your own server:
117+
118+
# my-server:
119+
# type: external
120+
# enabled: true
121+
# url: ${CALDAV_URL:-https://caldav.example.com/dav/}
122+
# username: ${CALDAV_USERNAME}
123+
# password: ${CALDAV_PASSWORD}
124+
# # Optional: SSL verification (default: true)
125+
# ssl_verify: true
126+
# # Optional: specify server limitations/features
127+
# features:
128+
# - no-expand # Server doesn't support EXPAND
129+
# - no-sync-token # Server doesn't support sync tokens
130+
# - no-freebusy # Server doesn't support freebusy queries
131+
132+
# =========================================================================
133+
# RFC6638 scheduling test users (optional)
134+
# =========================================================================
135+
#
136+
# For testing calendar scheduling (meeting invites, etc.), define
137+
# multiple users that can send invites to each other:
138+
139+
# rfc6638_users:
140+
# - url: https://caldav.example.com/dav/user1/
141+
# username: user1
142+
# password: pass1
143+
# - url: https://caldav.example.com/dav/user2/
144+
# username: user2
145+
# password: pass2

tests/docker-test-servers/baikal/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ This Baikal instance comes **pre-configured** with:
5454

5555
## Disabling Baikal Tests
5656

57-
If you want to skip Baikal tests, create `tests/conf_private.py`:
57+
If you want to skip Baikal tests, set `enabled: false` for the `baikal` entry in `tests/caldav_test_servers.yaml`:
5858

59-
```python
60-
test_baikal = False
59+
```yaml
60+
baikal:
61+
type: docker
62+
enabled: false
6163
```
6264
65+
Or use the environment variable: `TEST_BAIKAL=false`.
66+
6367
Or simply don't install Docker - the tests will automatically skip Baikal if Docker is not available.
6468

6569
## GitHub Actions (CI/CD)
@@ -93,21 +97,18 @@ You can add more secrets in GitHub Actions settings for credentials.
9397

9498
### Test Configuration
9599

96-
The test suite will automatically detect and use Baikal if configured. Configuration is in:
97-
- `tests/conf_baikal.py` - Baikal-specific configuration
98-
- `tests/conf.py` - Main test configuration (add Baikal to `caldav_servers` list)
99-
100-
To enable Baikal testing, add to `tests/conf_private.py`:
100+
The test suite will automatically detect and use Baikal if configured. Configuration is in `tests/caldav_test_servers.yaml` (copy from `tests/caldav_test_servers.yaml.example` and customize).
101101

102-
```python
103-
from tests.conf_baikal import get_baikal_config
102+
To enable Baikal testing, set `enabled: true` (or `enabled: auto` to auto-detect Docker availability) in the YAML config:
104103

105-
# Add Baikal to test servers if available
106-
baikal_conf = get_baikal_config()
107-
if baikal_conf:
108-
caldav_servers.append(baikal_conf)
104+
```yaml
105+
baikal:
106+
type: docker
107+
enabled: true
109108
```
110109

110+
Or use the environment variable: `TEST_BAIKAL=true`.
111+
111112
## Troubleshooting
112113

113114
### Container won't start
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Apple CalendarServer (CCS) Test Server
2+
3+
Apple's CalendarServer (ccs-calendarserver) running in Docker for the caldav
4+
library test suite.
5+
6+
## Overview
7+
8+
- **Image**: `pluies/ccs-calendarserver:latest` (Debian Jessie, Python 2)
9+
- **Port**: 8807 (mapped to container's 8008)
10+
- **Users**: user01/user01, user02/user02, admin/admin
11+
- **Storage**: File-based (SQLite), ephemeral (tmpfs)
12+
13+
Note: Apple CalendarServer is archived/orphaned since 2019. This Docker image
14+
is based on Debian Jessie and Python 2. It's included for historical
15+
compatibility testing.
16+
17+
## Quick Start
18+
19+
```bash
20+
./start.sh
21+
```
22+
23+
## Stop
24+
25+
```bash
26+
./stop.sh
27+
```
28+
29+
## Configuration
30+
31+
- `conf/caldavd.plist` - Main server config (HTTP on port 8008, no SSL)
32+
- `conf/auth/accounts.xml` - User accounts (XML-based directory service)
33+
- `conf/auth/augments.xml` - Calendar/addressbook enablement
34+
- `conf/auth/resources.xml` - Resources (empty)
35+
- `conf/auth/proxies.xml` - Proxy delegates (empty)
36+
37+
## Architecture
38+
39+
CCS uses UID-based principal URLs:
40+
- Principal: `/principals/__uids__/{GUID}/`
41+
- Calendar home: `/calendars/__uids__/{GUID}/`
42+
43+
The server auto-initializes its data directory on first start. No setup script
44+
is needed — users are defined in `accounts.xml`.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Minimal accounts for caldav library test suite.
4+
Based on Apple ccs-calendarserver test accounts (Apache 2.0 license).
5+
-->
6+
<!DOCTYPE accounts SYSTEM "accounts.dtd">
7+
8+
<directory realm="Test Realm">
9+
<record>
10+
<uid>0C8BDE62-E600-4696-83D3-8B5ECABDFD2E</uid>
11+
<guid>0C8BDE62-E600-4696-83D3-8B5ECABDFD2E</guid>
12+
<short-name>admin</short-name>
13+
<password>admin</password>
14+
<full-name>Super User</full-name>
15+
<email>admin@example.com</email>
16+
</record>
17+
<record type="user">
18+
<uid>10000000-0000-0000-0000-000000000001</uid>
19+
<guid>10000000-0000-0000-0000-000000000001</guid>
20+
<short-name>user01</short-name>
21+
<password>user01</password>
22+
<full-name>User 01</full-name>
23+
<email>user01@example.com</email>
24+
</record>
25+
<record type="user">
26+
<uid>10000000-0000-0000-0000-000000000002</uid>
27+
<guid>10000000-0000-0000-0000-000000000002</guid>
28+
<short-name>user02</short-name>
29+
<password>user02</password>
30+
<full-name>User 02</full-name>
31+
<email>user02@example.com</email>
32+
</record>
33+
</directory>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE augments SYSTEM "augments.dtd">
3+
4+
<augments>
5+
<record>
6+
<uid>Default</uid>
7+
<enable-calendar>true</enable-calendar>
8+
<enable-addressbook>true</enable-addressbook>
9+
</record>
10+
</augments>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE proxies SYSTEM "proxies.dtd">
3+
4+
<proxies realm="Test Realm">
5+
</proxies>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE accounts SYSTEM "accounts.dtd">
3+
4+
<directory realm="Test Realm">
5+
</directory>

0 commit comments

Comments
 (0)