diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2019-10-25 15:14:57 +0200 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2019-10-25 16:19:41 +0200 |
commit | 3461ec2ffdd51f298d9dd520974d998b153b3b6f (patch) | |
tree | 82d10bb0a991d10cd4a411bdb02130275d8893f4 /nixos/tests/gotify-server.nix | |
parent | a66e5106fd07bbf1d240dec02d9e50da153fe983 (diff) | |
download | nixpkgs-3461ec2ffdd51f298d9dd520974d998b153b3b6f.tar nixpkgs-3461ec2ffdd51f298d9dd520974d998b153b3b6f.tar.gz nixpkgs-3461ec2ffdd51f298d9dd520974d998b153b3b6f.tar.bz2 nixpkgs-3461ec2ffdd51f298d9dd520974d998b153b3b6f.tar.lz nixpkgs-3461ec2ffdd51f298d9dd520974d998b153b3b6f.tar.xz nixpkgs-3461ec2ffdd51f298d9dd520974d998b153b3b6f.tar.zst nixpkgs-3461ec2ffdd51f298d9dd520974d998b153b3b6f.zip |
nixos/gotify: init module and test
Diffstat (limited to 'nixos/tests/gotify-server.nix')
-rw-r--r-- | nixos/tests/gotify-server.nix | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/nixos/tests/gotify-server.nix b/nixos/tests/gotify-server.nix new file mode 100644 index 00000000000..0ffc3138d5a --- /dev/null +++ b/nixos/tests/gotify-server.nix @@ -0,0 +1,45 @@ +import ./make-test.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 = '' + startAll; + + $machine->waitForUnit("gotify-server"); + $machine->waitForOpenPort(3000); + + my $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' + ); + + my $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( + "curl --fail -sS -X POST 'localhost:3000/message?token=$token' -H 'Accept: application/json' " . + '-F title=Gotify -F message=Works' + ); + + my $title = $machine->succeed( + "curl --fail -sS 'localhost:3000/message?since=0&token=$usertoken' | jq '.messages|.[0]|.title' | xargs echo -n" + ); + + $title eq "Gotify" or die "Wrong title ($title), expected 'Gotify'!"; + ''; +}) |