Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 49 additions & 10 deletions tests/gold_tests/headers/cachedIMSRange.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -128,15 +146,36 @@
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)
tr.Processes.Default.ReturnCode = 0
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()
Expand All @@ -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()
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions tests/gold_tests/headers/gold/http1_304.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
``
> GET / HTTP/``
> Host: www.default304.test
> User-Agent: curl/``
> Accept: */*
``
< HTTP/`` 304``
< date: ``
< server: ATS/``
``
10 changes: 10 additions & 0 deletions tests/gold_tests/headers/gold/http2_304.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
``
> GET / HTTP/2
> Host: www.default304.test
> User-Agent: curl/``
> Accept: */*
``
< HTTP/2 304``
< date: ``
< server: ATS/``
``