about summary refs log tree commit diff
path: root/smoke-test.nix
diff options
context:
space:
mode:
Diffstat (limited to 'smoke-test.nix')
-rw-r--r--smoke-test.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/smoke-test.nix b/smoke-test.nix
new file mode 100644
index 0000000..fbbc8a7
--- /dev/null
+++ b/smoke-test.nix
@@ -0,0 +1,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'")
+'';
+}