From 35b5939fee8e27e6253afea0e51cd9fdcb02aca0 Mon Sep 17 00:00:00 2001 From: Diogo Correia Date: Mon, 10 Feb 2025 13:39:09 +0000 Subject: [PATCH] nixos/tests/umami: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/web-apps/umami.nix | 45 +++++++++++++++++++++++++++++++ pkgs/by-name/um/umami/package.nix | 4 +++ 3 files changed, 50 insertions(+) create mode 100644 nixos/tests/web-apps/umami.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index fd7caf0bacf6..85088c6b29a9 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1489,6 +1489,7 @@ in ucarp = runTest ./ucarp.nix; udisks2 = runTest ./udisks2.nix; ulogd = runTest ./ulogd/ulogd.nix; + umami = runTest ./web-apps/umami.nix; umurmur = runTest ./umurmur.nix; unbound = runTest ./unbound.nix; unifi = runTest ./unifi.nix; diff --git a/nixos/tests/web-apps/umami.nix b/nixos/tests/web-apps/umami.nix new file mode 100644 index 000000000000..6004ae68226b --- /dev/null +++ b/nixos/tests/web-apps/umami.nix @@ -0,0 +1,45 @@ +{ lib, ... }: +{ + name = "umami-nixos"; + + meta.maintainers = with lib.maintainers; [ diogotcorreia ]; + + nodes.machine = + { pkgs, ... }: + { + services.umami = { + enable = true; + settings = { + APP_SECRET = "very_secret"; + }; + }; + }; + + testScript = '' + import json + + machine.wait_for_unit("umami.service") + + machine.wait_for_open_port(3000) + machine.succeed("curl --fail http://localhost:3000/") + machine.succeed("curl --fail http://localhost:3000/script.js") + + res = machine.succeed(""" + curl -f --json '{ "username": "admin", "password": "umami" }' http://localhost:3000/api/auth/login + """) + token = json.loads(res)['token'] + + res = machine.succeed(""" + curl -f -H 'Authorization: Bearer %s' --json '{ "domain": "localhost", "name": "Test" }' http://localhost:3000/api/websites + """ % token) + print(res) + websiteId = json.loads(res)['id'] + + res = machine.succeed(""" + curl -f -H 'Authorization: Bearer %s' http://localhost:3000/api/websites/%s + """ % (token, websiteId)) + website = json.loads(res) + assert website["name"] == "Test" + assert website["domain"] == "localhost" + ''; +} diff --git a/pkgs/by-name/um/umami/package.nix b/pkgs/by-name/um/umami/package.nix index 1827473b1a52..bcbc6140f01b 100644 --- a/pkgs/by-name/um/umami/package.nix +++ b/pkgs/by-name/um/umami/package.nix @@ -4,6 +4,7 @@ fetchFromGitHub, fetchurl, makeWrapper, + nixosTests, nodejs, pnpm_10, prisma-engines, @@ -174,6 +175,9 @@ stdenvNoCC.mkDerivation (finalAttrs: { ''; passthru = { + tests = { + inherit (nixosTests) umami; + }; inherit sources geocities