summaryrefslogtreecommitdiffstats
path: root/nixos/tests/feishin/caddy.nix
blob: 1329c5fc3326cc7b5259aa965d90d3277ca35ebb (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
import ../make-test-python.nix (
  { lib, ... }:

  {
    name = "feishin-caddy";
    meta.maintainers = with lib.maintainers; [
      rharish
      BatteredBunny
    ];

    nodes.machine =
      { pkgs, ... }:
      {
        services.feishin = {
          enable = true;
          domain = "localhost:80";
          pathbase = "/feishin";
          settings = {
            ANALYTICS_DISABLED = "true";
          };
          caddy.enable = true;
          caddy.virtualHost.extraConfig = "tls internal";
        };
        # disable letsencrypt cert fetching
        services.caddy.globalConfig = "auto_https disable_certs";
      };

    testScript = ''
      machine.wait_for_unit("caddy.service")
      machine.wait_for_open_port(80)
      machine.succeed("curl -vvv --fail --show-error --silent --location --insecure http://localhost/feishin/")
      assert "<title>Feishin</title>" in machine.succeed("curl --fail --show-error --silent --location --insecure http://localhost/feishin/")
      assert "window.ANALYTICS_DISABLED = \"true\";" in machine.succeed("curl --fail --show-error --silent --location --insecure http://localhost/feishin/settings.js")
    '';
  }
)