mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
nixos/tests/nginx: add test variant for moreheaders module
This commit is contained in:
parent
156d23e183
commit
ee0312bcff
@ -587,6 +587,7 @@ in {
|
||||
nginx-globalredirect = handleTest ./nginx-globalredirect.nix {};
|
||||
nginx-http3 = handleTest ./nginx-http3.nix {};
|
||||
nginx-modsecurity = handleTest ./nginx-modsecurity.nix {};
|
||||
nginx-moreheaders = handleTest ./nginx-moreheaders.nix {};
|
||||
nginx-njs = handleTest ./nginx-njs.nix {};
|
||||
nginx-proxyprotocol = handleTest ./nginx-proxyprotocol {};
|
||||
nginx-pubhtml = handleTest ./nginx-pubhtml.nix {};
|
||||
|
37
nixos/tests/nginx-moreheaders.nix
Normal file
37
nixos/tests/nginx-moreheaders.nix
Normal file
@ -0,0 +1,37 @@
|
||||
import ./make-test-python.nix {
|
||||
name = "nginx-more-headers";
|
||||
|
||||
nodes = {
|
||||
webserver = { pkgs, ... }: {
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
|
||||
virtualHosts.test = {
|
||||
locations = {
|
||||
"/".return = "200 blub";
|
||||
"/some" = {
|
||||
return = "200 blub";
|
||||
extraConfig = ''
|
||||
more_set_headers "Referrer-Policy: no-referrer";
|
||||
'';
|
||||
};
|
||||
};
|
||||
extraConfig = ''
|
||||
more_set_headers "X-Powered-By: nixos";
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
webserver.wait_for_unit("nginx")
|
||||
webserver.wait_for_open_port(80)
|
||||
|
||||
webserver.succeed("curl --fail --resolve test:80:127.0.0.1 --head --verbose http://test | grep -q \"X-Powered-By: nixos\"")
|
||||
webserver.fail("curl --fail --resolve test:80:127.0.0.1 --head --verbose http://test | grep -q \"Referrer-Policy: no-referrer\"")
|
||||
|
||||
webserver.succeed("curl --fail --resolve test:80:127.0.0.1 --head --verbose http://test/some | grep -q \"X-Powered-By: nixos\"")
|
||||
webserver.succeed("curl --fail --resolve test:80:127.0.0.1 --head --verbose http://test/some | grep -q \"Referrer-Policy: no-referrer\"")
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue
Block a user