summaryrefslogtreecommitdiffstats
path: root/nixos/tests/limesurvey.nix
blob: 3e24040c9903d0ed5046c524e06064dacf3973e5 (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
{ lib, pkgs, ... }:

{
  name = "limesurvey";
  meta.maintainers = [ lib.maintainers.aanderse ];

  nodes.machine = {
    services.limesurvey = {
      enable = true;
      httpd.virtualHost = {
        hostName = "example.local";
        adminAddr = "root@example.local";
      };
      encryptionKeyFile = pkgs.writeText "key" (lib.strings.replicate 32 "0");
      encryptionNonceFile = pkgs.writeText "nonce" (lib.strings.replicate 24 "0");
    };

    # limesurvey won't work without a dot in the hostname
    networking.hosts."127.0.0.1" = [ "example.local" ];

    specialisation.nginx = {
      inheritParentConfig = true;
      configuration.services.limesurvey = {
        webserver = "nginx";
        nginx.virtualHost.serverName = "example.local";
      };
    };
  };

  testScript =
    { nodes, ... }:
    ''
      def test():
        machine.wait_until_succeeds("curl --fail --silent http://example.local/ | grep -q 'The following surveys are available'")

      start_all()

      machine.wait_for_unit("phpfpm-limesurvey.service")
      machine.wait_for_unit("httpd.service")
      machine.wait_for_open_port(80)
      test()

      machine.execute("${nodes.machine.system.build.toplevel}/specialisation/nginx/bin/switch-to-configuration test")

      machine.wait_for_unit("nginx.service")
      test()


    '';
}