2019-11-24 12:21:16 +00:00
|
|
|
import ./make-test-python.nix (
|
|
|
|
{ pkgs, lib, ... }:
|
|
|
|
{
|
2019-10-25 13:14:57 +00:00
|
|
|
name = "gotify-server";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2023-10-18 17:58:47 +00:00
|
|
|
maintainers = [ ];
|
2019-10-25 13:14:57 +00:00
|
|
|
};
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2022-03-20 23:15:30 +00:00
|
|
|
nodes.machine =
|
|
|
|
{ pkgs, ... }:
|
2024-12-10 19:26:33 +00:00
|
|
|
{
|
2019-10-25 13:14:57 +00:00
|
|
|
environment.systemPackages = [ pkgs.jq ];
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2019-10-25 13:14:57 +00:00
|
|
|
services.gotify = {
|
|
|
|
enable = true;
|
2024-07-30 21:40:17 +00:00
|
|
|
environment = {
|
|
|
|
GOTIFY_SERVER_PORT = 3000;
|
2019-10-25 13:14:57 +00:00
|
|
|
};
|
2024-12-10 19:26:33 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-10-25 13:14:57 +00:00
|
|
|
testScript = ''
|
2019-11-24 12:21:16 +00:00
|
|
|
machine.start()
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2019-11-24 12:21:16 +00:00
|
|
|
machine.wait_for_unit("gotify-server.service")
|
|
|
|
machine.wait_for_open_port(3000)
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2019-11-24 12:21:16 +00:00
|
|
|
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"
|
|
|
|
)
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2019-11-24 12:21:16 +00:00
|
|
|
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"
|
|
|
|
)
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2019-11-24 12:21:16 +00:00
|
|
|
machine.succeed(
|
|
|
|
f"curl --fail -sS -X POST 'localhost:3000/message?token={token}' -H 'Accept: application/json' "
|
|
|
|
+ "-F title=Gotify -F message=Works"
|
|
|
|
)
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2019-11-24 12:21:16 +00:00
|
|
|
title = machine.succeed(
|
|
|
|
f"curl --fail -sS 'localhost:3000/message?since=0&token={usertoken}' | jq '.messages|.[0]|.title' | xargs echo -n"
|
|
|
|
)
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2019-11-24 12:21:16 +00:00
|
|
|
assert title == "Gotify"
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2023-05-20 02:10:21 +00:00
|
|
|
# Ensure that the UI responds with a successful code and that the
|
2020-09-12 17:02:09 +00:00
|
|
|
# response is not empty
|
|
|
|
result = machine.succeed("curl -fsS localhost:3000")
|
|
|
|
assert result, "HTTP response from localhost:3000 must not be empty!"
|
2019-10-25 13:14:57 +00:00
|
|
|
'';
|
|
|
|
}
|
|
|
|
)
|