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