Skip to content

Commit 6c6da2f

Browse files
author
Hugo Osvaldo Barrera
committed
Test baikal using docker
1 parent b0d8fd3 commit 6c6da2f

File tree

10 files changed

+257
-4
lines changed

10 files changed

+257
-4
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "tests/storage/servers/baikal"]
2-
path = tests/storage/servers/baikal
3-
url = https://github.com/vdirsyncer/baikal-testserver
41
[submodule "tests/storage/servers/owncloud"]
52
path = tests/storage/servers/owncloud
63
url = https://github.com/vdirsyncer/owncloud-testserver

docker-compose.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ services:
1010
build: docker/radicale/
1111
ports:
1212
- '8001:8001'
13+
14+
baikal:
15+
build: docker/baikal/
16+
ports:
17+
- '8002:80'

docker/baikal/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Based on https://github.com/ckulka/baikal-docker
2+
# Sadly, we can't override the VOLUME it has set, and we want some static
3+
# config.
4+
FROM php:7.4-apache
5+
ENV VERSION 0.7.0
6+
7+
ADD https://github.com/sabre-io/Baikal/releases/download/$VERSION/baikal-$VERSION.zip .
8+
RUN apt-get update && apt-get install -y sqlite3 unzip
9+
RUN unzip -q baikal-$VERSION.zip -d /var/www/
10+
11+
RUN chown -R www-data:www-data /var/www/baikal && \
12+
docker-php-ext-install pdo pdo_mysql
13+
14+
COPY apache.conf /etc/apache2/sites-enabled/000-default.conf
15+
COPY start.sh /opt/
16+
RUN a2enmod rewrite
17+
18+
COPY baikal.yaml /var/www/baikal/config/baikal.yaml
19+
COPY configure.sql /configure.sql
20+
21+
RUN touch /var/www/baikal/Specific/INSTALL_DISABLED
22+
RUN cat /configure.sql | sqlite3 /var/www/baikal/Specific/db/db.sqlite
23+
24+
RUN chmod -R 777 /var/www/baikal/Specific/ /var/www/baikal/config/
25+
26+
CMD [ "sh", "/opt/start.sh" ]

docker/baikal/apache.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Shameless copied from https://github.com/ckulka/baikal-docker/blob/master/files/apache.conf
2+
3+
<VirtualHost *:80>
4+
5+
# InjectedServerAlias dav.example.org dav.example.io
6+
DocumentRoot /var/www/baikal/html
7+
8+
RewriteEngine On
9+
RewriteRule /.well-known/carddav /dav.php [R,L]
10+
RewriteRule /.well-known/caldav /dav.php [R,L]
11+
12+
<Directory "/var/www/baikal/html">
13+
Options None
14+
Options +FollowSymlinks
15+
AllowOverride All
16+
17+
# Confiugration for apache-2.2:
18+
Order allow,deny
19+
Allow from all
20+
21+
# Confiugration for apache-2.4:
22+
Require all granted
23+
</Directory>
24+
25+
</VirtualHost>

docker/baikal/baikal.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
system:
2+
configured_version: 0.7.0
3+
timezone: Europe/Paris
4+
card_enabled: true
5+
cal_enabled: true
6+
dav_auth_type: Basic
7+
admin_passwordhash: 6a890c3aa185845a4bee1e1caed92e1faaf2dec6772291dca301cef6782e3bce
8+
auth_realm: BaikalDAV
9+
invite_from: noreply@localhost
10+
database:
11+
sqlite_file: /var/www/baikal/Specific/db/db.sqlite
12+
mysql: false
13+
mysql_host: ''
14+
mysql_dbname: ''
15+
mysql_username: ''
16+
mysql_password: ''
17+
encryption_key: bdf3bec969736e122e6d5f72c282c49e
18+
configured_version: ''

