1let
2 user = "someuser";
3 password = "some_password";
4 port = builtins.toString 5232;
5in
6 import ./make-test.nix ({ pkgs, lib, ... }: {
7 name = "radicale";
8 meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
9
10 machine = {
11 services.radicale = {
12 enable = true;
13 config = ''
14 [auth]
15 type = htpasswd
16 htpasswd_filename = /etc/radicale/htpasswd
17 htpasswd_encryption = bcrypt
18
19 [storage]
20 filesystem_folder = /tmp/collections
21
22 [logging]
23 debug = True
24 '';
25 };
26 # WARNING: DON'T DO THIS IN PRODUCTION!
27 # This puts secrets (albeit hashed) directly into the Nix store for ease of testing.
28 environment.etc."radicale/htpasswd".source = pkgs.runCommand "htpasswd" {} ''
29 ${pkgs.apacheHttpd}/bin/htpasswd -bcB "$out" ${user} ${password}
30 '';
31 };
32
33 # This tests whether the web interface is accessible to an authenticated user
34 testScript = ''
35 $machine->waitForUnit('radicale.service');
36 $machine->waitForOpenPort(${port});
37 $machine->succeed('curl --fail http://${user}:${password}@localhost:${port}/.web/');
38 '';
39})