at master 1.5 kB view raw
1{ pkgs, lib, ... }: 2{ 3 name = "gotify-server"; 4 meta = with pkgs.lib.maintainers; { 5 maintainers = [ ]; 6 }; 7 8 nodes.machine = 9 { pkgs, ... }: 10 { 11 environment.systemPackages = [ pkgs.jq ]; 12 13 services.gotify = { 14 enable = true; 15 environment = { 16 GOTIFY_SERVER_PORT = 3000; 17 }; 18 }; 19 }; 20 21 testScript = '' 22 machine.start() 23 24 machine.wait_for_unit("gotify-server.service") 25 machine.wait_for_open_port(3000) 26 27 token = machine.succeed( 28 "curl --fail -sS -X POST localhost:3000/application -F name=nixos " 29 + '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" ' 30 + "| jq .token | xargs echo -n" 31 ) 32 33 usertoken = machine.succeed( 34 "curl --fail -sS -X POST localhost:3000/client -F name=nixos " 35 + '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" ' 36 + "| jq .token | xargs echo -n" 37 ) 38 39 machine.succeed( 40 f"curl --fail -sS -X POST 'localhost:3000/message?token={token}' -H 'Accept: application/json' " 41 + "-F title=Gotify -F message=Works" 42 ) 43 44 title = machine.succeed( 45 f"curl --fail -sS 'localhost:3000/message?since=0&token={usertoken}' | jq '.messages|.[0]|.title' | xargs echo -n" 46 ) 47 48 assert title == "Gotify" 49 50 # Ensure that the UI responds with a successful code and that the 51 # response is not empty 52 result = machine.succeed("curl -fsS localhost:3000") 53 assert result, "HTTP response from localhost:3000 must not be empty!" 54 ''; 55}