nixos/tests/nginx-sso: add subtests for each assertion

This commit is contained in:
Maximilian Bosch 2019-12-26 17:50:35 +01:00
parent abbce768dc
commit 495b0b581c
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E

View File

@ -32,15 +32,17 @@ import ./make-test-python.nix ({ pkgs, ... }: {
machine.wait_for_unit("nginx-sso.service")
machine.wait_for_open_port(8080)
# No valid user -> 401.
machine.fail("curl -sSf http://localhost:8080/auth")
with subtest("No valid user -> 401"):
machine.fail("curl -sSf http://localhost:8080/auth")
# Valid user but no matching ACL -> 403.
machine.fail("curl -sSf -H 'Authorization: Token MyToken' 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"
)
# Valid user and matching ACL -> 200.
machine.succeed(
"curl -sSf -H 'Authorization: Token MyToken' -H 'X-Application: MyApp' 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"
)
'';
})