about summary refs log tree commit diff
path: root/nixos-tests/smoke-test.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos-tests/smoke-test.nix')
-rw-r--r--nixos-tests/smoke-test.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/nixos-tests/smoke-test.nix b/nixos-tests/smoke-test.nix
new file mode 100644
index 0000000..b043a31
--- /dev/null
+++ b/nixos-tests/smoke-test.nix
@@ -0,0 +1,54 @@
+kittybox:
+{ lib, ... }: {
+  name = "nixos-kittybox";
+
+  nodes = {
+    kittybox = { config, pkgs, lib, ... }: {
+      imports = [ kittybox.nixosModules.default ];
+
+      services.postgresql = {
+        enable = true;
+        ensureDatabases = ["kittybox"];
+        ensureUsers = [ {
+          name = "kittybox";
+          ensurePermissions = {
+            "DATABASE kittybox" = "ALL PRIVILEGES";
+          };
+        } ];
+      };
+
+      systemd.services.kittybox.wants = [ "postgresql.service" ];
+      systemd.services.kittybox.after = [ "postgresql.service" ];
+      systemd.services.kittybox.wantedBy = lib.mkForce [];
+
+      services.kittybox = {
+        enable = true;
+        logLevel = "info,kittybox=debug,retainer::cache=warn,h2=warn,rustls=warn";
+      };
+
+      environment.systemPackages = with pkgs; [
+        xh
+      ];
+    };
+  };
+
+  # TODO: Make e2e tests for authentication endpoints and such
+  # Potentially using WebDriver
+  # Could also be implemented with fantoccini
+  testScript = ''
+    kittybox.wait_for_unit("default.target")
+    with subtest("Ensure that Kittybox service is socket activated..."):
+        kittybox.fail("systemctl is-active kittybox.service")
+        kittybox.succeed("systemctl is-active kittybox.socket")
+
+    with subtest("Verify that Kittybox starts correctly..."):
+        kittybox.succeed("xh --no-check-status http://localhost:8080/.kittybox/micropub")
+        kittybox.succeed("systemctl is-active kittybox.service")
+
+    with subtest("Onboarding should correctly work..."):
+        kittybox.copy_from_host("${./onboarding.json}", "/root/onboarding.json")
+        kittybox.succeed("xh --follow http://localhost:8080/.kittybox/onboarding -j @/root/onboarding.json")
+        # Testing for a known string is the easiest way to determine that the onboarding worked
+        kittybox.succeed("xh http://localhost:8080/ | grep 'vestige of the past long gone'")
+'';
+}