docker/baikal/configure.sql

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
PRAGMA foreign_keys=OFF;
2+
BEGIN TRANSACTION;
3+
CREATE TABLE addressbooks (
4+
id integer primary key asc NOT NULL,
5+
principaluri text NOT NULL,
6+
displayname text,
7+
uri text NOT NULL,
8+
description text,
9+
synctoken integer DEFAULT 1 NOT NULL
10+
);
11+
INSERT INTO addressbooks VALUES(1,'principals/baikal','Default Address Book','default','Default Address Book for Baikal',1);
12+
CREATE TABLE cards (
13+
id integer primary key asc NOT NULL,
14+
addressbookid integer NOT NULL,
15+
carddata blob,
16+
uri text NOT NULL,
17+
lastmodified integer,
18+
etag text,
19+
size integer
20+
);
21+
CREATE TABLE addressbookchanges (
22+
id integer primary key asc NOT NULL,
23+
uri text,
24+
synctoken integer NOT NULL,
25+
addressbookid integer NOT NULL,
26+
operation integer NOT NULL
27+
);
28+
CREATE TABLE calendarobjects (
29+
id integer primary key asc NOT NULL,
30+
calendardata blob NOT NULL,
31+
uri text NOT NULL,
32+
calendarid integer NOT NULL,
33+
lastmodified integer NOT NULL,
34+
etag text NOT NULL,
35+
size integer NOT NULL,
36+
componenttype text,
37+
firstoccurence integer,
38+
lastoccurence integer,
39+
uid text
40+
);
41+
CREATE TABLE calendars (
42+
id integer primary key asc NOT NULL,
43+
synctoken integer DEFAULT 1 NOT NULL,
44+
components text NOT NULL
45+
);
46+
INSERT INTO calendars VALUES(1,1,'VEVENT,VTODO');
47+
CREATE TABLE calendarinstances (
48+
id integer primary key asc NOT NULL,
49+
calendarid integer,
50+
principaluri text,
51+
access integer,
52+
displayname text,
53+
uri text NOT NULL,
54+
description text,
55+
calendarorder integer,
56+
calendarcolor text,
57+
timezone text,
58+
transparent bool,
59+
share_href text,
60+
share_displayname text,
61+
share_invitestatus integer DEFAULT '2',
62+
UNIQUE (principaluri, uri),
63+
UNIQUE (calendarid, principaluri),
64+
UNIQUE (calendarid, share_href)
65+
);
66+
INSERT INTO calendarinstances VALUES(1,1,'principals/baikal',NULL,'Default calendar','default','Default calendar',0,'','Europe/Paris',NULL,NULL,NULL,2);
67+
CREATE TABLE calendarchanges (
68+
id integer primary key asc NOT NULL,
69+
uri text,
70+
synctoken integer NOT NULL,
71+
calendarid integer NOT NULL,
72+
operation integer NOT NULL
73+
);
74+
CREATE TABLE calendarsubscriptions (
75+
id integer primary key asc NOT NULL,
76+
uri text NOT NULL,
77+
principaluri text NOT NULL,
78+
source text NOT NULL,
79+
displayname text,
80+
refreshrate text,
81+
calendarorder integer,
82+
calendarcolor text,
83+
striptodos bool,
84+
stripalarms bool,
85+
stripattachments bool,
86+
lastmodified int
87+
);
88+
CREATE TABLE schedulingobjects (
89+
id integer primary key asc NOT NULL,
90+
principaluri text NOT NULL,
91+
calendardata blob,
92+
uri text NOT NULL,
93+
lastmodified integer,
94+
etag text NOT NULL,
95+
size integer NOT NULL
96+
);
97+
CREATE TABLE locks (
98+
id integer primary key asc NOT NULL,
99+
owner text,
100+
timeout integer,
101+
created integer,
102+
token text,
103+
scope integer,
104+
depth integer,
105+
uri text
106+
);
107+
CREATE TABLE principals (
108+
id INTEGER PRIMARY KEY ASC NOT NULL,
109+
uri TEXT NOT NULL,
110+
email TEXT,
111+
displayname TEXT,
112+
UNIQUE(uri)
113+
);
114+
INSERT INTO principals VALUES(1,'principals/baikal','[email protected]','Baikal');
115+
CREATE TABLE groupmembers (
116+
id INTEGER PRIMARY KEY ASC NOT NULL,
117+
principal_id INTEGER NOT NULL,
118+
member_id INTEGER NOT NULL,
119+
UNIQUE(principal_id, member_id)
120+
);
121+
CREATE TABLE propertystorage (
122+
id integer primary key asc NOT NULL,
123+
path text NOT NULL,
124+
name text NOT NULL,
125+
valuetype integer NOT NULL,
126+
value string
127+
);
128+
CREATE TABLE users (
129+
id integer primary key asc NOT NULL,
130+
username TEXT NOT NULL,
131+
digesta1 TEXT NOT NULL,
132+
UNIQUE(username)
133+
);
134+
INSERT INTO users VALUES(1,'baikal','3b0845b235b7e985ce5905ab8df45e1a');
135+
CREATE INDEX addressbookid_synctoken ON addressbookchanges (addressbookid, synctoken);
136+
CREATE INDEX calendarid_synctoken ON calendarchanges (calendarid, synctoken);
137+
CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri);
138+
CREATE UNIQUE INDEX path_property ON propertystorage (path, name);
139+
COMMIT;

docker/baikal/start.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
# Shameless copied from https://raw.githubusercontent.com/ckulka/baikal-docker/master/files/start.sh
3+
4+
# Inject ServerName and ServerAlias if specified
5+
APACHE_CONFIG="/etc/apache2/sites-available/000-default.conf"
6+
if [ ! -z ${BAIKAL_SERVERNAME+x} ]
7+
then
8+
sed -i "s/# InjectedServerName .*/ServerName $BAIKAL_SERVERNAME/g" $APACHE_CONFIG
9+
fi
10+
11+
if [ ! -z ${BAIKAL_SERVERALIAS+x} ]
12+
then
13+
sed -i "s/# InjectedServerAlias .*/ServerAlias $BAIKAL_SERVERALIAS/g" $APACHE_CONFIG
14+
fi
15+
16+
apache2-foreground

tests/storage/servers/baikal

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import pytest
2+
3+
4+
class ServerMixin:
5+
@pytest.fixture
6+
def get_storage_args(self, request, tmpdir, slow_create_collection):
7+
def inner(collection="test"):
8+
base_url = "http://127.0.0.1:8002/"
9+
args = {
10+
"url": base_url,
11+
"username": "baikal",
12+
"password": "baikal",
13+
}
14+
15+
if self.storage_class.fileext == '.vcf':
16+
args['url'] = base_url + "card.php/"
17+
else:
18+
args['url'] = base_url + "cal.php/"
19+
20+
if collection is not None:
21+
args = slow_create_collection(self.storage_class, args, collection)
22+
return args
23+
24+
return inner
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
docker-compose build baikal
4+
docker-compose up -d baikal

0 commit comments

Comments
 (0)