at master 1.2 kB view raw
1{ lib, ... }: 2{ 3 name = "umami-nixos"; 4 5 meta.maintainers = with lib.maintainers; [ diogotcorreia ]; 6 7 nodes.machine = 8 { pkgs, ... }: 9 { 10 services.umami = { 11 enable = true; 12 settings = { 13 APP_SECRET = "very_secret"; 14 }; 15 }; 16 }; 17 18 testScript = '' 19 import json 20 21 machine.wait_for_unit("umami.service") 22 23 machine.wait_for_open_port(3000) 24 machine.succeed("curl --fail http://localhost:3000/") 25 machine.succeed("curl --fail http://localhost:3000/script.js") 26 27 res = machine.succeed(""" 28 curl -f --json '{ "username": "admin", "password": "umami" }' http://localhost:3000/api/auth/login 29 """) 30 token = json.loads(res)['token'] 31 32 res = machine.succeed(""" 33 curl -f -H 'Authorization: Bearer %s' --json '{ "domain": "localhost", "name": "Test" }' http://localhost:3000/api/websites 34 """ % token) 35 print(res) 36 websiteId = json.loads(res)['id'] 37 38 res = machine.succeed(""" 39 curl -f -H 'Authorization: Bearer %s' http://localhost:3000/api/websites/%s 40 """ % (token, websiteId)) 41 website = json.loads(res) 42 assert website["name"] == "Test" 43 assert website["domain"] == "localhost" 44 ''; 45}