1 import ./make-test-python.nix {
2 name = "nginx-etag-compression";
4 nodes.machine = { pkgs, lib, ... }: {
7 recommendedGzipSettings = true;
8 virtualHosts.default = {
9 root = pkgs.runCommandLocal "testdir" {} ''
11 cat > "$out/index.html" <<EOF
21 ${pkgs.gzip}/bin/gzip -k "$out/index.html"
27 testScript = { nodes, ... }: ''
28 machine.wait_for_unit("nginx")
29 machine.wait_for_open_port(80)
31 etag_plain = machine.succeed("curl -s -w'%header{etag}' -o/dev/null -H 'Accept-encoding:' http://127.0.0.1/")
32 etag_gzip = machine.succeed("curl -s -w'%header{etag}' -o/dev/null -H 'Accept-encoding:gzip' http://127.0.0.1/")
34 with subtest("different representations have different etags"):
35 assert etag_plain != etag_gzip, f"etags should differ: {etag_plain} == {etag_gzip}"
37 with subtest("etag for uncompressed response is reproducible"):
38 etag_plain_repeat = machine.succeed("curl -s -w'%header{etag}' -o/dev/null -H 'Accept-encoding:' http://127.0.0.1/")
39 assert etag_plain == etag_plain_repeat, f"etags should be the same: {etag_plain} != {etag_plain_repeat}"
41 with subtest("etag for compressed response is reproducible"):
42 etag_gzip_repeat = machine.succeed("curl -s -w'%header{etag}' -o/dev/null -H 'Accept-encoding:gzip' http://127.0.0.1/")
43 assert etag_gzip == etag_gzip_repeat, f"etags should be the same: {etag_gzip} != {etag_gzip_repeat}"