about summary refs log tree commit diff
path: root/nixos/tests/engelsystem.nix
blob: 7be3b8a5a1fe20acf5b507f3eb9e28b61006827b (plain) (blame)
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
import ./make-test-python.nix (
  { pkgs, lib, ... }:
  {
    name = "engelsystem";
    meta = with pkgs.lib.maintainers; {
      maintainers = [ talyz ];
    };

    nodes.engelsystem =
      { ... }:
      {
        services.engelsystem = {
          enable = true;
          domain = "engelsystem";
          createDatabase = true;
        };
        networking.firewall.allowedTCPPorts = [ 80 443 ];
        environment.systemPackages = with pkgs; [
          xmlstarlet
          libxml2
        ];
      };

    testScript = ''
      engelsystem.start()
      engelsystem.wait_for_unit("phpfpm-engelsystem.service")
      engelsystem.wait_until_succeeds("curl engelsystem/login -sS -f")
      engelsystem.succeed(
          "curl engelsystem/login -sS -f -c cookie | xmllint -html -xmlout - >login"
      )
      engelsystem.succeed(
          "xml sel -T -t -m \"html/head/meta[@name='csrf-token']\" -v @content login >token"
      )
      engelsystem.succeed(
          "curl engelsystem/login -sS -f -b cookie -F 'login=admin' -F 'password=asdfasdf' -F '_token=<token' -L | xmllint -html -xmlout - >news"
      )
      engelsystem.succeed(
          "test 'News - Engelsystem' = \"$(xml sel -T -t -c html/head/title news)\""
      )
    '';
  })