1{ lib, ... }:
2
3{
4 name = "xandikos";
5
6 meta.maintainers = with lib.maintainers; [ _0x4A6F ];
7
8 nodes = {
9 xandikos_client = { };
10 xandikos_default = {
11 networking.firewall.allowedTCPPorts = [ 8080 ];
12 services.xandikos.enable = true;
13 };
14 xandikos_proxy = {
15 networking.firewall.allowedTCPPorts = [
16 80
17 8080
18 ];
19 services.xandikos.enable = true;
20 services.xandikos.address = "localhost";
21 services.xandikos.port = 8080;
22 services.xandikos.routePrefix = "/xandikos-prefix/";
23 services.xandikos.extraOptions = [
24 "--defaults"
25 ];
26 services.nginx = {
27 enable = true;
28 recommendedProxySettings = true;
29 virtualHosts."xandikos" = {
30 serverName = "xandikos.local";
31 basicAuth.xandikos = "snakeOilPassword";
32 locations."/xandikos/" = {
33 proxyPass = "http://localhost:8080/xandikos-prefix/";
34 };
35 };
36 };
37 };
38 };
39
40 testScript = ''
41 start_all()
42
43 with subtest("Xandikos default"):
44 xandikos_default.wait_for_unit("multi-user.target")
45 xandikos_default.wait_for_unit("xandikos.service")
46 xandikos_default.wait_for_open_port(8080)
47 xandikos_default.succeed("curl --fail http://localhost:8080/")
48 xandikos_default.succeed(
49 "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
50 )
51 xandikos_client.wait_for_unit("network.target")
52 xandikos_client.fail("curl --fail http://xandikos_default:8080/")
53
54 with subtest("Xandikos proxy"):
55 xandikos_proxy.wait_for_unit("multi-user.target")
56 xandikos_proxy.wait_for_unit("xandikos.service")
57 xandikos_proxy.wait_for_open_port(8080)
58 xandikos_proxy.succeed("curl --fail http://localhost:8080/")
59 xandikos_proxy.succeed(
60 "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
61 )
62 xandikos_client.wait_for_unit("network.target")
63 xandikos_client.fail("curl --fail http://xandikos_proxy:8080/")
64 xandikos_client.succeed(
65 "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos"
66 )
67 xandikos_client.succeed(
68 "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos"
69 )
70 '';
71}