diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index aaf1d0fc357b..d1105cca178e 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -798,7 +798,7 @@ in { nfs4 = handleTest ./nfs { version = 4; }; nghttpx = handleTest ./nghttpx.nix {}; nginx = runTest ./nginx.nix; - nginx-auth = handleTest ./nginx-auth.nix {}; + nginx-auth = runTest ./nginx-auth.nix; nginx-etag = handleTest ./nginx-etag.nix {}; nginx-etag-compression = handleTest ./nginx-etag-compression.nix {}; nginx-globalredirect = handleTest ./nginx-globalredirect.nix {}; diff --git a/nixos/tests/nginx-auth.nix b/nixos/tests/nginx-auth.nix index eb04b2571941..1042eee2e0ab 100644 --- a/nixos/tests/nginx-auth.nix +++ b/nixos/tests/nginx-auth.nix @@ -1,54 +1,52 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "nginx-auth"; +{ pkgs, ... }: +{ + name = "nginx-auth"; - nodes = { - webserver = - { pkgs, lib, ... }: - { - services.nginx = - let - root = pkgs.runCommand "testdir" { } '' - mkdir "$out" - echo hello world > "$out/index.html" - ''; - in - { - enable = true; + nodes = { + webserver = + { pkgs, lib, ... }: + { + services.nginx = + let + root = pkgs.runCommand "testdir" { } '' + mkdir "$out" + echo hello world > "$out/index.html" + ''; + in + { + enable = true; - virtualHosts.lockedroot = { - inherit root; - basicAuth.alice = "pwofa"; - }; + virtualHosts.lockedroot = { + inherit root; + basicAuth.alice = "pwofa"; + }; - virtualHosts.lockedsubdir = { - inherit root; - locations."/sublocation/" = { - alias = "${root}/"; - basicAuth.bob = "pwofb"; - }; + virtualHosts.lockedsubdir = { + inherit root; + locations."/sublocation/" = { + alias = "${root}/"; + basicAuth.bob = "pwofb"; }; }; - }; - }; + }; + }; + }; - testScript = '' - webserver.wait_for_unit("nginx") - webserver.wait_for_open_port(80) + testScript = '' + webserver.wait_for_unit("nginx") + webserver.wait_for_open_port(80) - webserver.fail("curl --fail --resolve lockedroot:80:127.0.0.1 http://lockedroot") - webserver.succeed( - "curl --fail --resolve lockedroot:80:127.0.0.1 http://alice:pwofa@lockedroot" - ) + webserver.fail("curl --fail --resolve lockedroot:80:127.0.0.1 http://lockedroot") + webserver.succeed( + "curl --fail --resolve lockedroot:80:127.0.0.1 http://alice:pwofa@lockedroot" + ) - webserver.succeed("curl --fail --resolve lockedsubdir:80:127.0.0.1 http://lockedsubdir") - webserver.fail( - "curl --fail --resolve lockedsubdir:80:127.0.0.1 http://lockedsubdir/sublocation/index.html" - ) - webserver.succeed( - "curl --fail --resolve lockedsubdir:80:127.0.0.1 http://bob:pwofb@lockedsubdir/sublocation/index.html" - ) - ''; - } -) + webserver.succeed("curl --fail --resolve lockedsubdir:80:127.0.0.1 http://lockedsubdir") + webserver.fail( + "curl --fail --resolve lockedsubdir:80:127.0.0.1 http://lockedsubdir/sublocation/index.html" + ) + webserver.succeed( + "curl --fail --resolve lockedsubdir:80:127.0.0.1 http://bob:pwofb@lockedsubdir/sublocation/index.html" + ) + ''; +}