depot/third_party/nixpkgs/nixos/tests/nginx-moreheaders.nix
Default email 23b612e36f Project import generated by Copybara.
GitOrigin-RevId: ae5c332cbb5827f6b1f02572496b141021de335f
2024-01-25 23:12:00 +09:00

37 lines
1.2 KiB
Nix

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