mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 09:23:01 +00:00
4a559f8fee
In version 2.0.15 `gotify` switched to `packr` at 2.x which is why the UI can't be served properly via HTTP and causes an empty 500 response and the following errors in `journald`: ``` 2020/09/12 19:18:33 [Recovery] 2020/09/12 - 19:18:33 panic recovered: GET / HTTP/1.1 Host: localhost:8080 Accept: */* User-Agent: curl/7.72.0 stat /home/ma27/Projects/ui/build/index.html: no such file or directory ``` This wasn't caught by the VM-test as it only tested the REST and push APIs. Using their internal `packr.go` script in our build as it's the case in the upstream build-system[1] fixes the issue. [1] https://github.com/gotify/server/pull/277/files#diff-b67911656ef5d18c4ae36cb6741b7965R48
51 lines
1.5 KiB
Nix
51 lines
1.5 KiB
Nix
import ./make-test-python.nix ({ pkgs, lib, ...} : {
|
|
name = "gotify-server";
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
|
maintainers = [ ma27 ];
|
|
};
|
|
|
|
machine = { pkgs, ... }: {
|
|
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"
|
|
|
|
# Ensure that the UI responds with a successfuly 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!"
|
|
'';
|
|
})
|