2020-04-24 23:36:52 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ...} : {
|
|
|
|
name = "gotify-server";
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2023-10-19 13:55:26 +00:00
|
|
|
maintainers = [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
nodes.machine = { pkgs, ... }: {
|
2020-04-24 23:36:52 +00:00
|
|
|
environment.systemPackages = [ pkgs.jq ];
|
|
|
|
|
|
|
|
services.gotify = {
|
|
|
|
enable = true;
|
|
|
|
port = 3000;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
machine.start()
|
|
|
|
|
|
|
|
machine.wait_for_unit("gotify-server.service")
|
|
|
|
machine.wait_for_open_port(3000)
|
|
|
|
|
|
|
|
token = machine.succeed(
|
|
|
|
"curl --fail -sS -X POST localhost:3000/application -F name=nixos "
|
|
|
|
+ '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" '
|
|
|
|
+ "| jq .token | xargs echo -n"
|
|
|
|
)
|
|
|
|
|
|
|
|
usertoken = machine.succeed(
|
|
|
|
"curl --fail -sS -X POST localhost:3000/client -F name=nixos "
|
|
|
|
+ '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" '
|
|
|
|
+ "| jq .token | xargs echo -n"
|
|
|
|
)
|
|
|
|
|
|
|
|
machine.succeed(
|
|
|
|
f"curl --fail -sS -X POST 'localhost:3000/message?token={token}' -H 'Accept: application/json' "
|
|
|
|
+ "-F title=Gotify -F message=Works"
|
|
|
|
)
|
|
|
|
|
|
|
|
title = machine.succeed(
|
|
|
|
f"curl --fail -sS 'localhost:3000/message?since=0&token={usertoken}' | jq '.messages|.[0]|.title' | xargs echo -n"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert title == "Gotify"
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
# Ensure that the UI responds with a successful code and that the
|
2020-09-25 04:45:31 +00:00
|
|
|
# response is not empty
|
|
|
|
result = machine.succeed("curl -fsS localhost:3000")
|
|
|
|
assert result, "HTTP response from localhost:3000 must not be empty!"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
})
|