summaryrefslogtreecommitdiffstats
path: root/nixos/tests/flame.nix
blob: f770a66f8d296bd3100e5839d4351252f2b4f9b0 (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
{ lib, ... }:
{
  name = "flame";

  meta.maintainers = with lib.maintainers; [ DerGrumpf ];

  nodes.machine = {
    services.flame = {
      enable = true;
      passwordFile = "/etc/flame-password";

      apps = [
        {
          name = "Test App";
          url = "http://example.com";
        }
      ];

      categories = [
        {
          name = "Test Category";
          bookmarks = [
            {
              name = "Nixpkgs";
              url = "https://github.com/NixOS/nixpkgs";
            }
          ];
        }
      ];

      settings = {
        customTitle = "Test Flame";
        customUnknownKey = "test-value";
      };

      customCSS = ''
        body { background: #123456; }
      '';
    };

    systemd.tmpfiles.rules = [
      "f /etc/flame-password 0400 root root - testpassword"
    ];
  };

  testScript = ''
    machine.wait_for_unit("flame.service")
    machine.wait_for_open_port(5005)
    machine.succeed("curl -f http://localhost:5005/")

    machine.wait_for_unit("flame-seed.service")

    machine.succeed("curl -f http://localhost:5005/api/apps | grep -q 'Test App'")
    machine.succeed("curl -f http://localhost:5005/api/categories | grep -q 'Test Category'")
    machine.succeed("curl -f http://localhost:5005/api/categories | grep -q Nixpkgs")
    machine.succeed("curl -f http://localhost:5005/api/config | grep -q 'Test Flame'")
    machine.succeed("curl -f http://localhost:5005/flame.css | grep -q '#123456'")

    # Restart resilience
    machine.succeed("systemctl restart flame.service")
    machine.wait_for_unit("flame.service")
    machine.wait_for_open_port(5005)
    machine.succeed("curl -f http://localhost:5005/api/apps | grep -q 'Test App'")

    # Freeform settings pass-through (unknown key, not explicitly declared)
    machine.succeed("curl -f http://localhost:5005/api/config | grep -q customUnknownKey")
  '';
}