nixos/tests/nginx: add test variant for moreheaders module

This commit is contained in:
Sandro Jäckel 2024-01-15 17:25:21 +01:00 committed by Yaya
parent 156d23e183
commit ee0312bcff
2 changed files with 38 additions and 0 deletions

View File

@ -587,6 +587,7 @@ in {
nginx-globalredirect = handleTest ./nginx-globalredirect.nix {}; nginx-globalredirect = handleTest ./nginx-globalredirect.nix {};
nginx-http3 = handleTest ./nginx-http3.nix {}; nginx-http3 = handleTest ./nginx-http3.nix {};
nginx-modsecurity = handleTest ./nginx-modsecurity.nix {}; nginx-modsecurity = handleTest ./nginx-modsecurity.nix {};
nginx-moreheaders = handleTest ./nginx-moreheaders.nix {};
nginx-njs = handleTest ./nginx-njs.nix {}; nginx-njs = handleTest ./nginx-njs.nix {};
nginx-proxyprotocol = handleTest ./nginx-proxyprotocol {}; nginx-proxyprotocol = handleTest ./nginx-proxyprotocol {};
nginx-pubhtml = handleTest ./nginx-pubhtml.nix {}; nginx-pubhtml = handleTest ./nginx-pubhtml.nix {};

View 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\"")
'';
}