Files
nixpkgs/nixos/tests/ntfy-sh.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

43 lines
1.3 KiB
Nix

import ./make-test-python.nix (
{ pkgs, ... }:
{
name = "ntfy-sh";
nodes.machine =
{ ... }:
{
services.ntfy-sh.enable = true;
services.ntfy-sh.settings.base-url = "http://localhost:2586";
# Create a user with user:123
services.ntfy-sh.environmentFile = pkgs.writeText "ntfy.env" ''
NTFY_AUTH_DEFAULT_ACCESS='deny-all'
NTFY_AUTH_USERS='user:$2a$12$W2v7IQhkayvJOYRpg6YEruxj.jUO3R2xQOU7s1vC3HzLLB9gSKJ9.:user'
NTFY_AUTH_ACCESS='user:test:rw'
'';
};
testScript = ''
import json
msg = "Test notification"
machine.wait_for_unit("multi-user.target")
machine.wait_for_open_port(2586)
machine.succeed(f"curl -u user:1234 -d '{msg}' localhost:2586/test")
# If we have a user, receive a message
notif = json.loads(machine.succeed("curl -u user:1234 -s localhost:2586/test/json?poll=1"))
assert msg == notif["message"], "Wrong message"
# If we have no user, we should get forbidden, making sure the default access config works
notif = json.loads(machine.succeed("curl -s localhost:2586/test/json?poll=1"))
assert 403 == notif["http"], f"Should return 403, got {notif["http"]}"
machine.succeed("ntfy user list")
'';
}
)