about summary refs log tree commit diff
path: root/smoke-test.nix
blob: fbbc8a7f4f26c9c1ef77b20dce73af6673d9efa6 (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
kittybox:
{ lib, ... }: {
  name = "nixos-kittybox";

  nodes = {
    kittybox = { config, pkgs, lib, ... }: {
      imports = [ kittybox.nixosModules.default ];

      services.kittybox = {
        enable = true;
        # It never actually contacts those endpoints anyway unless we use Micropub so it's fine!
        # TODO: Once we have self-hosted software for those endpoints,
        #       make an e2e test for common workflows (e.g. making a post)
        tokenEndpoint = "https://example.com";
        authorizationEndpoint = "https://example.com";
        logLevel = "info,kittybox=debug,retainer::cache=warn,h2=warn,rustls=warn";
      };

      environment.systemPackages = with pkgs; [
        curl
      ];
    };
  };

  testScript = ''
    with subtest("Verify that Kittybox started correctly..."):
        kittybox.wait_for_open_port(8080)
        kittybox.succeed("curl --silent http://localhost:8080/micropub")

    with subtest("Onboarding should correctly work..."):
        kittybox.copy_from_host("${./onboarding.json}", "/root/onboarding.json")
        kittybox.succeed("curl -vvv http://localhost:8080/onboarding -d@/root/onboarding.json -H 'Content-Type: application/json'")
        # Testing for a known string is the easiest way to determine that the onboarding worked
        kittybox.succeed("curl --silent http://localhost:8080/ | grep 'vestige of the past long gone'")
'';
}