summaryrefslogtreecommitdiffstats
path: root/nixos/tests/lanraragi.nix
blob: 23809b22be9b9e440614c8d511859e46f8b2e4b8 (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
{ pkgs, lib, ... }:
{
  name = "lanraragi";
  meta.maintainers = with lib.maintainers; [ tomasajt ];

  nodes = {
    machine1 =
      { pkgs, ... }:
      {
        # needed for the cache
        virtualisation.memorySize = 4096;

        services.lanraragi.enable = true;
      };
    machine2 =
      { pkgs, ... }:
      {
        # needed for the cache
        virtualisation.memorySize = 4096;

        services.lanraragi = {
          enable = true;
          passwordFile = pkgs.writeText "lrr-test-pass" ''
            Ultra-secure-p@ssword-"with-spec1al\chars
          '';
          port = 4000;
          redis = {
            port = 4001;
            passwordFile = pkgs.writeText "redis-lrr-test-pass" ''
              123-redis-PASS
            '';
          };
        };
      };
  };

  testScript = ''
    start_all()

    machine1.wait_for_unit("lanraragi.service")
    machine1.wait_until_succeeds("curl -f localhost:3000")
    machine1.succeed("[ $(curl -o /dev/null -X post 'http://localhost:3000/login' --data-raw 'password=kamimamita' -w '%{http_code}') -eq 302 ]")

    machine2.wait_for_unit("lanraragi.service")
    machine2.wait_until_succeeds("curl -f localhost:4000")
    machine2.succeed("[ $(curl -o /dev/null -X post 'http://localhost:4000/login' --data-raw 'password=Ultra-secure-p@ssword-\"with-spec1al\\chars' -w '%{http_code}') -eq 302 ]")
  '';
}