Files
nixpkgs/nixos/tests/nginx-sso.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

60 lines
1.3 KiB
Nix

{ pkgs, ... }:
{
name = "nginx-sso";
meta = {
maintainers = with pkgs.lib.maintainers; [ ambroisie ];
};
nodes.machine = {
services.nginx.sso = {
enable = true;
configuration = {
listen = {
addr = "127.0.0.1";
port = 8080;
};
providers.token.tokens = {
myuser = {
_secret = pkgs.writeText "secret-token" "MyToken";
};
};
acl = {
rule_sets = [
{
rules = [
{
field = "x-application";
equals = "MyApp";
}
];
allow = [ "myuser" ];
}
];
};
};
};
};
testScript = ''
start_all()
machine.wait_for_unit("nginx-sso.service")
machine.wait_for_open_port(8080)
with subtest("No valid user -> 401"):
machine.fail("curl -sSf http://localhost:8080/auth")
with subtest("Valid user but no matching ACL -> 403"):
machine.fail(
"curl -sSf -H 'Authorization: Token MyToken' http://localhost:8080/auth"
)
with subtest("Valid user and matching ACL -> 200"):
machine.succeed(
"curl -sSf -H 'Authorization: Token MyToken' -H 'X-Application: MyApp' http://localhost:8080/auth"
)
'';
}