at 24.11-pre 1.7 kB view raw
1import ./make-test-python.nix { 2 name = "nginx-etag-compression"; 3 4 nodes.machine = { pkgs, lib, ... }: { 5 services.nginx = { 6 enable = true; 7 recommendedGzipSettings = true; 8 virtualHosts.default = { 9 root = pkgs.runCommandLocal "testdir" {} '' 10 mkdir "$out" 11 cat > "$out/index.html" <<EOF 12 Hello, world! 13 Hello, world! 14 Hello, world! 15 Hello, world! 16 Hello, world! 17 Hello, world! 18 Hello, world! 19 Hello, world! 20 EOF 21 ${pkgs.gzip}/bin/gzip -k "$out/index.html" 22 ''; 23 }; 24 }; 25 }; 26 27 testScript = { nodes, ... }: '' 28 machine.wait_for_unit("nginx") 29 machine.wait_for_open_port(80) 30 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/") 33 34 with subtest("different representations have different etags"): 35 assert etag_plain != etag_gzip, f"etags should differ: {etag_plain} == {etag_gzip}" 36 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}" 40 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}" 44 ''; 45}