summaryrefslogtreecommitdiffstats
path: root/nixos/tests/gancio.nix
blob: 2f4e244f8cb956fde529810b7cf10808f36ad8f6 (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
82
83
84
85
{ pkgs, ... }:
let
  extraHosts = ''
    192.168.13.12 agenda.example.com
  '';
in
{
  name = "gancio";
  meta.maintainers = with pkgs.lib.maintainers; [ jbgi ];

  nodes = {
    server =
      { pkgs, ... }:
      {
        networking = {
          interfaces.eth1 = {
            ipv4.addresses = [
              {
                address = "192.168.13.12";
                prefixLength = 24;
              }
            ];
          };
          inherit extraHosts;
          firewall.allowedTCPPorts = [ 80 ];
        };
        environment.systemPackages = [ pkgs.gancio ];
        services.gancio = {
          enable = true;
          settings = {
            hostname = "agenda.example.com";
            db.dialect = "postgres";
          };
          plugins = [ pkgs.gancioPlugins.telegram-bridge ];
          userLocale = {
            en = {
              register = {
                description = "My new registration page description";
              };
            };
          };
          nginx = {
            enableACME = false;
            forceSSL = false;
          };
        };
      };

    client =
      { pkgs, ... }:
      {
        environment.systemPackages = [ pkgs.jq ];
        networking = {
          interfaces.eth1 = {
            ipv4.addresses = [
              {
                address = "192.168.13.1";
                prefixLength = 24;
              }
            ];
          };
          inherit extraHosts;
        };
      };
  };

  testScript = ''
    start_all()

    server.wait_for_unit("postgresql.target")
    server.wait_for_unit("gancio")
    server.wait_for_unit("nginx")
    server.wait_for_file("/run/gancio/socket")
    server.wait_for_open_port(80)

    # Check can create user via cli
    server.succeed("cd /var/lib/gancio && sudo -u gancio gancio users create admin dummy admin")

    # Check event list is returned
    client.wait_until_succeeds("curl --verbose --fail-with-body http://agenda.example.com/api/events", timeout=30)

    server.shutdown()
    client.shutdown()
  '';
}