nixpkgs/nixos/tests/gotify-server.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.6 KiB
Nix
Raw Normal View History

import ./make-test-python.nix (
{ pkgs, lib, ... }:
{
2019-10-25 13:14:57 +00:00
name = "gotify-server";
meta = with pkgs.lib.maintainers; {
maintainers = [ ];
2019-10-25 13:14:57 +00:00
};
2022-03-20 23:15:30 +00:00
nodes.machine =
{ pkgs, ... }:
{
2019-10-25 13:14:57 +00:00
environment.systemPackages = [ pkgs.jq ];
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
};
};
};
2019-10-25 13:14:57 +00:00
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"
2023-05-20 02:10:21 +00:00
# Ensure that the UI responds with a successful code and that the
# 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
'';
}
)