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