From 418a78aff409276560b9b177aa30a4dc771bde91 Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Wed, 26 May 2021 18:02:50 +0000 Subject: [PATCH] Add an HTTP/2 304 "Not Modified" AuTest. This adds an HTTP/2 304 "Not Modified" test to verify that we handle it correctly. --- .../gold_tests/headers/cachedIMSRange.test.py | 59 +++++++++++++++---- tests/gold_tests/headers/gold/http1_304.gold | 10 ++++ tests/gold_tests/headers/gold/http2_304.gold | 10 ++++ 3 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 tests/gold_tests/headers/gold/http1_304.gold create mode 100644 tests/gold_tests/headers/gold/http2_304.gold diff --git a/tests/gold_tests/headers/cachedIMSRange.test.py b/tests/gold_tests/headers/cachedIMSRange.test.py index 6d854de690b..074a751b65f 100644 --- a/tests/gold_tests/headers/cachedIMSRange.test.py +++ b/tests/gold_tests/headers/cachedIMSRange.test.py @@ -81,16 +81,34 @@ server.addResponse("sessionlog.json", request_etagfill_header, response_etagfill_header) # ATS Configuration -ts = Test.MakeATSProcess("ts") +ts = Test.MakeATSProcess("ts", enable_tls=True) ts.Disk.plugin_config.AddLine('xdebug.so') +ts.addDefaultSSLFiles() +ts.Disk.ssl_multicert_config.AddLine( + 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' +) ts.Disk.records_config.update({ 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'http', 'proxy.config.http.response_via_str': 3, + 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), + 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), }) -ts.Disk.remap_config.AddLine( - 'map / http://127.0.0.1:{0}'.format(server.Variables.Port) +default_304_host = 'www.default304.test' +regex_remap_conf_file = "maps.reg" +ts.Disk.remap_config.AddLines([ + f'map https://{default_304_host}/ http://127.0.0.1:{server.Variables.Port}/ ' + f'@plugin=regex_remap.so @pparam={regex_remap_conf_file} @pparam=no-query-string @pparam=host', + + f'map http://{default_304_host}/ http://127.0.0.1:{server.Variables.Port}/ ' + f'@plugin=regex_remap.so @pparam={regex_remap_conf_file} @pparam=no-query-string @pparam=host', + + f'map / http://127.0.0.1:{server.Variables.Port}', +]) + +ts.Disk.MakeConfigFile(regex_remap_conf_file).AddLine( + f'//.*/ http://127.0.0.1:{server.Variables.Port} @status=304' ) # Test 0 - Fill a 3 byte object with Last-Modified time into cache. @@ -128,7 +146,28 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 3 - Fill a new object with an Etag. Not checking the output here. +# Test 3 - Test 304 response served from a regex-remap rule with HTTP. +tr = Test.AddTestRun() +tr.Processes.Default.Command = f'curl -vs http://127.0.0.1:{ts.Variables.port}/ -H "Host: {default_304_host}"' +tr.Processes.Default.ReturnCode = 0 +tr.Processes.Default.Streams.All = Testers.GoldFile("gold/http1_304.gold", case_insensitive=True) +tr.StillRunningAfter = server + +# Test 4 - Test 304 response served from a regex-remap rule with HTTPS. +tr = Test.AddTestRun() +tr.Processes.Default.Command = f'curl -vs -k https://127.0.0.1:{ts.Variables.ssl_port}/ -H "Host: {default_304_host}"' +tr.Processes.Default.ReturnCode = 0 +tr.Processes.Default.Streams.All = Testers.GoldFile("gold/http1_304.gold", case_insensitive=True) +tr.StillRunningAfter = server + +# Test 5 - Test 304 response served from a regex-remap rule with HTTP/2. +tr = Test.AddTestRun() +tr.Processes.Default.Command = f'curl -vs -k --http2 https://127.0.0.1:{ts.Variables.ssl_port}/ -H "Host: {default_304_host}"' +tr.Processes.Default.ReturnCode = 0 +tr.Processes.Default.Streams.All = Testers.GoldFile("gold/http2_304.gold", case_insensitive=True) +tr.StillRunningAfter = server + +# Test 6 - Fill a new object with an Etag. Not checking the output here. tr = Test.AddTestRun() tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: EtagFill" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( ts.Variables.port) @@ -136,7 +175,7 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 4 - Once the etag object goes stale, fetch it again. We expect +# Test 7 - Once the etag object goes stale, fetch it again. We expect # Origin to get INM request, and serve a 304. We expect ATS to refresh the # object, and give a 200 to user tr = Test.AddTestRun() @@ -148,7 +187,7 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 5 - Once the etag object goes stale, fetch it via a range request. +# Test 8 - Once the etag object goes stale, fetch it via a range request. # We expect Origin to get INM request, and serve a 304. We expect ATS to # refresh the object, and give a 206 to user tr = Test.AddTestRun() @@ -160,7 +199,7 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 6 - The origin changes the initial LMT object to 0 byte. We expect ATS to fetch and serve the new 0 byte object. +# Test 9 - The origin changes the initial LMT object to 0 byte. We expect ATS to fetch and serve the new 0 byte object. tr = Test.AddTestRun() tr.DelayStart = 3 tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: noBody" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format( @@ -170,7 +209,7 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 7 - Fetch the new 0 byte object again when fresh in cache to ensure its still a 0 byte object. +# Test 10 - Fetch the new 0 byte object again when fresh in cache to ensure its still a 0 byte object. tr = Test.AddTestRun() tr.DelayStart = 3 tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: noBody" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/'.format( @@ -180,7 +219,7 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 8 - The origin changes the etag object to 0 byte 404. We expect ATS to fetch and serve the 404 0 byte object. +# Test 11 - The origin changes the etag object to 0 byte 404. We expect ATS to fetch and serve the 404 0 byte object. tr = Test.AddTestRun() tr.DelayStart = 2 tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: EtagError" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( @@ -190,7 +229,7 @@ tr.StillRunningAfter = ts tr.StillRunningAfter = server -# Test 9 - Fetch the 0 byte etag object again when fresh in cache to ensure its still a 0 byte object +# Test 12 - Fetch the 0 byte etag object again when fresh in cache to ensure its still a 0 byte object tr = Test.AddTestRun() tr.DelayStart = 2 tr.Processes.Default.Command = 'curl -s -D - -v --ipv4 --http1.1 -H"UID: EtagError" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{0}/etag'.format( diff --git a/tests/gold_tests/headers/gold/http1_304.gold b/tests/gold_tests/headers/gold/http1_304.gold new file mode 100644 index 00000000000..3740c2395f9 --- /dev/null +++ b/tests/gold_tests/headers/gold/http1_304.gold @@ -0,0 +1,10 @@ +`` +> GET / HTTP/`` +> Host: www.default304.test +> User-Agent: curl/`` +> Accept: */* +`` +< HTTP/`` 304`` +< date: `` +< server: ATS/`` +`` diff --git a/tests/gold_tests/headers/gold/http2_304.gold b/tests/gold_tests/headers/gold/http2_304.gold new file mode 100644 index 00000000000..f5c3599828b --- /dev/null +++ b/tests/gold_tests/headers/gold/http2_304.gold @@ -0,0 +1,10 @@ +`` +> GET / HTTP/2 +> Host: www.default304.test +> User-Agent: curl/`` +> Accept: */* +`` +< HTTP/2 304`` +< date: `` +< server: ATS/`` +``