blob: 3213cfd61f09155df02756782a3b396ea76de2c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
{
pkgs,
lib,
...
}:
{
name = "rustical";
meta.maintainers = pkgs.rustical.meta.maintainers;
containers.machine =
{
config,
pkgs,
...
}:
{
services.rustical.enable = true;
services.nginx = {
enable = true;
virtualHosts."localhost" = {
locations."/" = {
proxyPass = "http://${config.services.rustical.settings.http.bind}";
};
};
};
systemd.services.nginx.serviceConfig.SupplementaryGroups = [ "rustical" ];
environment.systemPackages = with pkgs; [ calendar-cli ];
};
testScript =
{
containers,
...
}:
let
createPrincipalScript = pkgs.writeScript "rustical-create-principal" ''
#!${lib.getExe pkgs.expect}
spawn rustical principals create alice --password
expect "Enter your password:\r"
send "foobar\r"
expect eof
'';
calendarCliConfig = (pkgs.formats.json { }).generate "rustical-test-calendar-cli.json" {
default = {
caldav_user = "alice";
caldav_url = "http://localhost/caldav/";
calendar_url = "http://localhost/caldav/principal/alice";
};
testcal = {
inherits = "default";
calendar_url = "http://localhost/caldav/principal/alice/testcal";
};
};
in
# python
''
machine.wait_for_unit("rustical.service")
machine.wait_for_file("${lib.removePrefix "unix:" containers.machine.services.rustical.settings.http.bind}")
machine.wait_for_open_port(80)
with subtest("Smoketest"):
machine.succeed("curl --fail http://localhost")
with subtest("Create principal"):
machine.succeed("${createPrincipalScript}")
machine.succeed("rustical principals list | grep alice")
with subtest("Generate token for principal"):
machine.succeed("curl -f -c cookies.txt -d 'username=alice&password=foobar' http://localhost/frontend/login")
machine.succeed("curl -f -b cookies.txt -d 'name=mytoken' http://localhost/frontend/user/alice/app_token > token.txt")
with subtest("Interact with caldav"):
machine.succeed('calendar-cli --config-file ${calendarCliConfig} --caldav-pass "$(cat token.txt)" calendar create testcal')
machine.succeed('calendar-cli --config-file ${calendarCliConfig} --config-section testcal --caldav-pass "$(cat token.txt)" calendar add 2013-10-01 testevent')
machine.log(machine.execute("systemd-analyze security rustical.service | grep -v ✓")[1])
'';
}
|