diff --git a/tests/gold_tests/autest-site/ats_replay.test.ext b/tests/gold_tests/autest-site/ats_replay.test.ext index 3028ac9edff..18cb2f9ff8e 100644 --- a/tests/gold_tests/autest-site/ats_replay.test.ext +++ b/tests/gold_tests/autest-site/ats_replay.test.ext @@ -32,11 +32,24 @@ def configure_ats(obj: 'TestRun', server: 'Process', ats_config: dict, dns: Opti :returns: The ATS process object. ''' name = ats_config.get('name', 'ts') - process_config = ats_config.get('process_config', {}) + process_config = ats_config.get('process_config', {}).copy() + disable_log_checks = process_config.pop('disable_log_checks', False) ts = obj.MakeATSProcess(name, **process_config) + if disable_log_checks: + ts.Disk.diags_log.Content = Testers.ExcludesExpression(r'(?!)', 'Default diags log checks are disabled.') + records_config = ats_config.get('records_config', {}) ts.Disk.records_config.update(records_config) + if process_config.get('enable_tls', False): + ts.addDefaultSSLFiles() + ts.Disk.records_config.update( + { + 'proxy.config.ssl.server.cert.path': ts.Variables.SSLDir, + 'proxy.config.ssl.server.private_key.path': ts.Variables.SSLDir, + }) + ts.Disk.ssl_multicert_config.AddLine('dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key') + # Configure plugin_config if specified. plugin_config = ats_config.get('plugin_config', []) for plugin_line in plugin_config: @@ -166,7 +179,8 @@ def ATSReplayTest(obj, replay_file: str): if not 'ats' in autest_config: raise ValueError(f"Replay file {replay_file} does not contain 'autest.ats' section") ats_config = autest_config['ats'] - enable_tls = ats_config.get('enable_tls', False) + process_config = ats_config.get('process_config', {}) + enable_tls = process_config.get('enable_tls', ats_config.get('enable_tls', False)) ts = configure_ats(tr, server=server, ats_config=ats_config, dns=dns) # Proxy Verifier Client configuration. diff --git a/tests/gold_tests/cache/replay/bg_fill.yaml b/tests/gold_tests/cache/replay/bg_fill.yaml index f01a4f47a4e..ac0a34b040f 100644 --- a/tests/gold_tests/cache/replay/bg_fill.yaml +++ b/tests/gold_tests/cache/replay/bg_fill.yaml @@ -25,13 +25,9 @@ meta: version: '1.0' sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - version: 4 + stack: http2 + tls: + sni: test_sni transactions: - client-request: frames: @@ -65,13 +61,9 @@ sessions: size: 11 - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - version: 4 + stack: http2 + tls: + sni: test_sni transactions: - client-request: delay: 3s diff --git a/tests/gold_tests/cache/replay/varied_transactions.replay.yaml b/tests/gold_tests/cache/replay/varied_transactions.replay.yaml index 94ae9e4ddc5..bb7c45bcd6f 100644 --- a/tests/gold_tests/cache/replay/varied_transactions.replay.yaml +++ b/tests/gold_tests/cache/replay/varied_transactions.replay.yaml @@ -372,11 +372,6 @@ sessions: # transaction. delay: 100ms - proxy-request: - headers: - fields: - - [ X-Vary-On-This, { value: sixth, as: equal } ] - # This should be served out of the cache and not reach the origin. server-response: <<: *404_response diff --git a/tests/gold_tests/chunked_encoding/replays/chunked.replay.yaml b/tests/gold_tests/chunked_encoding/replays/chunked.replay.yaml index 66c0c24d6c8..ebb2b6de7b0 100644 --- a/tests/gold_tests/chunked_encoding/replays/chunked.replay.yaml +++ b/tests/gold_tests/chunked_encoding/replays/chunked.replay.yaml @@ -48,12 +48,7 @@ sessions: size: 32 - protocol: - - name: http - version: 1 - - name: tls - - name: tcp - - name: ip - + stack: https transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/client_connection/http2_slow_origins.replay.yaml b/tests/gold_tests/client_connection/http2_slow_origins.replay.yaml index e6e7e028423..5e1d961dca0 100644 --- a/tests/gold_tests/client_connection/http2_slow_origins.replay.yaml +++ b/tests/gold_tests/client_connection/http2_slow_origins.replay.yaml @@ -33,13 +33,9 @@ meta: sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - + stack: http2 + tls: + sni: test_sni transactions: - client-request: @@ -75,13 +71,9 @@ sessions: - [ X-Response, {value: 'first-response', as: equal } ] - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - + stack: http2 + tls: + sni: test_sni transactions: - client-request: @@ -117,13 +109,9 @@ sessions: - [ X-Response, {value: 'second-response', as: equal } ] - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - + stack: http2 + tls: + sni: test_sni transactions: - client-request: @@ -160,16 +148,12 @@ sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - - # Make sure this is the last attempted transaction by giving the above - # three transactions, all executed in parallel, a one second head start. - # This connection should be aborted. + # Make sure this is the last attempted transaction by giving the above + # three transactions, all executed in parallel, a one second head start. + # This connection should be aborted. + stack: http2 + tls: + sni: test_sni delay: 1s transactions: @@ -198,13 +182,9 @@ sessions: # Note that this will delay after the previous 1s delay, so this is really # a delay of 3s. - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - + stack: http2 + tls: + sni: test_sni delay: 2s transactions: diff --git a/tests/gold_tests/client_connection/https_slow_origins.replay.yaml b/tests/gold_tests/client_connection/https_slow_origins.replay.yaml index 095c08b9daf..a81fa21c7d8 100644 --- a/tests/gold_tests/client_connection/https_slow_origins.replay.yaml +++ b/tests/gold_tests/client_connection/https_slow_origins.replay.yaml @@ -33,11 +33,9 @@ meta: sessions: - protocol: - - name: tls - sni: test_sni - - name: tcp - - name: ip - + stack: https + tls: + sni: test_sni transactions: - client-request: @@ -75,11 +73,9 @@ sessions: - [ X-Response, {value: 'first-response', as: equal } ] - protocol: - - name: tls - sni: test_sni - - name: tcp - - name: ip - + stack: https + tls: + sni: test_sni transactions: - client-request: @@ -117,11 +113,9 @@ sessions: - [ X-Response, {value: 'second-response', as: equal } ] - protocol: - - name: tls - sni: test_sni - - name: tcp - - name: ip - + stack: https + tls: + sni: test_sni transactions: - client-request: @@ -160,14 +154,12 @@ sessions: - protocol: - - name: tls - sni: test_sni - - name: tcp - - name: ip - - # Make sure this is the last attempted transaction by giving the above - # three transactions, all executed in parallel, a one second head start. - # This connection should be aborted. + # Make sure this is the last attempted transaction by giving the above + # three transactions, all executed in parallel, a one second head start. + # This connection should be aborted. + stack: https + tls: + sni: test_sni delay: 1s transactions: @@ -198,11 +190,9 @@ sessions: # Note that this will delay after the previous 1s delay, so this is really # a delay of 3s. - protocol: - - name: tls - sni: test_sni - - name: tcp - - name: ip - + stack: https + tls: + sni: test_sni delay: 2s transactions: diff --git a/tests/gold_tests/connect/replays/connect_h2.replay.yaml b/tests/gold_tests/connect/replays/connect_h2.replay.yaml index 140137730d7..5f623632968 100644 --- a/tests/gold_tests/connect/replays/connect_h2.replay.yaml +++ b/tests/gold_tests/connect/replays/connect_h2.replay.yaml @@ -23,13 +23,9 @@ meta: sessions: - protocol: - - name: http - version: 2 - - name: tls + stack: http2 + tls: sni: www.example.com - - name: tcp - - name: ip - transactions: - client-request: frames: diff --git a/tests/gold_tests/h2/expect_100_continue.yaml b/tests/gold_tests/h2/expect_100_continue.yaml index 7c49460a7a1..26460f31648 100644 --- a/tests/gold_tests/h2/expect_100_continue.yaml +++ b/tests/gold_tests/h2/expect_100_continue.yaml @@ -19,15 +19,10 @@ meta: sessions: - protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.3 sni: data.brian.example.com - - name: tcp - - name: ip - version: '4' - transactions: - client-request: headers: diff --git a/tests/gold_tests/h2/h2get_with_body.yaml b/tests/gold_tests/h2/h2get_with_body.yaml index 223645b2e07..4f44d8f538e 100644 --- a/tests/gold_tests/h2/h2get_with_body.yaml +++ b/tests/gold_tests/h2/h2get_with_body.yaml @@ -25,13 +25,9 @@ meta: version: '1.0' sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - version: 4 + stack: http2 + tls: + sni: test_sni transactions: - client-request: frames: diff --git a/tests/gold_tests/h2/http2_close_connection.yaml b/tests/gold_tests/h2/http2_close_connection.yaml index 5e2d7e6b5a7..8d32552abcc 100644 --- a/tests/gold_tests/h2/http2_close_connection.yaml +++ b/tests/gold_tests/h2/http2_close_connection.yaml @@ -25,13 +25,9 @@ meta: version: '1.0' sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - version: 4 + stack: http2 + tls: + sni: test_sni transactions: - client-request: frames: @@ -92,9 +88,3 @@ sessions: encoding: plain data: server_test_2 size: 13 - - proxy-response: - content: - encoding: plain - data: server_test_2 - verify: {as: equal} diff --git a/tests/gold_tests/h2/http2_flow_control.replay.yaml b/tests/gold_tests/h2/http2_flow_control.replay.yaml index e99d6ed3a7c..fae24c276af 100644 --- a/tests/gold_tests/h2/http2_flow_control.replay.yaml +++ b/tests/gold_tests/h2/http2_flow_control.replay.yaml @@ -23,13 +23,9 @@ meta: sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: www.example.com - - name: tcp - - name: ip - + stack: http2 + tls: + sni: www.example.com transactions: - client-request: diff --git a/tests/gold_tests/h2/http2_flow_control.test.py b/tests/gold_tests/h2/http2_flow_control.test.py index 1d000c85509..f09429f7d48 100644 --- a/tests/gold_tests/h2/http2_flow_control.test.py +++ b/tests/gold_tests/h2/http2_flow_control.test.py @@ -103,8 +103,10 @@ def _configure_dns(self, tr: 'TestRun') -> 'Process': Http2FlowControlTest._dns_counter += 1 return dns - def _configure_server(self, tr: 'TestRun', server_type: ServerType) -> 'Process': + def _configure_server(self, tr: 'TestRun', server_type: ServerType) -> Optional['Process']: """Configure the test server.""" + if self._flow_control_policy_is_malformed: + return None if server_type == self.ServerType.HTTP1_CHUNKED: replay_file = self._replay_chunked_file else: @@ -166,7 +168,8 @@ def _configure_trafficserver(self, tr: 'TestRun', is_outbound: bool, server_type ts.Disk.ssl_multicert_config.AddLine('dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key') - ts.Disk.remap_config.AddLine(f'map / https://127.0.0.1:{self._server.Variables.https_port}') + if self._server is not None: + ts.Disk.remap_config.AddLine(f'map / https://127.0.0.1:{self._server.Variables.https_port}') if self._flow_control_policy_is_malformed: if is_outbound: diff --git a/tests/gold_tests/h2/http2_flow_control_chunked.replay.yaml b/tests/gold_tests/h2/http2_flow_control_chunked.replay.yaml index b30ff37c696..4a77e39aca3 100644 --- a/tests/gold_tests/h2/http2_flow_control_chunked.replay.yaml +++ b/tests/gold_tests/h2/http2_flow_control_chunked.replay.yaml @@ -23,13 +23,9 @@ meta: sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: www.example.com - - name: tcp - - name: ip - + stack: http2 + tls: + sni: www.example.com transactions: - client-request: diff --git a/tests/gold_tests/h2/replay/http2_concurrent_streams.replay.yaml b/tests/gold_tests/h2/replay/http2_concurrent_streams.replay.yaml index 4747f7eb63c..98f271f0eef 100644 --- a/tests/gold_tests/h2/replay/http2_concurrent_streams.replay.yaml +++ b/tests/gold_tests/h2/replay/http2_concurrent_streams.replay.yaml @@ -25,12 +25,9 @@ meta: sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip + stack: http2 + tls: + sni: test_sni transactions: # Stream 1 - client-request: diff --git a/tests/gold_tests/h2/replay_h2origin/h1-client-h2-origin.yaml b/tests/gold_tests/h2/replay_h2origin/h1-client-h2-origin.yaml index be37d8e360e..8e7b6cf12ae 100644 --- a/tests/gold_tests/h2/replay_h2origin/h1-client-h2-origin.yaml +++ b/tests/gold_tests/h2/replay_h2origin/h1-client-h2-origin.yaml @@ -3,17 +3,12 @@ meta: sessions: - protocol: - - name: http - version: '1.1' - - name: tls + stack: https + tls: version: TLSv1.3 sni: data.brian.example.com proxy-verify-mode: 0 proxy-provided-cert: true - - name: tcp - - name: ip - version: '4' - transactions: # # Test 1: Zero length response. @@ -36,17 +31,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: GET @@ -105,17 +95,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: GET @@ -153,17 +138,12 @@ sessions: size: 16 - protocol: - - name: http - version: '1.1' - - name: tls + stack: https + tls: version: TLSv1.3 sni: data.brian.example.com proxy-verify-mode: 0 proxy-provided-cert: true - - name: tcp - - name: ip - version: '4' - transactions: # # Test 3: 8 byte post with a 404 response. @@ -186,17 +166,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: POST @@ -253,17 +228,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: POST @@ -321,17 +291,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: POST @@ -389,17 +354,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '1.1' scheme: https method: POST @@ -457,17 +417,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: POST diff --git a/tests/gold_tests/h2/replay_h2origin/h2-origin.yaml b/tests/gold_tests/h2/replay_h2origin/h2-origin.yaml index 6cead4e3cd6..acf7035fcd6 100644 --- a/tests/gold_tests/h2/replay_h2origin/h2-origin.yaml +++ b/tests/gold_tests/h2/replay_h2origin/h2-origin.yaml @@ -3,17 +3,12 @@ meta: sessions: - protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.3 sni: data.brian.example.com proxy-verify-mode: 0 proxy-provided-cert: true - - name: tcp - - name: ip - version: '4' - transactions: # # Test 1: Zero length response. @@ -35,17 +30,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: GET @@ -105,17 +95,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: GET @@ -153,17 +138,12 @@ sessions: size: 16 - protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.3 sni: data.brian.example.com proxy-verify-mode: 0 proxy-provided-cert: true - - name: tcp - - name: ip - version: '4' - transactions: # # Test 3: 8 byte post with a 404 response. @@ -186,17 +166,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: POST @@ -266,17 +241,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: POST @@ -333,17 +303,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: POST @@ -410,17 +375,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: POST @@ -477,17 +437,12 @@ sessions: proxy-request: protocol: - - name: http - version: '2' - - name: tls + stack: http2 + tls: version: TLSv1.2 sni: data.brian.example.com proxy-verify-mode: 1 proxy-provided-cert: false - - name: tcp - - name: ip - version: '4' - version: '2' scheme: https method: POST diff --git a/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_client_after_data.yaml b/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_client_after_data.yaml index 60bfa6f7ace..e6253884acd 100644 --- a/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_client_after_data.yaml +++ b/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_client_after_data.yaml @@ -2,13 +2,9 @@ meta: version: '1.0' sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - version: 4 + stack: http2 + tls: + sni: test_sni keep-connection-open: 2s transactions: - client-request: @@ -31,12 +27,6 @@ sessions: - RST_STREAM: error-code: INTERNAL_ERROR - proxy-request: - content: - encoding: plain - data: client_test - verify: {as: equal} - server-response: headers: fields: @@ -47,9 +37,3 @@ sessions: encoding: plain data: server_test size: 11 - - proxy-response: - content: - encoding: plain - data: server_test - verify: {as: equal} diff --git a/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_client_after_headers.yaml b/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_client_after_headers.yaml index 27df8510302..f7620e92d21 100644 --- a/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_client_after_headers.yaml +++ b/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_client_after_headers.yaml @@ -2,13 +2,9 @@ meta: version: '1.0' sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - version: 4 + stack: http2 + tls: + sni: test_sni keep-connection-open: 2s transactions: - client-request: @@ -31,12 +27,6 @@ sessions: data: client_test size: 11 - proxy-request: - content: - encoding: plain - data: client_test - verify: {as: equal} - server-response: headers: fields: @@ -47,9 +37,3 @@ sessions: encoding: plain data: server_test size: 11 - - proxy-response: - content: - encoding: plain - data: server_test - verify: {as: equal} diff --git a/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_server_after_headers.yaml b/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_server_after_headers.yaml index 1ce5c320382..0a703ba6c84 100644 --- a/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_server_after_headers.yaml +++ b/tests/gold_tests/h2/replay_rst_stream/http2_rst_stream_server_after_headers.yaml @@ -2,13 +2,9 @@ meta: version: '1.0' sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - version: 4 + stack: http2 + tls: + sni: test_sni transactions: - client-request: headers: diff --git a/tests/gold_tests/h3/replays/h3_sni.replay.yaml b/tests/gold_tests/h3/replays/h3_sni.replay.yaml index 135d375dfc2..a4ca2bae174 100644 --- a/tests/gold_tests/h3/replays/h3_sni.replay.yaml +++ b/tests/gold_tests/h3/replays/h3_sni.replay.yaml @@ -19,10 +19,9 @@ meta: sessions: - protocol: - - name: http - version: 3 - - name: tls - sni: test_sni + stack: http3 + tls: + sni: test_sni transactions: - client-request: @@ -46,10 +45,8 @@ sessions: status: 200 - protocol: - - name: http - version: 3 - # Note that the SNI is not specified for this connection. - - name: tls + # Note that the SNI is not specified for this connection. + stack: http3 transactions: - client-request: version: "3" diff --git a/tests/gold_tests/headers/accept_webp.test.py b/tests/gold_tests/headers/accept_webp.test.py index 249534a1d12..1d0a4232c86 100644 --- a/tests/gold_tests/headers/accept_webp.test.py +++ b/tests/gold_tests/headers/accept_webp.test.py @@ -1,5 +1,5 @@ ''' -Test how we handle image/webp +Test how ATS handles image/webp alternates. ''' # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -18,71 +18,9 @@ # limitations under the License. Test.Summary = ''' -Checking that we don't serve image/webp to clients that do not support it +Check that ATS does not reuse a cached image/webp alternate for clients that do not advertise image/webp ''' -Test.SkipIf(Condition.CurlUsingUnixDomainSocket()) Test.ContinueOnFail = True -# Define default ATS -ts = Test.MakeATSProcess("ts") -server = Test.MakeOriginServer("server") - -testName = "accept_webp" -request_header = { - "headers": - "GET / HTTP/1.1\r\nHost: www.example.com\r\nAccept: image/webp,image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5\r\n\r\n", - "timestamp": "1469733493.993", - "body": "" -} -response_header = { - "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: image/webp\r\nCache-Control: max-age=300\r\n", - "timestamp": "1469733493.993", - "body": "xxx" -} -server.addResponse("sessionlog.json", request_header, response_header) - -# ATS Configuration -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http_match', - 'proxy.config.http.cache.ignore_accept_mismatch': 0, - 'proxy.config.http.insert_response_via_str': 3, - 'proxy.config.http.cache.http': 1, - 'proxy.config.http.wait_for_cache': 1, - }) - -ts.Disk.remap_config.AddLine('map http://www.example.com http://127.0.0.1:{0}'.format(server.Variables.Port)) - -# Test 1 - Request with image/webp support from the origin -tr = Test.AddTestRun() -tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) -tr.Processes.Default.StartBefore(Test.Processes.ts) -tr.MakeCurlCommand( - '-s -D - -v --ipv4 --http1.1 -H "Accept: image/webp,image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5" -H "Host: www.example.com" http://localhost:{0}/' - .format(ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stderr = "gold/accept_webp.gold" -tr.StillRunningAfter = ts - -# Test 2 - Request with image/webp support from cache -tr = Test.AddTestRun() -tr.MakeCurlCommand( - '-s -D - -v --ipv4 --http1.1 -H "Accept: image/webp,image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5" -H "Host: www.example.com" http://localhost:{0}/' - .format(ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stderr = "gold/accept_webp_cache.gold" -tr.StillRunningAfter = ts - -# Test 3 - Request without image/webp support going to the origin - NOTE: the origin can't change the content-type :( -tr = Test.AddTestRun() -tr.MakeCurlCommand( - '-s -D - -v --ipv4 --http1.1 -H "Accept: image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5" -H "Host: www.example.com" http://localhost:{0}/' - .format(ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stderr = "gold/accept_webp_jpeg.gold" -tr.StillRunningAfter = ts +Test.ATSReplayTest(replay_file="replays/accept_webp.replay.yaml") diff --git a/tests/gold_tests/headers/cachedDuplicateHeaders.test.py b/tests/gold_tests/headers/cachedDuplicateHeaders.test.py index c3c6be98d7f..eafe6cf81c1 100644 --- a/tests/gold_tests/headers/cachedDuplicateHeaders.test.py +++ b/tests/gold_tests/headers/cachedDuplicateHeaders.test.py @@ -1,5 +1,5 @@ ''' -Test cached responses and requests with bodies +Test cached duplicate headers during revalidation. ''' # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -18,43 +18,9 @@ # limitations under the License. Test.Summary = ''' -Test revalidating cached objects +Test cached duplicate headers during revalidation ''' -testName = "RevalidateCacheObject" -Test.ContinueOnFail = True - - -class CachedHeaderValidationTest: - replay_file = "replays/cache-test.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess("cached-header-verifier-server", self.replay_file) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts", enable_tls=True) - self.ts.Disk.plugin_config.AddLine('xdebug.so --enable=x-cache,x-cache-key,via') - self.ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.response_via_str': 3, - }) - self.ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(self.server.Variables.http_port)) - - def runTraffic(self): - tr = Test.AddTestRun() - tr.AddVerifierClientProcess("cached-header-verifier-client", self.replay_file, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.ts - tr.StillRunningAfter = self.server - - def run(self): - self.runTraffic() +Test.ContinueOnFail = True -CachedHeaderValidationTest().run() +Test.ATSReplayTest(replay_file="replays/cache-test.replay.yaml") diff --git a/tests/gold_tests/headers/cachedIMSRange.test.py b/tests/gold_tests/headers/cachedIMSRange.test.py index 64af159c9f1..6682053931a 100644 --- a/tests/gold_tests/headers/cachedIMSRange.test.py +++ b/tests/gold_tests/headers/cachedIMSRange.test.py @@ -1,5 +1,5 @@ ''' -Test cached responses and requests with bodies +Test revalidating cached objects. ''' # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -21,266 +21,6 @@ Test revalidating cached objects ''' -testName = "RevalidateCacheObject" Test.ContinueOnFail = True -# Set up Origin server -# request_header is from ATS to origin; response from Origin to ATS -# lookup_key is to make unique response in origin for header "UID" that will pass in ATS request -server = Test.MakeOriginServer("server", lookup_key="{%UID}") -# Initial request -request_header = { - "headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\nUID: Fill\r\n\r\n", - "timestamp": "1469733493.993", - "body": "" -} -response_header = { - "headers": - "HTTP/1.1 200 OK\r\nConnection: close\r\nLast-Modified: Tue, 08 May 2018 15:49:41 GMT\r\nCache-Control: max-age=1\r\n\r\n", - "timestamp": "1469733493.993", - "body": "xxx" -} -server.addResponse("sessionlog.json", request_header, response_header) -# IMS revalidation request -request_IMS_header = { - "headers": "GET / HTTP/1.1\r\nUID: IMS\r\nIf-Modified-Since: Tue, 08 May 2018 15:49:41 GMT\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", - "body": "" -} -response_IMS_header = { - "headers": "HTTP/1.1 304 Not Modified\r\nConnection: close\r\nCache-Control: max-age=1\r\n\r\n", - "timestamp": "1469733493.993", - "body": None -} -server.addResponse("sessionlog.json", request_IMS_header, response_IMS_header) - -# EtagFill -request_etagfill_header = { - "headers": "GET /etag HTTP/1.1\r\nHost: www.example.com\r\nUID: EtagFill\r\n\r\n", - "timestamp": "1469733493.993", - "body": None -} -response_etagfill_header = { - "headers": "HTTP/1.1 200 OK\r\nETag: myetag\r\nConnection: close\r\nCache-Control: max-age=1\r\n\r\n", - "timestamp": "1469733493.993", - "body": "xxx" -} -server.addResponse("sessionlog.json", request_etagfill_header, response_etagfill_header) -# INM revalidation -request_INM_header = { - "headers": "GET /etag HTTP/1.1\r\nUID: INM\r\nIf-None-Match: myetag\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", - "body": None -} -response_INM_header = { - "headers": "HTTP/1.1 304 Not Modified\r\nConnection: close\r\nETag: myetag\r\nCache-Control: max-age=1\r\n\r\n", - "timestamp": "1469733493.993", - "body": None -} -server.addResponse("sessionlog.json", request_INM_header, response_INM_header) - -# object changed to 0 byte -request_noBody_header = { - "headers": "GET / HTTP/1.1\r\nUID: noBody\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", - "body": "" -} -response_noBody_header = { - "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", - "timestamp": "1469733493.993", - "body": "" -} -server.addResponse("sessionlog.json", request_noBody_header, response_noBody_header) - -# etag object now is a 404. Yeah, 404s don't usually have Cache-Control, but, ATS's default is to cache 404s for a while. -request_etagfill_header = { - "headers": "GET /etag HTTP/1.1\r\nHost: www.example.com\r\nUID: EtagError\r\n\r\n", - "timestamp": "1469733493.993", - "body": None -} -response_etagfill_header = { - "headers": "HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Length: 0\r\nCache-Control: max-age=3\r\n\r\n", - "timestamp": "1469733493.993", - "body": "" -} -server.addResponse("sessionlog.json", request_etagfill_header, response_etagfill_header) - -# ATS Configuration -ts = Test.MakeATSProcess("ts", enable_tls=True) -ts.Disk.plugin_config.AddLine('xdebug.so --enable=x-cache,x-cache-key,via') -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), - }) - -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') - -ipv4flag = "" -if not Condition.CurlUsingUnixDomainSocket(): - ipv4flag = "--ipv4" - -# Test 0 - Fill a 3 byte object with Last-Modified time into cache. -tr = Test.AddTestRun() -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.MakeCurlCommand( - '-s -D - -v {0} --http1.1 -H"UID: Fill" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "cache_and_req_body-miss.gold" -tr.StillRunningAfter = ts -tr.StillRunningAfter = server - -# Test 1 - Once it goes stale, fetch it again. We expect Origin to get IMS -# request, and serve a 304. We expect ATS to refresh the object, and give -# a 200 to user -tr = Test.AddTestRun() -tr.DelayStart = 2 -tr.MakeCurlCommand( - '-s -D - -v {0} --http1.1 -H"UID: IMS" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "cache_and_req_body-hit-stale.gold" -tr.StillRunningAfter = ts -tr.StillRunningAfter = server - -# Test 2 - Once it goes stale, fetch it via a range request. We expect -# Origin to get IMS request, and serve a 304. We expect ATS to refresh the -# object, and give a 206 to user -tr = Test.AddTestRun() -tr.DelayStart = 2 -tr.MakeCurlCommand( - '--range 0-1 -s -D - -v {0} --http1.1 -H"UID: IMS" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "cache_and_req_body-hit-stale-206.gold" -tr.StillRunningAfter = ts -tr.StillRunningAfter = server - -# Test 3 - Test 304 response served from a regex-remap rule with HTTP. -tr = Test.AddTestRun() -tr.MakeCurlCommand(f'-vs http://127.0.0.1:{ts.Variables.port}/ -H "Host: {default_304_host}"', ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.All = Testers.GoldFile("gold/http1_304.gold", case_insensitive=True) -tr.StillRunningAfter = server - -if not Condition.CurlUsingUnixDomainSocket(): - # Test 4 - Test 304 response served from a regex-remap rule with HTTPS. - tr = Test.AddTestRun() - tr.MakeCurlCommand(f'-vs -k https://127.0.0.1:{ts.Variables.ssl_port}/ -H "Host: {default_304_host}"', ts=ts) - 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.MakeCurlCommand(f'-vs -k --http2 https://127.0.0.1:{ts.Variables.ssl_port}/ -H "Host: {default_304_host}"', ts=ts) - 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.MakeCurlCommand( - '-s -D - -v {0} --http1.1 -H"UID: EtagFill" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/etag' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.StillRunningAfter = ts -tr.StillRunningAfter = server - -# 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() -tr.DelayStart = 2 -tr.MakeCurlCommand( - '-s -D - -v {0} --http1.1 -H"UID: INM" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/etag' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "cache_and_req_body-hit-stale-INM.gold" -tr.StillRunningAfter = ts -tr.StillRunningAfter = server - -# 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() -tr.DelayStart = 2 -tr.MakeCurlCommand( - '--range 0-1 -s -D - -v {0} --http1.1 -H"UID: INM" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/etag' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "cache_and_req_body-hit-stale-206-etag.gold" -tr.StillRunningAfter = ts -tr.StillRunningAfter = server - -# 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.MakeCurlCommand( - '-s -D - -v {0} --http1.1 -H"UID: noBody" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "cache_and_req_nobody-hit-stale.gold" -tr.StillRunningAfter = ts -tr.StillRunningAfter = server - -# 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.MakeCurlCommand( - '-s -D - -v {0} --http1.1 -H"UID: noBody" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "cache_and_req_nobody-hit-stale.gold" -tr.StillRunningAfter = ts -tr.StillRunningAfter = server - -# 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.MakeCurlCommand( - '-s -D - -v {0} --http1.1 -H"UID: EtagError" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/etag' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "cache_and_error_nobody.gold" -tr.StillRunningAfter = ts -tr.StillRunningAfter = server - -# 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.MakeCurlCommand( - '-s -D - -v {0} --http1.1 -H"UID: EtagError" -H "x-debug: x-cache,x-cache-key,via" -H "Host: www.example.com" http://localhost:{1}/etag' - .format(ipv4flag, ts.Variables.port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "cache_and_error_nobody.gold" -tr.StillRunningAfter = ts -tr.StillRunningAfter = server +Test.ATSReplayTest(replay_file="replays/cached_ims_range.replay.yaml") diff --git a/tests/gold_tests/headers/domain-blacklist-30x.test.py b/tests/gold_tests/headers/domain-blacklist-30x.test.py index d46bdf39588..cc3ab045a44 100644 --- a/tests/gold_tests/headers/domain-blacklist-30x.test.py +++ b/tests/gold_tests/headers/domain-blacklist-30x.test.py @@ -1,5 +1,5 @@ ''' -Tests 30x responses are returned for matching domains +Test that redirect responses are returned for matching domains. ''' # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -17,94 +17,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os -import sys - Test.Summary = ''' -Tests 30x responses are returned for matching domains +Test that redirect responses are returned for matching domains ''' -ts = Test.MakeATSProcess("ts") -server = Test.MakeOriginServer("server") - -REDIRECT_301_HOST = 'www.redirect301.test' -REDIRECT_302_HOST = 'www.redirect302.test' -REDIRECT_307_HOST = 'www.redirect307.test' -REDIRECT_308_HOST = 'www.redirect308.test' -REDIRECT_0_HOST = 'www.redirect0.test' -PASSTHRU_HOST = 'www.passthrough.test' - -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'header_rewrite|dbg_header_rewrite', - 'proxy.config.body_factory.enable_logging': 1, - }) - -ts.Disk.remap_config.AddLine( - """\ -regex_map http://{0}/ http://{0}/ @plugin=header_rewrite.so @pparam=header_rewrite_rules_301.conf -regex_map http://{1}/ http://{1}/ @plugin=header_rewrite.so @pparam=header_rewrite_rules_302.conf -regex_map http://{2}/ http://{2}/ @plugin=header_rewrite.so @pparam=header_rewrite_rules_307.conf -regex_map http://{3}/ http://{3}/ @plugin=header_rewrite.so @pparam=header_rewrite_rules_308.conf -regex_map http://{4}/ http://{4}/ @plugin=header_rewrite.so @pparam=header_rewrite_rules_0.conf -""".format(REDIRECT_301_HOST, REDIRECT_302_HOST, REDIRECT_307_HOST, REDIRECT_308_HOST, REDIRECT_0_HOST)) - -for x in (0, 301, 302, 307, 308): - ts.Disk.MakeConfigFile("header_rewrite_rules_{0}.conf".format(x)).AddLine("""\ -set-redirect {0} "%{{CLIENT-URL}}" -""".format(x)) - -Test.Setup.Copy(os.path.join(os.pardir, os.pardir, 'tools', 'tcp_client.py')) -Test.Setup.Copy('data') - -redirect301tr = Test.AddTestRun(f"Test domain {REDIRECT_301_HOST}") -redirect301tr.Processes.Default.StartBefore(Test.Processes.ts) -redirect301tr.StillRunningAfter = ts -redirect301tr.Processes.Default.Command = f"{sys.executable} tcp_client.py 127.0.0.1 {ts.Variables.port} data/{REDIRECT_301_HOST}_get.txt | grep -v '^Date: '| grep -v '^Server: ATS/'" -redirect301tr.Processes.Default.TimeOut = 5 # seconds -redirect301tr.Processes.Default.ReturnCode = 0 -redirect301tr.Processes.Default.Streams.stdout = "redirect301_get.gold" - -redirect302tr = Test.AddTestRun(f"Test domain {REDIRECT_302_HOST}") -redirect302tr.StillRunningBefore = ts -redirect302tr.StillRunningAfter = ts -redirect302tr.Processes.Default.Command = f"{sys.executable} tcp_client.py 127.0.0.1 {ts.Variables.port} data/{REDIRECT_302_HOST}_get.txt | grep -v '^Date: '| grep -v '^Server: ATS/'" -redirect302tr.Processes.Default.TimeOut = 5 # seconds -redirect302tr.Processes.Default.ReturnCode = 0 -redirect302tr.Processes.Default.Streams.stdout = "redirect302_get.gold" - -redirect307tr = Test.AddTestRun(f"Test domain {REDIRECT_307_HOST}") -redirect302tr.StillRunningBefore = ts -redirect307tr.StillRunningAfter = ts -redirect307tr.Processes.Default.Command = f"{sys.executable} tcp_client.py 127.0.0.1 {ts.Variables.port} data/{REDIRECT_307_HOST}_get.txt | grep -v '^Date: '| grep -v '^Server: ATS/'" -redirect307tr.Processes.Default.TimeOut = 5 # seconds -redirect307tr.Processes.Default.ReturnCode = 0 -redirect307tr.Processes.Default.Streams.stdout = "redirect307_get.gold" - -redirect308tr = Test.AddTestRun(f"Test domain {REDIRECT_308_HOST}") -redirect308tr.StillRunningBefore = ts -redirect308tr.StillRunningAfter = ts -redirect308tr.Processes.Default.Command = f"{sys.executable} tcp_client.py 127.0.0.1 {ts.Variables.port} data/{REDIRECT_308_HOST}_get.txt | grep -v '^Date: '| grep -v '^Server: ATS/'" -redirect308tr.Processes.Default.TimeOut = 5 # seconds -redirect308tr.Processes.Default.ReturnCode = 0 -redirect308tr.Processes.Default.Streams.stdout = "redirect308_get.gold" - -redirect0tr = Test.AddTestRun(f"Test domain {REDIRECT_0_HOST}") -redirect0tr.StillRunningBefore = ts -redirect0tr.StillRunningAfter = ts -redirect0tr.Processes.Default.Command = f"{sys.executable} tcp_client.py 127.0.0.1 {ts.Variables.port} data/{REDIRECT_0_HOST}_get.txt | grep -v '^Date: '| grep -v '^Server: ATS/'" -redirect0tr.Processes.Default.TimeOut = 5 # seconds -redirect0tr.Processes.Default.ReturnCode = 0 -redirect0tr.Processes.Default.Streams.stdout = "redirect0_get.gold" - -passthroughtr = Test.AddTestRun(f"Test domain {PASSTHRU_HOST}") -passthroughtr.StillRunningBefore = ts -passthroughtr.StillRunningAfter = ts -passthroughtr.Processes.Default.Command = f"{sys.executable} tcp_client.py 127.0.0.1 {ts.Variables.port} data/{PASSTHRU_HOST}_get.txt | grep -v '^Date: '| grep -v '^Server: ATS/'" -passthroughtr.Processes.Default.TimeOut = 5 # seconds -passthroughtr.Processes.Default.ReturnCode = 0 -passthroughtr.Processes.Default.Streams.stdout = "passthrough_get.gold" +Test.ContinueOnFail = True -# Overriding the built in ERROR check since we expect some ERROR messages -ts.Disk.diags_log.Content = Testers.ContainsExpression("unsupported redirect status 0", "This test is a failure test") +Test.ATSReplayTest(replay_file="replays/domain-blacklist-30x.replay.yaml") diff --git a/tests/gold_tests/headers/gold/accept_webp.gold b/tests/gold_tests/headers/gold/accept_webp.gold deleted file mode 100644 index 9b6dcb47872..00000000000 --- a/tests/gold_tests/headers/gold/accept_webp.gold +++ /dev/null @@ -1,16 +0,0 @@ -`` -> GET /`` -> Host: www.example.com`` -> User-Agent: curl/`` -> Accept: image/webp,image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5 -`` -< HTTP/1.1 200 OK -< Content-Type: image/webp -< Cache-Control: max-age=300 -< Content-Length: 3 -< Date: `` -< Age: `` -< Connection: keep-alive -< Via: http/1.1 `` (ApacheTrafficServer/`` [uScMsSfWpSeN:t cCMp sS]) -< Server: ATS/`` -`` diff --git a/tests/gold_tests/headers/gold/accept_webp_cache.gold b/tests/gold_tests/headers/gold/accept_webp_cache.gold deleted file mode 100644 index 5e2cf841d0e..00000000000 --- a/tests/gold_tests/headers/gold/accept_webp_cache.gold +++ /dev/null @@ -1,16 +0,0 @@ -`` -> GET /`` -> Host: www.example.com`` -> User-Agent: curl/`` -> Accept: image/webp,image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5 -`` -< HTTP/1.1 200 OK -< Content-Type: image/webp -< Cache-Control: max-age=300 -< Content-Length: 3 -< Date: `` -< Age: `` -< Connection: keep-alive -< Via: http/1.1 `` (ApacheTrafficServer/`` [uScHs f p eN:t cCHp s ]) -< Server: ATS/`` -`` diff --git a/tests/gold_tests/headers/gold/accept_webp_jpeg.gold b/tests/gold_tests/headers/gold/accept_webp_jpeg.gold deleted file mode 100644 index 1e76ccc3165..00000000000 --- a/tests/gold_tests/headers/gold/accept_webp_jpeg.gold +++ /dev/null @@ -1,16 +0,0 @@ -`` -> GET /`` -> Host: www.example.com`` -> User-Agent: curl/`` -> Accept: image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5 -`` -< HTTP/1.1 200 OK -< Content-Type: image/webp -< Cache-Control: max-age=300 -< Content-Length: 3 -< Date: `` -< Age: `` -< Connection: keep-alive -< Via: http/1.1 `` (ApacheTrafficServer/`` [uScMsSfWpSeN:t cCMp sS]) -< Server: ATS/`` -`` diff --git a/tests/gold_tests/headers/gold/http1_304.gold b/tests/gold_tests/headers/gold/http1_304.gold deleted file mode 100644 index 3740c2395f9..00000000000 --- a/tests/gold_tests/headers/gold/http1_304.gold +++ /dev/null @@ -1,10 +0,0 @@ -`` -> 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 deleted file mode 100644 index f5c3599828b..00000000000 --- a/tests/gold_tests/headers/gold/http2_304.gold +++ /dev/null @@ -1,10 +0,0 @@ -`` -> GET / HTTP/2 -> Host: www.default304.test -> User-Agent: curl/`` -> Accept: */* -`` -< HTTP/2 304`` -< date: `` -< server: ATS/`` -`` diff --git a/tests/gold_tests/headers/gold/range-200.gold b/tests/gold_tests/headers/gold/range-200.gold deleted file mode 100644 index 0aa6ac90c5e..00000000000 --- a/tests/gold_tests/headers/gold/range-200.gold +++ /dev/null @@ -1,11 +0,0 @@ -HTTP/1.1 200 OK -Server: ATS/`` -Cache-Control: max-age=`` -Last-Modified: Thu, 10 Feb 2022 00:00:00 GMT -ETag: range -Content-Length: 11 -Date: `` -Age: `` -Connection: keep-alive - -0123456789 diff --git a/tests/gold_tests/headers/gold/range-206-revalidated.gold b/tests/gold_tests/headers/gold/range-206-revalidated.gold deleted file mode 100644 index e918cc03892..00000000000 --- a/tests/gold_tests/headers/gold/range-206-revalidated.gold +++ /dev/null @@ -1,12 +0,0 @@ -HTTP/1.1 206 Partial Content -Server: ATS/`` -Cache-Control: max-age=1 -Last-Modified: Thu, 10 Feb 2022 00:00:00 GMT -Content-Length: 5 -Date: `` -Etag: range -Age: `` -Content-Range: bytes 1-5/11 -Connection: keep-alive - -12345`` diff --git a/tests/gold_tests/headers/gold/range-206.gold b/tests/gold_tests/headers/gold/range-206.gold deleted file mode 100644 index 8caff80aa1b..00000000000 --- a/tests/gold_tests/headers/gold/range-206.gold +++ /dev/null @@ -1,12 +0,0 @@ -HTTP/1.1 206 Partial Content -Server: ATS/`` -Cache-Control: max-age=300 -Last-Modified: Thu, 10 Feb 2022 00:00:00 GMT -ETag: range -Content-Length: 5 -Date: `` -Age: `` -Content-Range: bytes 1-5/11 -Connection: keep-alive - -12345`` diff --git a/tests/gold_tests/headers/gold/range-416.gold b/tests/gold_tests/headers/gold/range-416.gold deleted file mode 100644 index 1a87e708d11..00000000000 --- a/tests/gold_tests/headers/gold/range-416.gold +++ /dev/null @@ -1,6 +0,0 @@ -HTTP/1.1 416 Requested Range Not Satisfiable -Date: `` -Connection: keep-alive -Server: ATS/`` -Cache-Control: no-store -`` diff --git a/tests/gold_tests/headers/hsts.test.py b/tests/gold_tests/headers/hsts.test.py index e5438325165..147fb7cd115 100644 --- a/tests/gold_tests/headers/hsts.test.py +++ b/tests/gold_tests/headers/hsts.test.py @@ -1,5 +1,5 @@ ''' -Test the hsts response header. +Test the HSTS response header. ''' # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -18,56 +18,9 @@ # limitations under the License. Test.Summary = ''' -heck hsts header is set correctly +Check the HSTS header is set correctly ''' -Test.SkipIf(Condition.CurlUsingUnixDomainSocket()) -Test.ContinueOnFail = True - -# Define default ATS -ts = Test.MakeATSProcess("ts", enable_tls=True) -server = Test.MakeOriginServer("server") - -# **testname is required** -testName = "" -request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -server.addResponse("sessionlog.json", request_header, response_header) - -# ATS Configuration -ts.addDefaultSSLFiles() -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'ssl', - 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), - 'proxy.config.ssl.hsts_max_age': 300, - }) - -ts.Disk.remap_config.AddLine('map https://www.example.com http://127.0.0.1:{0}'.format(server.Variables.Port)) - -ts.Disk.ssl_multicert_config.AddLine('dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key') - -# Test 1 - 200 Response -tr = Test.AddTestRun() -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(Test.Processes.ts) -tr.MakeCurlCommand( - '-s -D - --verbose --ipv4 --http1.1 --insecure --header "Host: {0}" https://localhost:{1}'.format( - 'www.example.com', ts.Variables.ssl_port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "hsts.200.gold" -tr.StillRunningAfter = ts +Test.ContinueOnFail = True -# Test 2 - 404 Not Found on Accelerator -tr = Test.AddTestRun() -tr.MakeCurlCommand( - '-s -D - --verbose --ipv4 --http1.1 --insecure --header "Host: {0}" https://localhost:{1}'.format( - 'bad_host', ts.Variables.ssl_port), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "hsts.404.gold" -tr.StillRunningAfter = server -tr.StillRunningAfter = ts +Test.ATSReplayTest(replay_file="replays/hsts.replay.yaml") diff --git a/tests/gold_tests/headers/invalid_range_header.test.py b/tests/gold_tests/headers/invalid_range_header.test.py index 38c36b24014..f9613e7f7ad 100644 --- a/tests/gold_tests/headers/invalid_range_header.test.py +++ b/tests/gold_tests/headers/invalid_range_header.test.py @@ -1,4 +1,5 @@ ''' +Test invalid values in the Range header. ''' # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -16,53 +17,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os - Test.Summary = ''' -Test invalid values in range header +Test invalid values in the Range header ''' -Test.ContinueOnFail = True - - -class InvalidRangeHeaderTest: - invalidRangeRequestReplayFile = "replays/invalid_range_request.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess("verifier-server1", self.invalidRangeRequestReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts1") - self.ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.cache.http': 1, - 'proxy.config.http.cache.range.write': 1, - 'proxy.config.http.cache.required_headers': 0, - 'proxy.config.http.insert_age_in_response': 0 - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - def runTraffic(self): - tr = Test.AddTestRun() - tr.AddVerifierClientProcess("client1", self.invalidRangeRequestReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - # verification - tr.Processes.Default.Streams.stdout += Testers.ContainsExpression( - r"Received an HTTP/1 416 response for key 2", "Verify that client receives a 416 response") - tr.Processes.Default.Streams.stdout += Testers.ContainsExpression( - r"x-responseheader: failed_response", "Verify that the response came from the server") - - def run(self): - self.runTraffic() +Test.ContinueOnFail = True -InvalidRangeHeaderTest().run() +Test.ATSReplayTest(replay_file="replays/invalid_range_request.replay.yaml") diff --git a/tests/gold_tests/headers/maps.reg b/tests/gold_tests/headers/maps.reg new file mode 100644 index 00000000000..692a82f3524 --- /dev/null +++ b/tests/gold_tests/headers/maps.reg @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +//.*/ http://127.0.0.1:1 @status=304 diff --git a/tests/gold_tests/headers/normalized_ae_match_vary_cache.test.py b/tests/gold_tests/headers/normalized_ae_match_vary_cache.test.py index 991d2fda32b..57f96dcfb0a 100644 --- a/tests/gold_tests/headers/normalized_ae_match_vary_cache.test.py +++ b/tests/gold_tests/headers/normalized_ae_match_vary_cache.test.py @@ -1,6 +1,6 @@ ''' Test cache matching with the normalized Accept-Encoding header field -and the Vary header field in response +and the Vary header field in response. ''' # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -18,50 +18,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os - Test.Summary = ''' Test cache matching with the normalized Accept-Encoding and the Vary header field in response ''' Test.ContinueOnFail = True -testName = "NORMALIZE_AE_MATCH_VARY" - -replay_file = "replays/normalized_ae_varied_transactions.replay.yaml" -server = Test.MakeVerifierServerProcess("server", replay_file) - -ts = Test.MakeATSProcess("ts", enable_cache=True) -ts.Disk.remap_config.AddLine( - f"map http://www.ae-0.com http://127.0.0.1:{server.Variables.http_port}" + - ' @plugin=conf_remap.so @pparam=proxy.config.http.normalize_ae=0') -ts.Disk.remap_config.AddLine( - f"map http://www.ae-1.com http://127.0.0.1:{server.Variables.http_port}" + - ' @plugin=conf_remap.so @pparam=proxy.config.http.normalize_ae=1') -ts.Disk.remap_config.AddLine( - f"map http://www.ae-2.com http://127.0.0.1:{server.Variables.http_port}" + - ' @plugin=conf_remap.so @pparam=proxy.config.http.normalize_ae=2') -# disable normalize_ae=3 on 9.1 -ts.Disk.remap_config.AddLine( - f"map http://www.ae-3.com http://127.0.0.1:{server.Variables.http_port}" + - ' @plugin=conf_remap.so @pparam=proxy.config.http.normalize_ae=3') -ts.Disk.plugin_config.AddLine('xdebug.so --enable=x-cache') -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.response_via_str': 3, - # the following variables could affect the results of alternate cache matching, - # define them with their default values explicitly - 'proxy.config.cache.limits.http.max_alts': 5, - 'proxy.config.http.cache.ignore_accept_mismatch': 2, - 'proxy.config.http.cache.ignore_accept_language_mismatch': 2, - 'proxy.config.http.cache.ignore_accept_encoding_mismatch': 2, - 'proxy.config.http.cache.ignore_accept_charset_mismatch': 2, - }) - -tr = Test.AddTestRun() -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client", replay_file, http_ports=[ts.Variables.port]) -tr.StillRunningAfter = ts +Test.ATSReplayTest(replay_file="replays/normalized_ae_varied_transactions.replay.yaml") diff --git a/tests/gold_tests/headers/range.test.py b/tests/gold_tests/headers/range.test.py index 32b94c66645..85661b6e289 100644 --- a/tests/gold_tests/headers/range.test.py +++ b/tests/gold_tests/headers/range.test.py @@ -1,5 +1,6 @@ -""" -""" +''' +Test range requests. +''' # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -16,200 +17,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -Test.Summary = """ +Test.Summary = ''' Test range requests -""" +''' Test.ContinueOnFail = True -CACHE_SHORT_MAXAGE = 1 - - -def register(microserver, request_hdr, request_body, response_hdr, response_body): - request = { - "headers": "{}\r\n\r\n".format("\r\n".join(line for line in request_hdr.split("\n") if line)), - "timestamp": "1469733493.993", - "body": request_body, - } - response = { - "headers": "{}\r\n\r\n".format("\r\n".join(line for line in response_hdr.split("\n") if line)), - "timestamp": "1469733493.993", - "body": response_body, - } - microserver.addResponse("sessionlog.json", request, response) - - -def curl_whole(ts, path=""): - return f"-sSv -D - http://127.0.0.1:{ts.Variables.port}/{path}" - - -def curl_range(ts, path="", ifrange=None, start=1, end=5): - opt = f"-H 'If-Range: {ifrange}'" if ifrange else "" - return f"-sSv -D - {opt} -H 'Range: bytes={start}-{end}' http://127.0.0.1:{ts.Variables.port}/{path}" - - -# ---- -# Setup Origin Server -# ---- -microserver = Test.MakeOriginServer("microserver") - -request_hdr = """ -GET / HTTP/1.1 -Host: 127.0.0.1 -""" - -response_hdr = """ -HTTP/1.1 200 OK -Server: microserver -Connection: close -Cache-Control: max-age=300 -Last-Modified: Thu, 10 Feb 2022 00:00:00 GMT -ETag: range -""" - -short_cache_request_hdr = """ -GET /short HTTP/1.1 -Host: 127.0.0.1 -""" - -short_cache_response_hdr = f""" -HTTP/1.1 200 OK -Server: microserver -Connection: close -Cache-Control: max-age={CACHE_SHORT_MAXAGE} -Last-Modified: Thu, 10 Feb 2022 00:00:00 GMT -ETag: range -""" - -response_body = f"{''.join(str(i) for i in range(10))}\n" - -register(microserver, request_hdr, "", response_hdr, response_body) -register(microserver, short_cache_request_hdr, "", short_cache_response_hdr, response_body) - -# The purpose here is to have a somewhat smarter origin that can respond to If-Modified-Since queries. -# We then can test how the cache server using this origin deals with stale caches. -origin = Test.MakeATSProcess("origin") - -origin.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{microserver.Variables.Port}") - -origin.Disk.records_config.update( - { - "proxy.config.http.cache.http": 1, - "proxy.config.http.wait_for_cache": 1, - "proxy.config.http.insert_age_in_response": 0, - "proxy.config.http.request_via_str": 0, - "proxy.config.http.response_via_str": 0, - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - }) - -# Make the origin return 304 Not Modified for stale caches -origin.Disk.cache_config.AddLine("dest_ip=127.0.0.1 pin-in-cache=1d") - -# ---- -# Setup ATS -# ---- -# HACK: Don't use a fixed port because it causes ensuing tests to fail. The problem -# appears to be microDNS not allowing address reuse. -# -# https://docs.python.org/3/library/socketserver.html#socketserver.BaseServer.allow_reuse_address -ts = Test.MakeATSProcess("ts") - -ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{origin.Variables.port}/") - -ts.Disk.records_config.update( - { - "proxy.config.http.cache.http": 1, - "proxy.config.http.cache.range.write": 1, - "proxy.config.http.response_via_str": 3, - "proxy.config.http.wait_for_cache": 1, - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - }) -# ---- -# Test Cases -# ---- - -# On cache miss -# --- - -# ATS should ignore the Range header when given an If-Range header with the incorrect etag -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_range(ts, ifrange='"should-not-match"'), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.StartBefore(microserver, ready=When.PortOpen(microserver.Variables.Port)) -tr.Processes.Default.StartBefore(origin, ready=When.PortOpen(origin.Variables.port)) -tr.Processes.Default.StartBefore(Test.Processes.ts, ready=When.PortOpen(ts.Variables.port)) -tr.Processes.Default.Streams.stdout = "gold/range-200.gold" - -# On cache hit -# --- - -# ATS should respond to Range requests with partial content -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_range(ts), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-206.gold" - -# ATS should respond to Range requests with partial content when given an If-Range header with -# the correct etag -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_range(ts, ifrange='"range"'), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-206.gold" - -# ATS should respond to Range requests with partial content when given an If-Range header -# that matches the Last-Modified header of the cached response -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_range(ts, ifrange="Thu, 10 Feb 2022 00:00:00 GMT"), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-206.gold" - -# ATS should respond to Range requests with the full content when given an If-Range header -# that doesn't match the Last-Modified header of the cached response -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_range(ts, ifrange="Thu, 10 Feb 2022 01:00:00 GMT"), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-200.gold" - -# ATS should respond to Range requests with a 416 error code when the given Range is invalid -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_range(ts, start=100, end=105), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-416.gold" - -# ATS should ignore the Range header when given an If-Range header with the incorrect etag -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_range(ts, ifrange='"should-not-match"'), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-200.gold" - -# ATS should ignore the Range header when given an If-Range header with weak etags -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_range(ts, ifrange='W/"range"'), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-200.gold" - -# ATS should ignore the Range header when given an If-Range header with a date older than the -# Last-Modified header of the cached response -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_range(ts, ifrange="Wed, 09 Feb 2022 23:00:00 GMT"), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-200.gold" - -# Write to the cache by requesting the entire content -tr = Test.AddTestRun() -tr.MakeCurlCommand(curl_whole(ts, path="short"), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-200.gold" - -# ATS should respond to range requests with partial content for stale caches in response to -# valid If-Range requests if the origin responds with 304 Not Modified. -tr = Test.AddTestRun() -tr.MakeCurlCommandMulti(f"sleep {2 * CACHE_SHORT_MAXAGE}; {{curl}} " + curl_range(ts, path="short", ifrange='"range"'), ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/range-206-revalidated.gold" - -tr.StillRunningAfter = origin -tr.StillRunningAfter = microserver -tr.StillRunningAfter = ts +Test.ATSReplayTest(replay_file="replays/range.replay.yaml") diff --git a/tests/gold_tests/headers/replays/accept_webp.replay.yaml b/tests/gold_tests/headers/replays/accept_webp.replay.yaml new file mode 100644 index 00000000000..729d28d118d --- /dev/null +++ b/tests/gold_tests/headers/replays/accept_webp.replay.yaml @@ -0,0 +1,161 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + + blocks: + - origin_response_should_not_be_used: &origin_response_should_not_be_used + server-response: + status: 500 + reason: "Internal Server Error" + headers: + fields: + - [Content-Length, 16] + content: + encoding: plain + data: "origin-should-not" + +autest: + description: 'Verify cached image/webp responses are not reused for non-webp clients' + + server: + name: 'accept-webp-server' + + client: + name: 'accept-webp-client' + + ats: + name: 'ts-accept-webp' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http_match' + proxy.config.http.cache.ignore_accept_mismatch: 0 + proxy.config.http.insert_response_via_str: 3 + proxy.config.http.cache.http: 1 + proxy.config.http.wait_for_cache: 1 + + remap_config: + - from: "http://www.example.com/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + +sessions: + - transactions: + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.example.com] + - [Accept, "image/webp,image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5"] + - [uuid, webp-origin] + + proxy-request: + headers: + fields: + - [Accept, { value: "image/webp,image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5", as: equal }] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Connection, close] + - [Content-Type, image/webp] + - [Cache-Control, "max-age=300"] + - [Content-Length, 3] + content: + encoding: plain + data: "xxx" + + proxy-response: + status: 200 + headers: + fields: + - [Content-Type, { value: image/webp, as: equal }] + - [Cache-Control, { value: max-age=300, as: equal }] + content: + verify: + value: "xxx" + as: equal + + - client-request: + delay: 100ms + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.example.com] + - [Accept, "image/webp,image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5"] + - [uuid, webp-cache] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 200 + headers: + fields: + - [Content-Type, { value: image/webp, as: equal }] + - [Cache-Control, { value: max-age=300, as: equal }] + content: + verify: + value: "xxx" + as: equal + + - client-request: + delay: 100ms + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.example.com] + - [Accept, "image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5"] + - [uuid, no-webp-origin] + + proxy-request: + headers: + fields: + - [Accept, { value: "image/png,image/svg+xml,image/*;q=0.8,video/*;q=0.8,*/*;q=0.5", as: equal }] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Connection, close] + - [Content-Type, image/webp] + - [Cache-Control, "max-age=300"] + - [Content-Length, 3] + content: + encoding: plain + data: "yyy" + + proxy-response: + status: 200 + headers: + fields: + - [Content-Type, { value: image/webp, as: equal }] + - [Cache-Control, { value: max-age=300, as: equal }] + content: + verify: + value: "yyy" + as: equal diff --git a/tests/gold_tests/headers/replays/cache-test.replay.yaml b/tests/gold_tests/headers/replays/cache-test.replay.yaml index 9299ed849ea..50d5e2913f6 100644 --- a/tests/gold_tests/headers/replays/cache-test.replay.yaml +++ b/tests/gold_tests/headers/replays/cache-test.replay.yaml @@ -17,6 +17,32 @@ meta: version: "1.0" +autest: + description: 'Verify cached duplicate headers are preserved across stale revalidation' + + server: + name: 'cached-header-server' + + client: + name: 'cached-header-client' + + ats: + name: 'ts' + process_config: + enable_cache: true + + plugin_config: + - 'xdebug.so --enable=x-cache,x-cache-key,via' + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.response_via_str: 3 + + remap_config: + - from: "/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + # Note 1: # When testing duplicate headers here, replay files cannot # handle two seperate values. So make sure that duplicate headers diff --git a/tests/gold_tests/headers/replays/cached_ims_range.replay.yaml b/tests/gold_tests/headers/replays/cached_ims_range.replay.yaml new file mode 100644 index 00000000000..34a3e15ce46 --- /dev/null +++ b/tests/gold_tests/headers/replays/cached_ims_range.replay.yaml @@ -0,0 +1,429 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + + blocks: + - origin_response_should_not_be_used: &origin_response_should_not_be_used + server-response: + status: 500 + reason: "Internal Server Error" + headers: + fields: + - [Content-Length, 16] + content: + encoding: plain + data: "origin-should-not" + +autest: + description: 'Verify IMS and INM cache revalidation, range revalidation, and regex-remap 304 handling' + + server: + name: 'cached-ims-range-server' + + client: + name: 'cached-ims-range-client' + + ats: + name: 'ts-cached-ims-range' + process_config: + enable_cache: true + enable_tls: true + + plugin_config: + - 'xdebug.so --enable=x-cache,x-cache-key,via' + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.response_via_str: 3 + + copy_to_config_dir: + - 'maps.reg' + + remap_config: + - from: "https://www.default304.test/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + plugins: + - name: "regex_remap.so" + args: + - "maps.reg" + - "no-query-string" + - "host" + - from: "http://www.default304.test/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + plugins: + - name: "regex_remap.so" + args: + - "maps.reg" + - "no-query-string" + - "host" + - from: "/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + +sessions: + - transactions: + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.example.com] + - [UID, Fill] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, fill-lmt] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Connection, close] + - [Last-Modified, "Tue, 08 May 2018 15:49:41 GMT"] + - [Cache-Control, max-age=1] + - [Content-Length, 3] + content: + encoding: plain + data: "xxx" + + proxy-response: + status: 200 + headers: + fields: + - [X-Cache, { value: miss, as: equal }] + - [Content-Length, { value: 3, as: equal }] + content: + verify: + value: "xxx" + as: equal + + - client-request: + delay: 2s + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.example.com] + - [UID, IMS] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, ims-refresh] + + proxy-request: + headers: + fields: + - [If-Modified-Since, { value: "Tue, 08 May 2018 15:49:41 GMT", as: equal }] + + server-response: + status: 304 + reason: Not Modified + headers: + fields: + - [Connection, close] + - [Cache-Control, max-age=1] + + proxy-response: + status: 200 + headers: + fields: + - [X-Cache, { value: hit-stale, as: equal }] + - [Content-Length, { value: 3, as: equal }] + content: + verify: + value: "xxx" + as: equal + + - client-request: + delay: 2s + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.example.com] + - [UID, IMS] + - [x-debug, "x-cache,x-cache-key,via"] + - [Range, bytes=0-1] + - [uuid, ims-range-refresh] + + server-response: + status: 304 + reason: Not Modified + headers: + fields: + - [Connection, close] + - [Cache-Control, max-age=1] + + proxy-response: + status: 206 + headers: + fields: + - [X-Cache, { value: hit-stale, as: equal }] + - [Content-Length, { value: 2, as: equal }] + - [Content-Range, { value: "bytes 0-1/3", as: equal }] + content: + verify: + value: "xx" + as: equal + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.default304.test] + - [uuid, default304-http] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 304 + + - client-request: + method: GET + version: "1.1" + url: /etag + headers: + fields: + - [Host, www.example.com] + - [UID, EtagFill] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, fill-etag] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Connection, close] + - [ETag, myetag] + - [Cache-Control, max-age=1] + - [Content-Length, 3] + content: + encoding: plain + data: "xxx" + + proxy-response: + status: 200 + content: + verify: + value: "xxx" + as: equal + + - client-request: + delay: 2s + method: GET + version: "1.1" + url: /etag + headers: + fields: + - [Host, www.example.com] + - [UID, INM] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, inm-refresh] + + proxy-request: + headers: + fields: + - [If-None-Match, { value: myetag, as: equal }] + + server-response: + status: 304 + reason: Not Modified + headers: + fields: + - [Connection, close] + - [ETag, myetag] + - [Cache-Control, max-age=1] + + proxy-response: + status: 200 + headers: + fields: + - [X-Cache, { value: hit-stale, as: equal }] + - [ETag, { value: myetag, as: equal }] + content: + verify: + value: "xxx" + as: equal + + - client-request: + delay: 2s + method: GET + version: "1.1" + url: /etag + headers: + fields: + - [Host, www.example.com] + - [UID, INM] + - [x-debug, "x-cache,x-cache-key,via"] + - [Range, bytes=0-1] + - [uuid, inm-range-refresh] + + server-response: + status: 304 + reason: Not Modified + headers: + fields: + - [Connection, close] + - [ETag, myetag] + - [Cache-Control, max-age=1] + + proxy-response: + status: 206 + headers: + fields: + - [X-Cache, { value: hit-stale, as: equal }] + - [ETag, { value: myetag, as: equal }] + - [Content-Length, { value: 2, as: equal }] + - [Content-Range, { value: "bytes 0-1/3", as: equal }] + content: + verify: + value: "xx" + as: equal + + - client-request: + delay: 3s + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.example.com] + - [UID, noBody] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, nobody-refresh] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Connection, close] + - [Content-Length, 0] + - [Cache-Control, max-age=3] + + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 0, as: equal }] + - [Cache-Control, { value: max-age=3, as: equal }] + + - client-request: + delay: 100ms + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.example.com] + - [UID, noBody] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, nobody-cache] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 500 + + - client-request: + delay: 2s + method: GET + version: "1.1" + url: /etag + headers: + fields: + - [Host, www.example.com] + - [UID, EtagError] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, etag-error-refresh] + + server-response: + status: 404 + reason: Not Found + headers: + fields: + - [Connection, close] + - [Content-Length, 0] + - [Cache-Control, max-age=3] + + proxy-response: + status: 404 + headers: + fields: + - [Content-Length, { value: 0, as: equal }] + - [Cache-Control, { value: max-age=3, as: equal }] + + - client-request: + delay: 100ms + method: GET + version: "1.1" + url: /etag + headers: + fields: + - [Host, www.example.com] + - [UID, EtagError] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, etag-error-cache] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 500 + + - protocol: + stack: https + tls: + sni: www.default304.test + transactions: + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.default304.test] + - [uuid, default304-https] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 304 + + - protocol: + stack: http2 + tls: + sni: www.default304.test + transactions: + - client-request: + headers: + fields: + - [":method", GET] + - [":scheme", https] + - [":authority", www.default304.test] + - [":path", /] + - [uuid, default304-h2] + + <<: *origin_response_should_not_be_used + + proxy-response: + headers: + fields: + - [":status", { value: "304", as: equal }] diff --git a/tests/gold_tests/headers/replays/domain-blacklist-30x.replay.yaml b/tests/gold_tests/headers/replays/domain-blacklist-30x.replay.yaml new file mode 100644 index 00000000000..32f2616be0d --- /dev/null +++ b/tests/gold_tests/headers/replays/domain-blacklist-30x.replay.yaml @@ -0,0 +1,215 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + + blocks: + - origin_response_should_not_be_used: &origin_response_should_not_be_used + server-response: + status: 500 + reason: "Internal Server Error" + headers: + fields: + - [Content-Length, 16] + content: + encoding: plain + data: "origin-should-not" + +autest: + description: 'Verify header_rewrite redirects are returned for configured hosts' + + server: + name: 'redirect-server' + + client: + name: 'redirect-client' + + ats: + name: 'ts-domain-redirects' + + process_config: + disable_log_checks: true + + copy_to_config_dir: + - 'rewrite_rules' + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'header_rewrite|dbg_header_rewrite' + proxy.config.body_factory.enable_logging: 1 + + remap_config: + - >- + regex_map http://www.redirect301.test/ http://www.redirect301.test/ + @plugin=header_rewrite.so + @pparam=rewrite_rules/header_rewrite_rules_301.conf + - >- + regex_map http://www.redirect302.test/ http://www.redirect302.test/ + @plugin=header_rewrite.so + @pparam=rewrite_rules/header_rewrite_rules_302.conf + - >- + regex_map http://www.redirect307.test/ http://www.redirect307.test/ + @plugin=header_rewrite.so + @pparam=rewrite_rules/header_rewrite_rules_307.conf + - >- + regex_map http://www.redirect308.test/ http://www.redirect308.test/ + @plugin=header_rewrite.so + @pparam=rewrite_rules/header_rewrite_rules_308.conf + - >- + regex_map http://www.redirect0.test/ http://www.redirect0.test/ + @plugin=header_rewrite.so + @pparam=rewrite_rules/header_rewrite_rules_0.conf + + log_validation: + diags_log: + contains: + - expression: 'unsupported redirect status 0' + description: 'Verify the failure case for redirect status 0 is logged' + +sessions: + - transactions: + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.redirect301.test] + - [uuid, redirect-301] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 301 + headers: + fields: + - [Location, { value: "http://www.redirect301.test/", as: equal }] + - [Cache-Control, { value: no-store, as: equal }] + content: + verify: + value: 'The new location is "http://www.redirect301.test/".' + as: contains + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.redirect302.test] + - [uuid, redirect-302] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 302 + headers: + fields: + - [Location, { value: "http://www.redirect302.test/", as: equal }] + - [Cache-Control, { value: no-store, as: equal }] + content: + verify: + value: 'The new location is "http://www.redirect302.test/".' + as: contains + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.redirect307.test] + - [uuid, redirect-307] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 307 + headers: + fields: + - [Location, { value: "http://www.redirect307.test/", as: equal }] + - [Cache-Control, { value: no-store, as: equal }] + content: + verify: + value: 'The new location is "http://www.redirect307.test/".' + as: contains + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.redirect308.test] + - [uuid, redirect-308] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 308 + headers: + fields: + - [Location, { value: "http://www.redirect308.test/", as: equal }] + - [Cache-Control, { value: no-store, as: equal }] + content: + verify: + value: 'The new location is "http://www.redirect308.test/".' + as: contains + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.redirect0.test] + - [uuid, redirect-0] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 302 + headers: + fields: + - [Location, { value: "http://www.redirect0.test/", as: equal }] + - [Cache-Control, { value: no-store, as: equal }] + content: + verify: + value: 'The new location is "http://www.redirect0.test/".' + as: contains + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.passthrough.test] + - [uuid, passthrough-404] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 404 + headers: + fields: + - [Cache-Control, { value: no-store, as: equal }] + - [Content-Type, { value: text/html, as: contains }] + content: + verify: + value: "Not Found on Accelerator" + as: contains diff --git a/tests/gold_tests/headers/replays/hsts.replay.yaml b/tests/gold_tests/headers/replays/hsts.replay.yaml new file mode 100644 index 00000000000..477a2ff973a --- /dev/null +++ b/tests/gold_tests/headers/replays/hsts.replay.yaml @@ -0,0 +1,106 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + + blocks: + - origin_response_should_not_be_used: &origin_response_should_not_be_used + server-response: + status: 500 + reason: "Internal Server Error" + headers: + fields: + - [Content-Length, 0] + +autest: + description: 'Verify HSTS is added on mapped HTTPS traffic but not accelerator 404 responses' + + server: + name: 'hsts-server' + + client: + name: 'hsts-client' + + ats: + name: 'ts-hsts' + process_config: + enable_tls: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'ssl' + proxy.config.ssl.hsts_max_age: 300 + + remap_config: + - from: "https://www.example.com/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + +sessions: + - protocol: + stack: https + tls: + sni: www.example.com + transactions: + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, www.example.com] + - [uuid, hsts-200] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Connection, close] + - [Content-Length, 0] + + proxy-response: + status: 200 + headers: + fields: + - [Strict-Transport-Security, { value: max-age=300, as: equal }] + + - protocol: + stack: https + tls: + sni: bad_host + transactions: + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, bad_host] + - [uuid, hsts-404] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 404 + headers: + fields: + - [Strict-Transport-Security, { as: absent }] + - [Content-Type, { value: text/html, as: contains }] + content: + verify: + value: "Not Found on Accelerator" + as: contains diff --git a/tests/gold_tests/headers/replays/invalid_range_request.replay.yaml b/tests/gold_tests/headers/replays/invalid_range_request.replay.yaml index 5f6702bf0d1..2e68f97296b 100644 --- a/tests/gold_tests/headers/replays/invalid_range_request.replay.yaml +++ b/tests/gold_tests/headers/replays/invalid_range_request.replay.yaml @@ -17,6 +17,32 @@ meta: version: "1.0" +autest: + description: 'Verify invalid Range requests are forwarded to origin and return 416' + + server: + name: 'invalid-range-server' + + client: + name: 'invalid-range-client' + + ats: + name: 'ts' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.cache.http: 1 + proxy.config.http.cache.range.write: 1 + proxy.config.http.cache.required_headers: 0 + proxy.config.http.insert_age_in_response: 0 + + remap_config: + - from: "/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + sessions: # Populate cache entry - transactions: @@ -55,3 +81,10 @@ sessions: headers: fields: - [X-ResponseHeader, failed_response] + + proxy-response: + status: 416 + reason: Range Not Satisfiable + headers: + fields: + - [X-ResponseHeader, { value: failed_response, as: equal }] diff --git a/tests/gold_tests/headers/replays/normalized_ae_varied_transactions.replay.yaml b/tests/gold_tests/headers/replays/normalized_ae_varied_transactions.replay.yaml index 57842341a59..6aa18883c9a 100644 --- a/tests/gold_tests/headers/replays/normalized_ae_varied_transactions.replay.yaml +++ b/tests/gold_tests/headers/replays/normalized_ae_varied_transactions.replay.yaml @@ -26,6 +26,58 @@ meta: fields: - [ Content-Length, 0 ] +autest: + description: 'Verify cache matching with normalized Accept-Encoding and Vary' + + server: + name: 'normalized-ae-server' + + client: + name: 'normalized-ae-client' + + ats: + name: 'ts' + process_config: + enable_cache: true + + plugin_config: + - 'xdebug.so --enable=x-cache' + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.response_via_str: 3 + proxy.config.cache.limits.http.max_alts: 5 + proxy.config.http.cache.ignore_accept_mismatch: 2 + proxy.config.http.cache.ignore_accept_language_mismatch: 2 + proxy.config.http.cache.ignore_accept_encoding_mismatch: 2 + proxy.config.http.cache.ignore_accept_charset_mismatch: 2 + + remap_config: + - from: "http://www.ae-0.com/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + plugins: + - name: "conf_remap.so" + args: + - "proxy.config.http.normalize_ae=0" + - from: "http://www.ae-1.com/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + plugins: + - name: "conf_remap.so" + args: + - "proxy.config.http.normalize_ae=1" + - from: "http://www.ae-2.com/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + plugins: + - name: "conf_remap.so" + args: + - "proxy.config.http.normalize_ae=2" + - from: "http://www.ae-3.com/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + plugins: + - name: "conf_remap.so" + args: + - "proxy.config.http.normalize_ae=3" sessions: - transactions: diff --git a/tests/gold_tests/headers/replays/range.replay.yaml b/tests/gold_tests/headers/replays/range.replay.yaml new file mode 100644 index 00000000000..0355f8c6366 --- /dev/null +++ b/tests/gold_tests/headers/replays/range.replay.yaml @@ -0,0 +1,332 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + + blocks: + - full_object_response: &full_object_response + server-response: + status: 200 + reason: OK + headers: + fields: + - [Server, microserver] + - [Connection, close] + - [Cache-Control, max-age=300] + - [Last-Modified, "Thu, 10 Feb 2022 00:00:00 GMT"] + - [ETag, range] + - [Content-Length, 11] + content: + encoding: plain + data: "0123456789\n" + + - short_object_response: &short_object_response + server-response: + status: 200 + reason: OK + headers: + fields: + - [Server, microserver] + - [Connection, close] + - [Cache-Control, max-age=1] + - [Last-Modified, "Thu, 10 Feb 2022 00:00:00 GMT"] + - [ETag, range] + - [Content-Length, 11] + content: + encoding: plain + data: "0123456789\n" + + - origin_response_should_not_be_used: &origin_response_should_not_be_used + server-response: + status: 500 + reason: "Internal Server Error" + headers: + fields: + - [Content-Length, 16] + content: + encoding: plain + data: "origin-should-not" + +autest: + description: 'Verify range request handling for hits, misses, and stale cache revalidation' + + server: + name: 'range-server' + + client: + name: 'range-client' + + ats: + name: 'ts-range' + process_config: + enable_cache: true + + records_config: + proxy.config.http.cache.http: 1 + proxy.config.http.cache.range.write: 1 + proxy.config.http.response_via_str: 3 + proxy.config.http.wait_for_cache: 1 + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + + remap_config: + - from: "http://127.0.0.1/" + to: "http://127.0.0.1:{SERVER_HTTP_PORT}/" + +sessions: + - transactions: + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=1-5] + - [If-Range, '"should-not-match"'] + - [uuid, miss-ifrange] + + <<: *full_object_response + + proxy-response: + status: 200 + headers: + fields: + - [ETag, { value: range, as: equal }] + - [Content-Length, { value: 11, as: equal }] + content: + verify: + value: "0123456789\n" + as: equal + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=1-5] + - [uuid, hit-range] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 206 + headers: + fields: + - [ETag, { value: range, as: equal }] + - [Content-Length, { value: 5, as: equal }] + - [Content-Range, { value: "bytes 1-5/11", as: equal }] + content: + verify: + value: "12345" + as: equal + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=1-5] + - [If-Range, '"range"'] + - [uuid, hit-ifrange-etag] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 206 + headers: + fields: + - [Content-Range, { value: "bytes 1-5/11", as: equal }] + content: + verify: + value: "12345" + as: equal + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=1-5] + - [If-Range, "Thu, 10 Feb 2022 00:00:00 GMT"] + - [uuid, hit-ifrange-date] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 206 + headers: + fields: + - [Content-Range, { value: "bytes 1-5/11", as: equal }] + content: + verify: + value: "12345" + as: equal + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=1-5] + - [If-Range, "Thu, 10 Feb 2022 01:00:00 GMT"] + - [uuid, miss-ifrange-newer-date] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 200 + content: + verify: + value: "0123456789\n" + as: equal + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=100-105] + - [uuid, invalid-range] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 416 + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=1-5] + - [If-Range, '"should-not-match"'] + - [uuid, hit-ifrange-bad-etag] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 200 + content: + verify: + value: "0123456789\n" + as: equal + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=1-5] + - [If-Range, 'W/"range"'] + - [uuid, hit-ifrange-weak-etag] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 200 + content: + verify: + value: "0123456789\n" + as: equal + + - client-request: + method: GET + version: "1.1" + url: / + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=1-5] + - [If-Range, "Wed, 09 Feb 2022 23:00:00 GMT"] + - [uuid, hit-ifrange-older-date] + + <<: *origin_response_should_not_be_used + + proxy-response: + status: 200 + content: + verify: + value: "0123456789\n" + as: equal + + - client-request: + method: GET + version: "1.1" + url: /short + headers: + fields: + - [Host, 127.0.0.1] + - [uuid, fill-short] + + <<: *short_object_response + + proxy-response: + status: 200 + headers: + fields: + - [Cache-Control, { value: max-age=1, as: equal }] + content: + verify: + value: "0123456789\n" + as: equal + + - client-request: + delay: 2s + method: GET + version: "1.1" + url: /short + headers: + fields: + - [Host, 127.0.0.1] + - [Range, bytes=1-5] + - [If-Range, '"range"'] + - [uuid, revalidate-short] + + server-response: + status: 304 + reason: Not Modified + headers: + fields: + - [Cache-Control, max-age=1] + - [ETag, range] + + proxy-response: + status: 206 + headers: + fields: + - [Cache-Control, { value: max-age=1, as: equal }] + - [ETag, { value: range, as: equal }] + - [Content-Range, { value: "bytes 1-5/11", as: equal }] + content: + verify: + value: "12345" + as: equal diff --git a/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_0.conf b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_0.conf new file mode 100644 index 00000000000..4c9074d1556 --- /dev/null +++ b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_0.conf @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set-redirect 0 "%{CLIENT-URL}" diff --git a/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_301.conf b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_301.conf new file mode 100644 index 00000000000..1048164884f --- /dev/null +++ b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_301.conf @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set-redirect 301 "%{CLIENT-URL}" diff --git a/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_302.conf b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_302.conf new file mode 100644 index 00000000000..fb64f255bf8 --- /dev/null +++ b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_302.conf @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set-redirect 302 "%{CLIENT-URL}" diff --git a/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_307.conf b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_307.conf new file mode 100644 index 00000000000..cfdde954ca9 --- /dev/null +++ b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_307.conf @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set-redirect 307 "%{CLIENT-URL}" diff --git a/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_308.conf b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_308.conf new file mode 100644 index 00000000000..106a4ac7314 --- /dev/null +++ b/tests/gold_tests/headers/rewrite_rules/header_rewrite_rules_308.conf @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set-redirect 308 "%{CLIENT-URL}" diff --git a/tests/gold_tests/ip_allow/replays/h3.replay.yaml b/tests/gold_tests/ip_allow/replays/h3.replay.yaml index 187d046f9ae..ee2811a6d8f 100644 --- a/tests/gold_tests/ip_allow/replays/h3.replay.yaml +++ b/tests/gold_tests/ip_allow/replays/h3.replay.yaml @@ -19,10 +19,9 @@ meta: sessions: - protocol: - - name: http - version: 3 - - name: tls - sni: test_sni + stack: http3 + tls: + sni: test_sni transactions: - client-request: diff --git a/tests/gold_tests/ip_allow/replays/http_proxy_protocol.replay.yaml b/tests/gold_tests/ip_allow/replays/http_proxy_protocol.replay.yaml index 996182c0f45..b7d2242d2b6 100644 --- a/tests/gold_tests/ip_allow/replays/http_proxy_protocol.replay.yaml +++ b/tests/gold_tests/ip_allow/replays/http_proxy_protocol.replay.yaml @@ -30,12 +30,11 @@ meta: - [ Content-Length, 20 ] sessions: - protocol: - - name: http - version: 1 - - name: proxy-protocol - version: 2 - src-addr: "1.2.3.4:1111" - dst-addr: "5.6.7.8:2222" + stack: http + proxy-protocol: + version: 2 + src-addr: "1.2.3.4:1111" + dst-addr: "5.6.7.8:2222" transactions: # GET diff --git a/tests/gold_tests/ip_allow/replays/https_categories_all.replay.yaml b/tests/gold_tests/ip_allow/replays/https_categories_all.replay.yaml index 9c41fae78c5..86046bd1196 100644 --- a/tests/gold_tests/ip_allow/replays/https_categories_all.replay.yaml +++ b/tests/gold_tests/ip_allow/replays/https_categories_all.replay.yaml @@ -31,10 +31,9 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tls - sni: test_sni + stack: https + tls: + sni: test_sni transactions: # GET rejected diff --git a/tests/gold_tests/ip_allow/replays/https_categories_external.replay.yaml b/tests/gold_tests/ip_allow/replays/https_categories_external.replay.yaml index 54b67f5b974..525311cbeb9 100644 --- a/tests/gold_tests/ip_allow/replays/https_categories_external.replay.yaml +++ b/tests/gold_tests/ip_allow/replays/https_categories_external.replay.yaml @@ -31,10 +31,9 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tls - sni: test_sni + stack: https + tls: + sni: test_sni transactions: # GET allowed diff --git a/tests/gold_tests/ip_allow/replays/https_categories_external_remap.replay.yaml b/tests/gold_tests/ip_allow/replays/https_categories_external_remap.replay.yaml index 2ead15ebb7d..d6d1db4e535 100644 --- a/tests/gold_tests/ip_allow/replays/https_categories_external_remap.replay.yaml +++ b/tests/gold_tests/ip_allow/replays/https_categories_external_remap.replay.yaml @@ -31,10 +31,9 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tls - sni: test_sni + stack: https + tls: + sni: test_sni transactions: - client-request: diff --git a/tests/gold_tests/ip_allow/replays/https_categories_internal.replay.yaml b/tests/gold_tests/ip_allow/replays/https_categories_internal.replay.yaml index c8178be60e7..170575d4a67 100644 --- a/tests/gold_tests/ip_allow/replays/https_categories_internal.replay.yaml +++ b/tests/gold_tests/ip_allow/replays/https_categories_internal.replay.yaml @@ -30,10 +30,9 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tls - sni: test_sni + stack: https + tls: + sni: test_sni transactions: # GET allowed diff --git a/tests/gold_tests/ip_allow/replays/https_categories_server.replay.yaml b/tests/gold_tests/ip_allow/replays/https_categories_server.replay.yaml index 9c41fae78c5..86046bd1196 100644 --- a/tests/gold_tests/ip_allow/replays/https_categories_server.replay.yaml +++ b/tests/gold_tests/ip_allow/replays/https_categories_server.replay.yaml @@ -31,10 +31,9 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tls - sni: test_sni + stack: https + tls: + sni: test_sni transactions: # GET rejected diff --git a/tests/gold_tests/ip_allow/replays/https_multiple_methods.replay.yaml b/tests/gold_tests/ip_allow/replays/https_multiple_methods.replay.yaml index 0f212bbd743..aa938c9f5f6 100644 --- a/tests/gold_tests/ip_allow/replays/https_multiple_methods.replay.yaml +++ b/tests/gold_tests/ip_allow/replays/https_multiple_methods.replay.yaml @@ -30,10 +30,9 @@ meta: - [ Content-Length, 20 ] sessions: - protocol: - - name: http - version: 1 - - name: tls - sni: test_sni + stack: https + tls: + sni: test_sni transactions: # GET diff --git a/tests/gold_tests/logging/replay/basic1.replay.yaml b/tests/gold_tests/logging/replay/basic1.replay.yaml index 4de3719c2fa..79219bd3ad8 100644 --- a/tests/gold_tests/logging/replay/basic1.replay.yaml +++ b/tests/gold_tests/logging/replay/basic1.replay.yaml @@ -19,10 +19,9 @@ meta: sessions: - protocol: - - name: http - version: 3 - - name: tls - sni: test_sni + stack: http3 + tls: + sni: test_sni transactions: - client-request: diff --git a/tests/gold_tests/pluginTest/access_control/replays/access_control.replay.yaml b/tests/gold_tests/pluginTest/access_control/replays/access_control.replay.yaml index 93fe0538904..ac43ec24d9e 100644 --- a/tests/gold_tests/pluginTest/access_control/replays/access_control.replay.yaml +++ b/tests/gold_tests/pluginTest/access_control/replays/access_control.replay.yaml @@ -15,7 +15,10 @@ # limitations under the License. sessions: -- protocol: [{ name: tls, sni: test }] +- protocol: + stack: https + tls: + sni: test transactions: # 1: Regular request diff --git a/tests/gold_tests/pluginTest/cache_promote/replay/cache_promote.replay.yaml.tmpl b/tests/gold_tests/pluginTest/cache_promote/replay/cache_promote.replay.yaml.tmpl index 422da45cdf1..75ffd59935c 100644 --- a/tests/gold_tests/pluginTest/cache_promote/replay/cache_promote.replay.yaml.tmpl +++ b/tests/gold_tests/pluginTest/cache_promote/replay/cache_promote.replay.yaml.tmpl @@ -22,11 +22,7 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tcp - - name: ip - + stack: http transactions: # # test case 0-0 : simple LRU policy case - 3rd request is expected to hit the cache diff --git a/tests/gold_tests/pluginTest/certifier/replays/https-two-sessions.replay.yaml b/tests/gold_tests/pluginTest/certifier/replays/https-two-sessions.replay.yaml index 9d2da6d9450..ea7f4f6c0a3 100644 --- a/tests/gold_tests/pluginTest/certifier/replays/https-two-sessions.replay.yaml +++ b/tests/gold_tests/pluginTest/certifier/replays/https-two-sessions.replay.yaml @@ -18,7 +18,10 @@ meta: version: "1.0" sessions: - - protocol: [{ name: tls, sni: www.tls.com }, { name: tcp }, { name: ip }] + - protocol: + stack: https + tls: + sni: www.tls.com transactions: - client-request: @@ -42,7 +45,10 @@ sessions: status: 200 # separate session to trigger a new TLS handshake to engage the certifier - - protocol: [{ name: tls, sni: www.tls.com }, { name: tcp }, { name: ip }] + - protocol: + stack: https + tls: + sni: www.tls.com transactions: - client-request: diff --git a/tests/gold_tests/pluginTest/certifier/replays/https.replay.yaml b/tests/gold_tests/pluginTest/certifier/replays/https.replay.yaml index 084a94a0297..b8e500a5ce8 100644 --- a/tests/gold_tests/pluginTest/certifier/replays/https.replay.yaml +++ b/tests/gold_tests/pluginTest/certifier/replays/https.replay.yaml @@ -18,7 +18,10 @@ meta: version: "1.0" sessions: - - protocol: [{ name: tls, sni: www.tls.com }, { name: tcp }, { name: ip }] + - protocol: + stack: https + tls: + sni: www.tls.com transactions: - client-request: diff --git a/tests/gold_tests/pluginTest/escalate/escalate.test.py b/tests/gold_tests/pluginTest/escalate/escalate.test.py index 68c4e7a9151..d00c306f083 100644 --- a/tests/gold_tests/pluginTest/escalate/escalate.test.py +++ b/tests/gold_tests/pluginTest/escalate/escalate.test.py @@ -33,6 +33,8 @@ class EscalateTest: _replay_original_file: str = 'escalate_original.replay.yaml' _replay_failover_file: str = 'escalate_failover.replay.yaml' + _server_original_file: str = 'escalate_original_server_default.replay.yaml' + _server_failover_file: str = 'escalate_failover_server_default.replay.yaml' def __init__(self): '''Configure the test run.''' @@ -56,8 +58,10 @@ def _setup_servers(self, tr: 'Process') -> None: ''' tr.Setup.Copy(self._replay_original_file) tr.Setup.Copy(self._replay_failover_file) - self._server_origin = tr.AddVerifierServerProcess(f"server_origin", self._replay_original_file) - self._server_failover = tr.AddVerifierServerProcess(f"server_failover", self._replay_failover_file) + tr.Setup.Copy(self._server_original_file) + tr.Setup.Copy(self._server_failover_file) + self._server_origin = tr.AddVerifierServerProcess(f"server_origin", self._server_original_file) + self._server_failover = tr.AddVerifierServerProcess(f"server_failover", self._server_failover_file) self._server_origin.Streams.All += Testers.ContainsExpression( 'uuid: GET', "Verify the origin server received the GET request.") diff --git a/tests/gold_tests/pluginTest/escalate/escalate_failover_server_default.replay.yaml b/tests/gold_tests/pluginTest/escalate/escalate_failover_server_default.replay.yaml new file mode 100644 index 00000000000..7b7132dca16 --- /dev/null +++ b/tests/gold_tests/pluginTest/escalate/escalate_failover_server_default.replay.yaml @@ -0,0 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + +sessions: +- transactions: + - client-request: + method: "GET" + version: "1.1" + url: /path/get_failed + headers: + fields: + - [ Host, origin.server.com ] + - [ Content-Length, 0 ] + - [ X-Request, third ] + - [ uuid, GET_failed ] + + proxy-request: + method: "GET" + headers: + fields: + - [ X-Request, { value: third, as: equal } ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 320000 ] + - [ X-Response, third ] + + - client-request: + method: "GET" + version: "1.1" + url: /path/get_down + headers: + fields: + - [ Host, down_origin.server.com ] + - [ Content-Length, 0 ] + - [ X-Request, fourth ] + - [ uuid, GET_down_origin ] + + proxy-request: + method: "GET" + headers: + fields: + - [ X-Request, { value: fourth, as: equal } ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Transfer-Encoding, chunked ] + - [ X-Response, fourth ] + content: + size: 320000 diff --git a/tests/gold_tests/pluginTest/escalate/escalate_original_server_default.replay.yaml b/tests/gold_tests/pluginTest/escalate/escalate_original_server_default.replay.yaml new file mode 100644 index 00000000000..05a1417f2b7 --- /dev/null +++ b/tests/gold_tests/pluginTest/escalate/escalate_original_server_default.replay.yaml @@ -0,0 +1,96 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + +sessions: +- transactions: + - client-request: + method: "GET" + version: "1.1" + url: /path/get + headers: + fields: + - [ Host, origin.server.com ] + - [ Content-Length, 0 ] + - [ X-Request, first ] + - [ uuid, GET ] + + proxy-request: + method: "GET" + headers: + fields: + - [ X-Request, { value: first, as: equal } ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 320000 ] + - [ X-Response, first ] + + - client-request: + method: "GET" + version: "1.1" + url: /path/get_chunked + headers: + fields: + - [ Host, origin.server.com ] + - [ Content-Length, 0 ] + - [ X-Request, second ] + - [ uuid, GET_chunked ] + + proxy-request: + method: "GET" + headers: + fields: + - [ X-Request, { value: second, as: equal } ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Transfer-Encoding, chunked ] + - [ X-Response, second ] + content: + size: 320000 + + - client-request: + method: "GET" + version: "1.1" + url: /path/get_failed + headers: + fields: + - [ Host, origin.server.com ] + - [ Content-Length, 0 ] + - [ X-Request, third ] + - [ uuid, GET_failed ] + + proxy-request: + method: "GET" + headers: + fields: + - [ X-Request, { value: third, as: equal } ] + + server-response: + status: 502 + reason: Bad Gateway + headers: + fields: + - [ Content-Length, 0 ] diff --git a/tests/gold_tests/pluginTest/ja3_fingerprint/ja3_fingerprint_global.replay.yaml b/tests/gold_tests/pluginTest/ja3_fingerprint/ja3_fingerprint_global.replay.yaml index 6c0806898e0..5d178af6c48 100644 --- a/tests/gold_tests/pluginTest/ja3_fingerprint/ja3_fingerprint_global.replay.yaml +++ b/tests/gold_tests/pluginTest/ja3_fingerprint/ja3_fingerprint_global.replay.yaml @@ -20,11 +20,9 @@ meta: sessions: - protocol: - - name: tls - sni: https.server.com - - name: tcp - - name: ip - + stack: https + tls: + sni: https.server.com transactions: - client-request: @@ -61,13 +59,9 @@ sessions: - [ X-Response, { value: 'https-response', as: equal } ] - protocol: - - name: http - version: 2 - - name: tls - sni: http2.server.com - - name: tcp - - name: ip - + stack: http2 + tls: + sni: http2.server.com transactions: - client-request: diff --git a/tests/gold_tests/pluginTest/ja3_fingerprint/ja3_fingerprint_remap.replay.yaml b/tests/gold_tests/pluginTest/ja3_fingerprint/ja3_fingerprint_remap.replay.yaml index 6123304bc94..38c1a83c697 100644 --- a/tests/gold_tests/pluginTest/ja3_fingerprint/ja3_fingerprint_remap.replay.yaml +++ b/tests/gold_tests/pluginTest/ja3_fingerprint/ja3_fingerprint_remap.replay.yaml @@ -20,11 +20,9 @@ meta: sessions: - protocol: - - name: tls - sni: https.server.com - - name: tcp - - name: ip - + stack: https + tls: + sni: https.server.com transactions: - client-request: @@ -63,13 +61,9 @@ sessions: - [ X-Response, { value: 'https-response', as: equal } ] - protocol: - - name: http - version: 2 - - name: tls - sni: http2.server.com - - name: tcp - - name: ip - + stack: http2 + tls: + sni: http2.server.com transactions: - client-request: diff --git a/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint.replay.yaml b/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint.replay.yaml index 8e23953c950..dd1ea625470 100644 --- a/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint.replay.yaml +++ b/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint.replay.yaml @@ -19,11 +19,7 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tcp - - name: ip - + stack: http transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint.test.py b/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint.test.py index c235a822618..10da9358d7c 100644 --- a/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint.test.py +++ b/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint.test.py @@ -33,22 +33,26 @@ class TestJA4Fingerprint: '''Configure a test for ja4_fingerprint.''' replay_filepath: str = 'ja4_fingerprint.replay.yaml' + basic_server_replay_filepath: str = 'ja4_fingerprint_basic_server.replay.yaml' client_counter: int = 0 server_counter: int = 0 ts_counter: int = 0 - def __init__(self, name: str, /, autorun: bool) -> None: + def __init__(self, name: str, /, autorun: bool, use_preserve: bool = False) -> None: '''Initialize the test. :param name: The name of the test. + :param use_preserve: Whether to use the --preserve flag. ''' self.name = name self.autorun = autorun + self.use_preserve = use_preserve def _init_run(self) -> 'TestRun': '''Initialize processes for the test run.''' - server_one = TestJA4Fingerprint.configure_server('yay.com') + replay_filepath = self.replay_filepath if self.use_preserve else self.basic_server_replay_filepath + server_one = TestJA4Fingerprint.configure_server('yay.com', replay_filepath=replay_filepath) self._configure_traffic_server(server_one) tr = Test.AddTestRun(self.name) @@ -93,11 +97,9 @@ def wrapper(*args, **kwargs) -> Any: return wrapper @staticmethod - def configure_server(domain: str): + def configure_server(domain: str, replay_filepath: str): server = Test.MakeVerifierServerProcess( - f'server{TestJA4Fingerprint.server_counter + 1}.{domain}', - TestJA4Fingerprint.replay_filepath, - other_args='--format \'{url}\'') + f'server{TestJA4Fingerprint.server_counter + 1}.{domain}', replay_filepath, other_args="--format '{url}'") TestJA4Fingerprint.server_counter += 1 return server @@ -117,6 +119,7 @@ def _configure_traffic_server(self, server_one: 'Process'): 'proxy.config.ssl.server.cert.path': f'{ts.Variables.SSLDir}', 'proxy.config.ssl.server.private_key.path': f'{ts.Variables.SSLDir}', 'proxy.config.http.server_ports': f'{self._port_one}:ssl', + 'proxy.config.proxy_name': 'test.proxy.com', 'proxy.config.diags.debug.enabled': 1, 'proxy.config.diags.debug.tags': 'ja4_fingerprint|http', }) @@ -144,7 +147,8 @@ def _configure_wait_for_log(self, server_one: 'Process'): 'then a JA4 header should be attached.') def test1(params: TestParams) -> None: client = params['tr'].Processes.Default - params['tr'].MakeCurlCommand('-k -v "https://localhost:{0}/resource"'.format(params['port_one']), ts=params['ts']) + params['tr'].MakeCurlCommand( + '-k -v -H "uuid: no-existing-headers" "https://localhost:{0}/resource"'.format(params['port_one']), ts=params['ts']) client.ReturnCode = 0 client.Streams.stdout += Testers.ContainsExpression(r'Yay!', 'We should receive the expected body.') diff --git a/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint_basic_server.replay.yaml b/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint_basic_server.replay.yaml new file mode 100644 index 00000000000..dbb3f4cfab3 --- /dev/null +++ b/tests/gold_tests/pluginTest/ja4_fingerprint/ja4_fingerprint_basic_server.replay.yaml @@ -0,0 +1,44 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + +sessions: +- protocol: + stack: http + transactions: + - client-request: + method: "GET" + version: "1.1" + url: /resource + headers: + fields: + - [ Connection, keep-alive ] + - [ Content-Length, 0 ] + - [ uuid, no-existing-headers ] + + proxy-request: + headers: + fields: + - [ ja4, { as: present } ] + + server-response: + status: 200 + reason: OK + content: + encoding: plain + data: Yay! diff --git a/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_copy.replay.yaml b/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_copy.replay.yaml index aaadd0d3c43..eafee5314ed 100644 --- a/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_copy.replay.yaml +++ b/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_copy.replay.yaml @@ -19,11 +19,7 @@ meta: sessions: - protocol: - - name: http - - name: tls - - name: tcp - - name: ip - + stack: https transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_copy_skip_post.replay.yaml b/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_copy_skip_post.replay.yaml index 243160b93db..4b944a24deb 100644 --- a/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_copy_skip_post.replay.yaml +++ b/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_copy_skip_post.replay.yaml @@ -19,11 +19,7 @@ meta: sessions: - protocol: - - name: http - - name: tls - - name: tcp - - name: ip - + stack: https transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_original.replay.yaml b/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_original.replay.yaml index a3b26e27dad..9e3dd1564e3 100644 --- a/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_original.replay.yaml +++ b/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_original.replay.yaml @@ -19,11 +19,7 @@ meta: sessions: - protocol: - - name: http - - name: tls - - name: tcp - - name: ip - + stack: https transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_original_skip_post.replay.yaml b/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_original_skip_post.replay.yaml index 5639227aa0b..a479d476831 100644 --- a/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_original_skip_post.replay.yaml +++ b/tests/gold_tests/pluginTest/multiplexer/replays/multiplexer_original_skip_post.replay.yaml @@ -19,11 +19,7 @@ meta: sessions: - protocol: - - name: http - - name: tls - - name: tcp - - name: ip - + stack: https transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/pluginTest/traffic_dump/replay/http3.yaml b/tests/gold_tests/pluginTest/traffic_dump/replay/http3.yaml index e4eb5dd84c5..1d6f6f9997f 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/replay/http3.yaml +++ b/tests/gold_tests/pluginTest/traffic_dump/replay/http3.yaml @@ -28,10 +28,10 @@ meta: - [ Connection, close ] sessions: -- protocol: [ {name: http, version: 3}, - {name: tls, sni: www.tls.com}, - {name: udp}, - {name: ip} ] +- protocol: + stack: http3 + tls: + sni: www.tls.com transactions: - client-request: diff --git a/tests/gold_tests/pluginTest/traffic_dump/replay/response_body.yaml b/tests/gold_tests/pluginTest/traffic_dump/replay/response_body.yaml index c301f36082d..5529466d339 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/replay/response_body.yaml +++ b/tests/gold_tests/pluginTest/traffic_dump/replay/response_body.yaml @@ -110,10 +110,10 @@ sessions: # # Test 3: An HTTP/2 request body. # -- protocol: [ {name: http, version: 2}, - {name: tls, sni: www.tls.com}, - {name: tcp}, - {name: ip} ] +- protocol: + stack: http2 + tls: + sni: www.tls.com transactions: - client-request: diff --git a/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump.yaml b/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump.yaml index fc76d0f39cb..3849c46708a 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump.yaml +++ b/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump.yaml @@ -259,9 +259,10 @@ sessions: proxy-response: status: 200 -- protocol: [ {name: tls, sni: www.tls.com }, - {name: tcp }, - {name: ip} ] +- protocol: + stack: https + tls: + sni: www.tls.com transactions: - client-request: @@ -279,10 +280,10 @@ sessions: proxy-response: status: 200 -- protocol: [ {name: http, version: 2}, - {name: tls, sni: www.tls.com}, - {name: tcp}, - {name: ip} ] +- protocol: + stack: http2 + tls: + sni: www.tls.com transactions: - client-request: @@ -313,9 +314,10 @@ sessions: proxy-response: status: 200 -- protocol: [ {name: tls, sni: www.client_only_tls.com}, - {name: tcp}, - {name: ip} ] +- protocol: + stack: https + tls: + sni: www.client_only_tls.com transactions: - client-request: diff --git a/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump_ip_filter_server.yaml b/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump_ip_filter_server.yaml new file mode 100644 index 00000000000..003b004030a --- /dev/null +++ b/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump_ip_filter_server.yaml @@ -0,0 +1,44 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + +sessions: +- transactions: + - client-request: + method: GET + url: /one + version: 1.1 + headers: + fields: + - [ Host, www.notls.com ] + - [ X-Request-1, ultra_sensitive ] + - [ Content-Length, 0 ] + - [ uuid, 1 ] + + proxy-request: + headers: + fields: + - [ X-Request-1, { value: ultra_sensitive, as: equal } ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 16 ] + - [ Set-Cookie, classified_not_for_logging ] diff --git a/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump_server.yaml b/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump_server.yaml new file mode 100644 index 00000000000..69507431781 --- /dev/null +++ b/tests/gold_tests/pluginTest/traffic_dump/replay/traffic_dump_server.yaml @@ -0,0 +1,241 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +meta: + version: "1.0" + + blocks: + - 200_ok_response: &200_ok_response + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 16 ] + - [ Connection, close ] + +sessions: +- transactions: + - client-request: + method: GET + url: /one + version: 1.1 + headers: + fields: + - [ Host, www.notls.com ] + - [ X-Request-1, ultra_sensitive ] + - [ Content-Length, 0 ] + - [ uuid, 1 ] + + proxy-request: + headers: + fields: + - [ X-Request-1, { value: ultra_sensitive, as: equal } ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 16 ] + - [ Set-Cookie, classified_not_for_logging ] + +- transactions: + - client-request: + method: GET + url: /two + version: 1.1 + headers: + fields: + - [ Host, www.notls.com ] + - [ X-Request-2, also_very_sensitive ] + - [ Content-Length, 0 ] + - [ uuid, 2 ] + + proxy-request: + headers: + fields: + - [ X-Request-2, { value: also_very_sensitive, as: equal } ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 16 ] + - [ Set-Cookie, classified_not_for_logging ] + +- transactions: + - client-request: + method: GET + url: "http://www.some.host.com/candy" + version: 1.1 + headers: + fields: + - [ Host, www.some.host.com ] + - [ Content-Length, 0 ] + - [ uuid, 3 ] + + proxy-request: + url: + - [ scheme, { as: absent } ] + - [ host, { as: absent } ] + - [ path, { value: /candy, as: equal } ] + headers: + fields: + - [ Host, { value: www.some.host.com, as: equal } ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 16 ] + - [ Set-Cookie, classified_not_for_logging ] + +- transactions: + - client-request: + method: POST + url: /post/with/body + version: 1.1 + headers: + fields: + - [ Host, www.notls.com ] + - [ Content-Length, 12345 ] + - [ uuid, 4 ] + + proxy-request: + url: + - [ path, { value: /post/with/body, as: equal } ] + headers: + fields: + - [ Host, { value: www.notls.com, as: equal } ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 16 ] + - [ Set-Cookie, classified_not_for_logging ] + +- transactions: + - client-request: + method: GET + url: /expect/this/to/be/cached + version: 1.1 + headers: + fields: + - [ Host, www.notls.com ] + - [ Content-Length, 0 ] + - [ uuid, 5 ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 16 ] + - [ Cache-Control, max-age=300 ] + +- transactions: + - client-request: + method: GET + url: /first + version: 1.1 + headers: + fields: + - [ Host, www.notls.com ] + - [ Content-Length, 0 ] + - [ uuid, 7 ] + + <<: *200_ok_response + + - client-request: + method: GET + url: /second + version: 1.1 + headers: + fields: + - [ Host, www.notls.com ] + - [ Content-Length, 0 ] + - [ uuid, 8 ] + + <<: *200_ok_response + +- protocol: + stack: https + tls: + sni: www.tls.com + + transactions: + - client-request: + method: GET + url: /tls + version: 1.1 + headers: + fields: + - [ Host, www.tls.com ] + - [ Content-Length, 0 ] + - [ uuid, 9 ] + + <<: *200_ok_response + +- protocol: + stack: http2 + tls: + sni: www.tls.com + + transactions: + - client-request: + headers: + fields: + - [ :method, GET ] + - [ :scheme, https ] + - [ :authority, www.tls.com ] + - [ :path, /h2_first ] + - [ uuid, 10 ] + + <<: *200_ok_response + + - client-request: + headers: + fields: + - [ :method, GET ] + - [ :scheme, https ] + - [ :authority, www.tls.com ] + - [ :path, /h2_second ] + - [ uuid, 11 ] + + <<: *200_ok_response + +- protocol: + stack: https + tls: + sni: www.client_only_tls.com + + transactions: + - client-request: + method: GET + url: /client_only_tls + version: 1.1 + headers: + fields: + - [ Host, www.client_only_tls.com ] + - [ Content-Length, 0 ] + - [ uuid, 12 ] + + <<: *200_ok_response diff --git a/tests/gold_tests/pluginTest/traffic_dump/replay/various_sni.yaml b/tests/gold_tests/pluginTest/traffic_dump/replay/various_sni.yaml index 4d5f30b16c2..fb2c33e0286 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/replay/various_sni.yaml +++ b/tests/gold_tests/pluginTest/traffic_dump/replay/various_sni.yaml @@ -38,10 +38,10 @@ sessions: # # Test 1: Create a session using an SNI of "bob". # -- protocol: [ {name: http, version: 2}, - {name: tls, sni: bob.com}, - {name: tcp }, - {name: ip} ] +- protocol: + stack: http2 + tls: + sni: bob.com transactions: @@ -63,10 +63,10 @@ sessions: # # Test 2: Create a session using an SNI of "dave.com". # -- protocol: [ {name: http, version: 2}, - {name: tls, sni: dave.com}, - {name: tcp }, - {name: ip} ] +- protocol: + stack: http2 + tls: + sni: dave.com transactions: @@ -88,10 +88,8 @@ sessions: # # Test 3: Create a session using no SNI. # -- protocol: [ {name: http, version: 2}, - {name: tls}, - {name: tcp }, - {name: ip} ] +- protocol: + stack: http2 transactions: diff --git a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py index 645c5c52b8c..7a0eafb8429 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py +++ b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py @@ -30,7 +30,8 @@ # Configure the origin server. replay_file = "replay/traffic_dump.yaml" -server = Test.MakeVerifierServerProcess("server", replay_file, ssl_cert="ssl/server_combined.pem", ca_cert="ssl/signer.pem") +server = Test.MakeVerifierServerProcess( + "server", "replay/traffic_dump_server.yaml", ssl_cert="ssl/server_combined.pem", ca_cert="ssl/signer.pem") # Define ATS and configure it. ts = Test.MakeATSProcess("ts", enable_tls=True) diff --git a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_ip_filter.test.py b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_ip_filter.test.py index 5aa7e6851dc..60bc55cda62 100644 --- a/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_ip_filter.test.py +++ b/tests/gold_tests/pluginTest/traffic_dump/traffic_dump_ip_filter.test.py @@ -28,7 +28,7 @@ # Configure the origin server. replay_file = "replay/traffic_dump.yaml" -server = Test.MakeVerifierServerProcess("server", replay_file) +server = Test.MakeVerifierServerProcess("server", "replay/traffic_dump_ip_filter_server.yaml") def get_common_ats_process(name, plugin_command, replay_exists): diff --git a/tests/gold_tests/pluginTest/transform/transaction-with-body.replays.yaml b/tests/gold_tests/pluginTest/transform/transaction-with-body.replays.yaml index 07a4b1a8046..31c4e333844 100644 --- a/tests/gold_tests/pluginTest/transform/transaction-with-body.replays.yaml +++ b/tests/gold_tests/pluginTest/transform/transaction-with-body.replays.yaml @@ -157,13 +157,9 @@ sessions: status: 200 - protocol: - - name: http - version: 2 - - name: tls - sni: test_sni - - name: tcp - - name: ip - + stack: http2 + tls: + sni: test_sni transactions: #--------------------------------------------------------------------------- diff --git a/tests/gold_tests/pluginTest/tsapi/test_TSVConnPPInfo.test.py b/tests/gold_tests/pluginTest/tsapi/test_TSVConnPPInfo.test.py index 5daf5abb474..f40c772a7b3 100644 --- a/tests/gold_tests/pluginTest/tsapi/test_TSVConnPPInfo.test.py +++ b/tests/gold_tests/pluginTest/tsapi/test_TSVConnPPInfo.test.py @@ -73,7 +73,9 @@ # plaintext HTTP tr = Test.AddTestRun() tr.TimeOut = 10 -tr.Processes.Default.Command = f"curl --haproxy-protocol --haproxy-clientip 1.2.3.4 'http://127.0.0.1:{ts.Variables.proxy_protocol_port}/httpbin/get'" +tr.Processes.Default.Command = ( + f"curl --haproxy-protocol --haproxy-clientip 1.2.3.4 " + f"'http://127.0.0.1:{ts.Variables.proxy_protocol_port}/httpbin/get'") tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.StartBefore(httpbin, ready=When.PortOpen(httpbin.Variables.Port)) tr.Processes.Default.StartBefore(Test.Processes.ts) @@ -84,7 +86,9 @@ # HTTPS tr = Test.AddTestRun() tr.TimeOut = 10 -tr.Processes.Default.Command = f"curl --haproxy-protocol --haproxy-clientip 5.6.7.8 -k 'https://127.0.0.1:{ts.Variables.proxy_protocol_ssl_port}/httpbin/get'" +tr.Processes.Default.Command = ( + f"curl --haproxy-protocol --haproxy-clientip 5.6.7.8 -k " + f"'https://127.0.0.1:{ts.Variables.proxy_protocol_ssl_port}/httpbin/get'") tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "test_TSVConnPPInfo_curl1.gold" tr.StillRunningAfter = httpbin @@ -95,7 +99,8 @@ tr.Processes.Default.ReturnCode = 0 f = tr.Disk.File(log_path) f.Content = "test_TSVConnPPInfo_plugin_log.gold" +# curl 8.20+ intentionally uses --haproxy-clientip for both PROXY addresses so the address family matches. f.Content += Testers.ContainsExpression( - "PP Info Received:V1,P2,T1,SRC1.2.3.4,DST127.0.0.1", "Expected information should be received") + r"PP Info Received:V1,P2,T1,SRC1\.2\.3\.4,DST(127\.0\.0\.1|1\.2\.3\.4)", "Expected information should be received") f.Content += Testers.ContainsExpression( - "PP Info Received:V1,P2,T1,SRC5.6.7.8,DST127.0.0.1", "Expected information should be received") + r"PP Info Received:V1,P2,T1,SRC5\.6\.7\.8,DST(127\.0\.0\.1|5\.6\.7\.8)", "Expected information should be received") diff --git a/tests/gold_tests/pluginTest/txn_box/basic/basic.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/basic.replay.yaml index f25a84127b2..05babe6a75b 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/basic.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/basic.replay.yaml @@ -180,7 +180,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # - all: { headers: { fields: [[ uuid, ts-uuid]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/cmp.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/cmp.replay.yaml index 153e7c31ee8..1d71b122530 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/cmp.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/cmp.replay.yaml @@ -88,7 +88,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] # plain text sessions +- protocol: # plain text sessions + stack: http transactions: # - all: { headers: { fields: [[ uuid, 1 ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/ip-addr.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/ip-addr.replay.yaml index b0635579d5a..038a8b7f5fc 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/ip-addr.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/ip-addr.replay.yaml @@ -46,7 +46,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4 } ] # plain text sessions +- protocol: # plain text sessions + stack: http transactions: # - all: { headers: { fields: [[ uuid, 1 ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/mod.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/mod.replay.yaml index a0f066fb5f1..b0d1d378863 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/mod.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/mod.replay.yaml @@ -61,7 +61,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: ## Checks for the concat modifier. @@ -172,7 +173,8 @@ sessions: proxy-response: <<: *base-rsp -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: ## Checks for regular expression modifier. diff --git a/tests/gold_tests/pluginTest/txn_box/basic/multi-cfg.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/multi-cfg.replay.yaml index 21cdae08da5..b2bc8274125 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/multi-cfg.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/multi-cfg.replay.yaml @@ -17,7 +17,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 0 ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/redirect.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/redirect.replay.yaml index 35fb7c9b405..d677347aa77 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/redirect.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/redirect.replay.yaml @@ -63,7 +63,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 101 ]]}} client-request: @@ -72,8 +73,6 @@ sessions: headers: fields: - [ Host, base.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -89,8 +88,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -106,8 +103,6 @@ sessions: headers: fields: - [ Host, base.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -123,8 +118,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -140,8 +133,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -158,8 +149,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -194,8 +183,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -211,8 +198,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -228,8 +213,6 @@ sessions: headers: fields: - [ "Host", "encode.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -244,8 +227,6 @@ sessions: headers: fields: - [ "Host", "decode.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: diff --git a/tests/gold_tests/pluginTest/txn_box/basic/reply.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/reply.replay.yaml index def38d97d11..062a2e14caf 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/reply.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/reply.replay.yaml @@ -41,7 +41,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, delain ]]}} @@ -65,8 +66,6 @@ sessions: headers: fields: - [ Host, bad.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -79,8 +78,6 @@ sessions: headers: fields: - [ Host, bad.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -93,8 +90,6 @@ sessions: headers: fields: - [ Host, bad.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: diff --git a/tests/gold_tests/pluginTest/txn_box/basic/rxp.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/rxp.replay.yaml index ba997241333..408b47cedc4 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/rxp.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/rxp.replay.yaml @@ -35,7 +35,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # - all: { headers: { fields: [[ uuid, 1 ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/stat.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/stat.replay.yaml index a4d5383d54d..4d4431541b0 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/stat.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/stat.replay.yaml @@ -62,7 +62,8 @@ meta: sessions: # Plain text -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 101 ]]}} client-request: diff --git a/tests/gold_tests/pluginTest/txn_box/basic/tls-cert.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/tls-cert.replay.yaml index cd4deaedea9..bdbedf90e62 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/tls-cert.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/tls-cert.replay.yaml @@ -37,7 +37,10 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} , { name: "tls", sni: "alpha.ex" } ] +- protocol: + stack: https + tls: + sni: "alpha.ex" transactions: - all: { headers: { fields: [[ uuid, 101 ]]}} client-request: @@ -59,7 +62,8 @@ sessions: fields: - [ "target-cert-subject", { value: "server_cn", as: equal } ] -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # Verify the outbound client cert is there with the expected values. - all: { headers: { fields: [[ uuid, outbound-TLS ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/tls.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/tls.replay.yaml index 57a0bbb0d49..11f30bfb5a8 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/tls.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/tls.replay.yaml @@ -30,7 +30,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] # plain text sessions +- protocol: # plain text sessions + stack: http transactions: - all: { headers: { fields: [[ uuid, 101 ]]}} client-request: @@ -66,7 +67,8 @@ sessions: proxy-response: status: 200 -- protocol: [ { name: "ip", version : 4} , { name: "tls" }] # TLS sessions +- protocol: # TLS sessions + stack: https transactions: - all: { headers: { fields: [[ uuid, 1 ]] }} client-request: diff --git a/tests/gold_tests/pluginTest/txn_box/basic/tuple.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/tuple.replay.yaml index b6590f8387d..0e1e5454b67 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/tuple.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/tuple.replay.yaml @@ -37,7 +37,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] # plain text sessions +- protocol: # plain text sessions + stack: http transactions: # - all: { headers: { fields: [[ uuid, 1 ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/txn-error.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/txn-error.replay.yaml index de633ae429b..5b7f3ebfa7b 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/txn-error.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/txn-error.replay.yaml @@ -42,7 +42,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, "base-case" ]]}} @@ -60,7 +61,8 @@ sessions: status: 501 # Must be a different session because the internal error forces a connection close. -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, "bypass-case" ]]}} @@ -78,7 +80,8 @@ sessions: <<: *base-rsp status: 200 -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, "no-fixup" ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/txn_open_1.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/txn_open_1.replay.yaml index d19f2d518d7..4d56eff0d83 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/txn_open_1.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/txn_open_1.replay.yaml @@ -24,7 +24,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # - all: { headers: { fields: [[ uuid, 1 ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/txn_open_2.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/txn_open_2.replay.yaml index 433003f1502..e39da858b5f 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/txn_open_2.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/txn_open_2.replay.yaml @@ -33,7 +33,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # - all: { headers: { fields: [[ uuid, 1 ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/txn_open_3.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/txn_open_3.replay.yaml index e300c08d3dc..293d05b2bc6 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/txn_open_3.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/txn_open_3.replay.yaml @@ -30,7 +30,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # - all: { headers: { fields: [[ uuid, 1 ]]}} diff --git a/tests/gold_tests/pluginTest/txn_box/basic/with.replay.yaml b/tests/gold_tests/pluginTest/txn_box/basic/with.replay.yaml index 175aafdac0d..594148d1980 100644 --- a/tests/gold_tests/pluginTest/txn_box/basic/with.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/basic/with.replay.yaml @@ -61,7 +61,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # Alpha cases use "none-of" so if the field isn't present, no with case should match and it should diff --git a/tests/gold_tests/pluginTest/txn_box/ct_header/ct_header.replay.yaml b/tests/gold_tests/pluginTest/txn_box/ct_header/ct_header.replay.yaml index 273aca628ed..f29188f8791 100644 --- a/tests/gold_tests/pluginTest/txn_box/ct_header/ct_header.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/ct_header/ct_header.replay.yaml @@ -57,7 +57,8 @@ sessions: # # Test 1: For non-TLS connections, we should not add cross site fields. # -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 1 ]]}} @@ -90,7 +91,8 @@ sessions: # # Test 2: Since this is TLS, expect the cross site fields. # -- protocol: [ { name: tls } , { name: ip, version: 4 } ] +- protocol: + stack: https transactions: - all: { headers: { fields: [[ uuid, 2 ]]}} @@ -176,7 +178,8 @@ sessions: fields: - [ expect-ct, { value: "max-age=31536000, report-uri=\"http://cane.example.com/path/cane?src=examplecom-expect-ct-report-only\"", as: equal} ] -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # diff --git a/tests/gold_tests/pluginTest/txn_box/example/accept-encoding.replay.yaml b/tests/gold_tests/pluginTest/txn_box/example/accept-encoding.replay.yaml index 223e0761169..aefbcd8c383 100644 --- a/tests/gold_tests/pluginTest/txn_box/example/accept-encoding.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/example/accept-encoding.replay.yaml @@ -25,7 +25,8 @@ meta: - [ Content-Length, 234 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 1 ]]}} client-request: diff --git a/tests/gold_tests/pluginTest/txn_box/prod/cors-origin.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/cors-origin.replay.yaml index 96a0a645c27..c86c815877f 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/cors-origin.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/cors-origin.replay.yaml @@ -38,7 +38,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, alpha ]]}} @@ -67,8 +68,6 @@ sessions: headers: fields: - [ Host, api.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -83,8 +82,6 @@ sessions: fields: - [ Host, api.ex ] - [ Origin, "https://echo.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -107,4 +104,3 @@ sessions: headers: fields: - [ "CORS", { value: "https://delta.ex", as: equal }] - diff --git a/tests/gold_tests/pluginTest/txn_box/prod/cors-referrer.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/cors-referrer.replay.yaml index 3a580e2472d..9ca5f55fe8d 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/cors-referrer.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/cors-referrer.replay.yaml @@ -45,7 +45,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, alpha ]]}} @@ -74,8 +75,6 @@ sessions: headers: fields: - [ Host, api.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -90,8 +89,6 @@ sessions: fields: - [ Host, api.ex ] - [ Referrer, "http://echo.ex/ui/demo" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -114,4 +111,3 @@ sessions: headers: fields: - [ "CORS", { value: "delta.ex", as: equal }] - diff --git a/tests/gold_tests/pluginTest/txn_box/prod/ip-acl.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/ip-acl.replay.yaml index ab6820610c2..dbfc32f2055 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/ip-acl.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/ip-acl.replay.yaml @@ -43,7 +43,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 1 ]]}} @@ -84,8 +85,6 @@ sessions: fields: - [ Host, base.ex ] - [ addr, "192.168.2.3" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -122,4 +121,3 @@ sessions: <<: *base-rsp proxy-response: status: 200 - diff --git a/tests/gold_tests/pluginTest/txn_box/prod/mTLS-alpha.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/mTLS-alpha.replay.yaml index d8f9a02f647..3e86fc02802 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/mTLS-alpha.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/mTLS-alpha.replay.yaml @@ -3,9 +3,9 @@ meta: sessions: - protocol: - - name: tls - sni: "alpha" - + stack: https + tls: + sni: "alpha" transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/pluginTest/txn_box/prod/mTLS-bravo.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/mTLS-bravo.replay.yaml index 80c7d48cbcf..68eadbba17d 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/mTLS-bravo.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/mTLS-bravo.replay.yaml @@ -3,9 +3,9 @@ meta: sessions: - protocol: - - name: tls - sni: "bravo" - + stack: https + tls: + sni: "bravo" transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/pluginTest/txn_box/prod/query-delete.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/query-delete.replay.yaml index 31753eab806..1a5054697ae 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/query-delete.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/query-delete.replay.yaml @@ -50,7 +50,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: &txn-set # No query diff --git a/tests/gold_tests/pluginTest/txn_box/prod/query.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/query.replay.yaml index b1cc6b448b6..c5de31d811d 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/query.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/query.replay.yaml @@ -23,7 +23,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # No query -> no field. diff --git a/tests/gold_tests/pluginTest/txn_box/prod/stanley.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/stanley.replay.yaml index 3f3097272fc..492361bf638 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/stanley.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/stanley.replay.yaml @@ -38,7 +38,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, base-case ]]}} client-request: @@ -48,8 +49,6 @@ sessions: fields: - [ Host, "nowhere.com" ] - [ ycal-host, "calendar.yahoo.com" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -66,8 +65,6 @@ sessions: fields: - [ Host, "notepad.mail.yahoo.com" ] - [ ycal-host, "bop.yahoo.com" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -75,4 +72,3 @@ sessions: headers: fields: - [ Location, { value: "view=notepad", as: "contains" } ] - diff --git a/tests/gold_tests/pluginTest/txn_box/prod/vznith-1.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/vznith-1.replay.yaml index 0d08bed30c5..1a160a05289 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/vznith-1.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/vznith-1.replay.yaml @@ -35,7 +35,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # Base case - no path modification. diff --git a/tests/gold_tests/pluginTest/txn_box/prod/yts-3489.replay.yaml b/tests/gold_tests/pluginTest/txn_box/prod/yts-3489.replay.yaml index 82796adfc45..4bd8dfd6546 100644 --- a/tests/gold_tests/pluginTest/txn_box/prod/yts-3489.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/prod/yts-3489.replay.yaml @@ -72,7 +72,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 101 ]]}} client-request: @@ -81,8 +82,6 @@ sessions: headers: fields: - [ Host, base.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -98,8 +97,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -115,8 +112,6 @@ sessions: headers: fields: - [ Host, base.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -132,8 +127,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -149,8 +142,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -167,8 +158,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -203,8 +192,6 @@ sessions: headers: fields: - [ "Host", "base.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -221,8 +208,6 @@ sessions: headers: fields: - [ "Host", "alt.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -239,8 +224,6 @@ sessions: headers: fields: - [ "Host", "alt.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -257,8 +240,6 @@ sessions: headers: fields: - [ "Host", "join.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -275,8 +256,6 @@ sessions: headers: fields: - [ "Host", "join.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -293,8 +272,6 @@ sessions: headers: fields: - [ "Host", "concat.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -311,8 +288,6 @@ sessions: headers: fields: - [ "Host", "concat.ex" ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: diff --git a/tests/gold_tests/pluginTest/txn_box/ramp/multi-ramp.replay.yaml b/tests/gold_tests/pluginTest/txn_box/ramp/multi-ramp.replay.yaml index 3f05f3b8175..48869bb5c4c 100644 --- a/tests/gold_tests/pluginTest/txn_box/ramp/multi-ramp.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/ramp/multi-ramp.replay.yaml @@ -21,7 +21,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: tls } , { name: ip, version: 4 } ] +- protocol: + stack: https transactions: - client-request: <<: *base_request diff --git a/tests/gold_tests/pluginTest/txn_box/ramp/ramp.replay.yaml b/tests/gold_tests/pluginTest/txn_box/ramp/ramp.replay.yaml index 5e22948c927..a4f943d737a 100644 --- a/tests/gold_tests/pluginTest/txn_box/ramp/ramp.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/ramp/ramp.replay.yaml @@ -18,7 +18,8 @@ meta: url: "/1" sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 1 ]]}} client-request: diff --git a/tests/gold_tests/pluginTest/txn_box/remap/remap-base.replay.yaml b/tests/gold_tests/pluginTest/txn_box/remap/remap-base.replay.yaml index a130e339712..d8b340e6e15 100644 --- a/tests/gold_tests/pluginTest/txn_box/remap/remap-base.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/remap/remap-base.replay.yaml @@ -58,7 +58,8 @@ meta: - [ Content-Length, 96 ] sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: # - client-request: diff --git a/tests/gold_tests/pluginTest/txn_box/smoke/smoke-2.replay.yaml b/tests/gold_tests/pluginTest/txn_box/smoke/smoke-2.replay.yaml index 20b0d1df765..aed6a2dea67 100644 --- a/tests/gold_tests/pluginTest/txn_box/smoke/smoke-2.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/smoke/smoke-2.replay.yaml @@ -16,7 +16,8 @@ meta: method: "GET" sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - client-request: diff --git a/tests/gold_tests/pluginTest/txn_box/smoke/smoke.replay.yaml b/tests/gold_tests/pluginTest/txn_box/smoke/smoke.replay.yaml index 6631a2a88bb..5b801adb371 100644 --- a/tests/gold_tests/pluginTest/txn_box/smoke/smoke.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/smoke/smoke.replay.yaml @@ -31,7 +31,8 @@ meta: method: "GET" sessions: -- protocol: [ { name: ip, version : 4} ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 1 ]]}} client-request: diff --git a/tests/gold_tests/pluginTest/txn_box/static_file/static_file.replay.yaml b/tests/gold_tests/pluginTest/txn_box/static_file/static_file.replay.yaml index 434ab34bc02..89ba1bef7cc 100644 --- a/tests/gold_tests/pluginTest/txn_box/static_file/static_file.replay.yaml +++ b/tests/gold_tests/pluginTest/txn_box/static_file/static_file.replay.yaml @@ -141,7 +141,8 @@ meta: - [ Content-Length, 56 ] sessions: -- protocol: [ { name: ip, version : 4 } ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 1 ]]}} client-request: @@ -221,7 +222,8 @@ sessions: proxy-response: status: 200 -- protocol: [ { name: ip, version : 4 } ] +- protocol: + stack: http transactions: - all: { headers: { fields: [[ uuid, 4 ]]}} client-request: @@ -341,8 +343,6 @@ sessions: headers: fields: - [ Host, unmapped.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -356,8 +356,6 @@ sessions: headers: fields: - [ Host, unmapped.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -371,8 +369,6 @@ sessions: headers: fields: - [ Host, unmapped.ex ] - proxy-request: - <<: *base-req server-response: <<: *base-rsp proxy-response: @@ -386,8 +382,6 @@ sessions: headers: fields: - [ Host, base.ex ] - proxy-request: - <<: *base-req server-response: status: 404 reason: "Missing" diff --git a/tests/gold_tests/proxy_protocol/replay/proxy_protocol_in.replay.yaml b/tests/gold_tests/proxy_protocol/replay/proxy_protocol_in.replay.yaml index 9b9aaee9002..b8b85a2c4a8 100644 --- a/tests/gold_tests/proxy_protocol/replay/proxy_protocol_in.replay.yaml +++ b/tests/gold_tests/proxy_protocol/replay/proxy_protocol_in.replay.yaml @@ -24,13 +24,8 @@ meta: sessions: # Test 1: Incoming PROXY Protocol v1 on TCP port - protocol: - - name: http - version: 1 - - name: proxy-protocol - version: 1 - - name: tcp - - name: ip - + stack: http + proxy-protocol: 1 transactions: - client-request: method: GET @@ -57,14 +52,8 @@ sessions: # Test 2: Incoming PROXY Protocol v1 on SSL port - protocol: - - name: http - version: 1 - - name: tls - - name: proxy-protocol - version: 1 - - name: tcp - - name: ip - + stack: https + proxy-protocol: 1 transactions: - client-request: method: GET @@ -92,13 +81,8 @@ sessions: # Test 3: Incoming PROXY Protocol v2 on TCP port - protocol: - - name: http - version: 1 - - name: proxy-protocol - version: 2 - - name: tcp - - name: ip - + stack: http + proxy-protocol: 2 transactions: - client-request: method: GET @@ -125,14 +109,8 @@ sessions: # Test 4: Incoming PROXY Protocol v2 on SSL port - protocol: - - name: http - version: 1 - - name: tls - - name: proxy-protocol - version: 2 - - name: tcp - - name: ip - + stack: https + proxy-protocol: 2 transactions: - client-request: method: GET @@ -160,15 +138,11 @@ sessions: # Test 3: Incoming PROXY Protocol v1 on TCP port, with arbitrary source and # destination address in PROXY message - protocol: - - name: http - version: 1 - - name: proxy-protocol + stack: http + proxy-protocol: version: 1 src-addr: 198.51.100.1:51137 dst-addr: 198.51.100.2:80 - - name: tcp - - name: ip - transactions: - client-request: method: GET @@ -201,12 +175,8 @@ sessions: # Test 4: Verify ATS with :pp: server_ports designation can handle a # connection without Proxy Protocol. - protocol: - - name: http - version: 1 # not sending Proxy Protcol - - name: tcp - - name: ip - + stack: http transactions: - client-request: method: GET @@ -234,13 +204,8 @@ sessions: # Test 5: Verify ATS with :pp: server_ports designation can handle a TLS # connection without Proxy Protocol. - protocol: - - name: http - version: 1 - - name: tls # not sending Proxy Protcol - - name: tcp - - name: ip - + stack: https transactions: - client-request: method: GET diff --git a/tests/gold_tests/proxy_protocol/replay/proxy_protocol_out.replay.yaml b/tests/gold_tests/proxy_protocol/replay/proxy_protocol_out.replay.yaml index d124b068a8b..c72bc230add 100644 --- a/tests/gold_tests/proxy_protocol/replay/proxy_protocol_out.replay.yaml +++ b/tests/gold_tests/proxy_protocol/replay/proxy_protocol_out.replay.yaml @@ -23,13 +23,9 @@ meta: sessions: # Basic https transaction - protocol: - - name: http - version: 1 - - name: tls + stack: https + tls: sni: pp.origin.com - - name: tcp - - name: ip - transactions: - client-request: method: GET diff --git a/tests/gold_tests/redirect/replay/redirect_to_same_origin_on_cache.replay.yaml b/tests/gold_tests/redirect/replay/redirect_to_same_origin_on_cache.replay.yaml index bd8de8ce26b..0603121d6a7 100644 --- a/tests/gold_tests/redirect/replay/redirect_to_same_origin_on_cache.replay.yaml +++ b/tests/gold_tests/redirect/replay/redirect_to_same_origin_on_cache.replay.yaml @@ -19,11 +19,7 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tcp - - name: ip - + stack: http transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/remap/base.replay.yaml b/tests/gold_tests/remap/base.replay.yaml index b236481ffe4..2f4ba5da8ff 100644 --- a/tests/gold_tests/remap/base.replay.yaml +++ b/tests/gold_tests/remap/base.replay.yaml @@ -22,8 +22,7 @@ meta: sessions: - protocol: - - name: http - version: 1 + stack: http transactions: - client-request: diff --git a/tests/gold_tests/remap/deny_head_post.replay.yaml b/tests/gold_tests/remap/deny_head_post.replay.yaml index f814b534779..e149fa73eac 100644 --- a/tests/gold_tests/remap/deny_head_post.replay.yaml +++ b/tests/gold_tests/remap/deny_head_post.replay.yaml @@ -31,8 +31,7 @@ meta: sessions: - protocol: - - name: http - version: 1 + stack: http transactions: - client-request: diff --git a/tests/gold_tests/remap/remap_acl.test.py b/tests/gold_tests/remap/remap_acl.test.py index 902956c9139..0f5b0f5f23e 100644 --- a/tests/gold_tests/remap/remap_acl.test.py +++ b/tests/gold_tests/remap/remap_acl.test.py @@ -166,13 +166,13 @@ def _configure_traffic_server(self) -> int: # tr = Test.AddTestRun("Await config reload") p = tr.Processes.Default - p.Command = 'echo awaiting config reload' - p.Env = ts.Env Test_remap_acl._ts_reload_counter += 1 - count = Test_remap_acl._ts_reload_counter + 1 - await_config_reload = tr.Processes.Process(f'config_reload_succeeded_{count}', 'sleep 30') - await_config_reload.Ready = When.FileContains(ts.Disk.diags_log.Name, "remap.config finished loading", count) - p.StartBefore(await_config_reload) + count = 1 + Test_remap_acl._ts_reload_counter + condwait = os.path.join(Test.Variables.AtsTestToolsDir, 'condwait') + p.Command = (f"'{condwait}' 30 --contains '{ts.Disk.diags_log.Name}' " + f"'remap.config finished loading' {count}") + p.Env = ts.Env + tr.StillRunningAfter = ts else: record_config = { diff --git a/tests/gold_tests/remap/remap_acl_all_allowed.replay.yaml b/tests/gold_tests/remap/remap_acl_all_allowed.replay.yaml index 06501c9ed6f..952b348de94 100644 --- a/tests/gold_tests/remap/remap_acl_all_allowed.replay.yaml +++ b/tests/gold_tests/remap/remap_acl_all_allowed.replay.yaml @@ -30,8 +30,7 @@ meta: sessions: - protocol: - - name: http - version: 1 + stack: http transactions: - client-request: diff --git a/tests/gold_tests/remap/remap_acl_all_denied.replay.yaml b/tests/gold_tests/remap/remap_acl_all_denied.replay.yaml index 3e727f5bcb5..6c0f6186a1e 100644 --- a/tests/gold_tests/remap/remap_acl_all_denied.replay.yaml +++ b/tests/gold_tests/remap/remap_acl_all_denied.replay.yaml @@ -30,8 +30,7 @@ meta: sessions: - protocol: - - name: http - version: 1 + stack: http transactions: - client-request: diff --git a/tests/gold_tests/remap/remap_acl_get_allowed.replay.yaml b/tests/gold_tests/remap/remap_acl_get_allowed.replay.yaml index 648fdc137a2..087e5b3f66b 100644 --- a/tests/gold_tests/remap/remap_acl_get_allowed.replay.yaml +++ b/tests/gold_tests/remap/remap_acl_get_allowed.replay.yaml @@ -31,8 +31,7 @@ meta: sessions: - protocol: - - name: http - version: 1 + stack: http transactions: - client-request: diff --git a/tests/gold_tests/remap/remap_acl_get_post_allowed.replay.yaml b/tests/gold_tests/remap/remap_acl_get_post_allowed.replay.yaml index 26e6297c4c9..2dbcb636341 100644 --- a/tests/gold_tests/remap/remap_acl_get_post_allowed.replay.yaml +++ b/tests/gold_tests/remap/remap_acl_get_post_allowed.replay.yaml @@ -31,8 +31,7 @@ meta: sessions: - protocol: - - name: http - version: 1 + stack: http transactions: - client-request: diff --git a/tests/gold_tests/remap/remap_acl_get_post_allowed_pp.replay.yaml b/tests/gold_tests/remap/remap_acl_get_post_allowed_pp.replay.yaml index 1e8b9323b0f..91907bb6ed0 100644 --- a/tests/gold_tests/remap/remap_acl_get_post_allowed_pp.replay.yaml +++ b/tests/gold_tests/remap/remap_acl_get_post_allowed_pp.replay.yaml @@ -31,12 +31,11 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: proxy-protocol - version: 2 - src-addr: "1.2.3.4:1111" - dst-addr: "5.6.7.8:2222" + stack: http + proxy-protocol: + version: 2 + src-addr: "1.2.3.4:1111" + dst-addr: "5.6.7.8:2222" transactions: - client-request: diff --git a/tests/gold_tests/remap/remap_acl_get_post_denied.replay.yaml b/tests/gold_tests/remap/remap_acl_get_post_denied.replay.yaml index 9093a8bb363..cb2db9766d9 100644 --- a/tests/gold_tests/remap/remap_acl_get_post_denied.replay.yaml +++ b/tests/gold_tests/remap/remap_acl_get_post_denied.replay.yaml @@ -31,8 +31,7 @@ meta: sessions: - protocol: - - name: http - version: 1 + stack: http transactions: - client-request: diff --git a/tests/gold_tests/thread_config/check_threads.py b/tests/gold_tests/thread_config/check_threads.py index 61a5414d875..e0347b7dddc 100755 --- a/tests/gold_tests/thread_config/check_threads.py +++ b/tests/gold_tests/thread_config/check_threads.py @@ -19,92 +19,135 @@ import psutil import argparse +import os import sys - - -def count_threads(ts_path, etnet_threads, accept_threads, task_threads, aio_threads): - - for p in psutil.process_iter(['name', 'cwd', 'threads']): - - # Find the pid corresponding to the ats process we started in autest. - # It needs to match the process name and the binary path. - # If autest can expose the pid of the process this is not needed anymore. - if p.name() == '[TS_MAIN]' and p.cwd() == ts_path: - - etnet_check = set() - accept_check = set() - task_check = set() - aio_check = set() - - for t in p.threads(): - +import time + +COUNT_THREAD_WAIT_SECONDS = 10.0 +COUNT_THREAD_POLL_SECONDS = 0.1 + + +def _count_threads_once(ts_path, etnet_threads, accept_threads, task_threads, aio_threads): + """ + Return (code, message) for a single snapshot of ATS thread state. + """ + for p in psutil.process_iter(): + try: + # Find the pid corresponding to the ats process we started in autest. + # It needs to match the process name and the binary path. + # If autest can expose the pid of the process this is not needed anymore. + # Match by CWD or command line containing ts_path, since under + # ASAN the CWD may differ from the expected path. + process_name = p.name() + process_cwd = p.cwd() + process_exe = p.exe() + is_ts = process_name == '[TS_MAIN]' or process_name == 'traffic_server' or os.path.basename( + process_exe) == 'traffic_server' + match_by_cwd = process_cwd == ts_path + match_by_cmdline = any(ts_path in arg for arg in (p.cmdline() or [])) + if not is_ts or not (match_by_cwd or match_by_cmdline): + continue + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + continue + + etnet_check = set() + accept_check = set() + task_check = set() + aio_check = set() + + try: + threads = p.threads() + except psutil.AccessDenied: + return 12, 'Could not inspect ATS process threads.' + except (psutil.NoSuchProcess, psutil.ZombieProcess): + return 1, 'ATS process disappeared before thread inspection completed.' + + for t in threads: + try: # Get the name of the thread. thread_name = psutil.Process(t.id).name() - - if thread_name.startswith('[ET_NET'): - - # Get the id of this thread and check if it's in range. - etnet_id = int(thread_name.split(' ')[1][:-1]) - if etnet_id >= etnet_threads: - sys.stderr.write('Too many ET_NET threads created.\n') - return 2 - elif etnet_id in etnet_check: - sys.stderr.write('ET_NET thread with duplicate thread id created.\n') - return 3 - else: - etnet_check.add(etnet_id) - - elif thread_name.startswith('[ACCEPT'): - - # Get the id of this thread and check if it's in range. - accept_id = int(thread_name.split(' ')[1].split(':')[0]) - if accept_id >= accept_threads: - sys.stderr.write('Too many ACCEPT threads created.\n') - return 5 - else: - accept_check.add(accept_id) - - elif thread_name.startswith('[ET_TASK'): - - # Get the id of this thread and check if it's in range. - task_id = int(thread_name.split(' ')[1][:-1]) - if task_id >= task_threads: - sys.stderr.write('Too many ET_TASK threads created.\n') - return 7 - elif task_id in task_check: - sys.stderr.write('ET_TASK thread with duplicate thread id created.\n') - return 8 - else: - task_check.add(task_id) - - elif thread_name.startswith('[ET_AIO'): - - # Get the id of this thread and check if it's in range. - aio_id = int(thread_name.split(' ')[1].split(':')[0]) - if aio_id >= aio_threads: - sys.stderr.write('Too many ET_AIO threads created.\n') - return 10 - else: - aio_check.add(aio_id) - - # Check the size of the sets, must be equal to the expected size. - if len(etnet_check) != etnet_threads: - sys.stderr.write('Expected ET_NET threads: {0}, found: {1}.\n'.format(etnet_threads, len(etnet_check))) - return 4 - elif len(accept_check) != accept_threads: - sys.stderr.write('Expected ACCEPT threads: {0}, found: {1}.\n'.format(accept_threads, len(accept_check))) - return 6 - elif len(task_check) != task_threads: - sys.stderr.write('Expected ET_TASK threads: {0}, found: {1}.\n'.format(task_threads, len(task_check))) - return 9 - elif len(aio_check) != aio_threads: - sys.stderr.write('Expected ET_AIO threads: {0}, found: {1}.\n'.format(aio_threads, len(aio_check))) - return 11 - else: - return 0 - - # Return 1 if no pid is found to match the ats process. - return 1 + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + # A thread can disappear while we inspect; treat as transient. + continue + + if thread_name.startswith('[ET_NET'): + + # Get the id of this thread and check if it's in range. + etnet_id = int(thread_name.split(' ')[1][:-1]) + if etnet_id >= etnet_threads: + return 2, 'Too many ET_NET threads created.' + elif etnet_id in etnet_check: + return 3, 'ET_NET thread with duplicate thread id created.' + else: + etnet_check.add(etnet_id) + + elif thread_name.startswith('[ACCEPT'): + + # Get the id of this thread and check if it's in range. + accept_id = int(thread_name.split(' ')[1].split(':')[0]) + if accept_id >= accept_threads: + return 5, 'Too many ACCEPT threads created.' + else: + accept_check.add(accept_id) + + elif thread_name.startswith('[ET_TASK'): + + # Get the id of this thread and check if it's in range. + task_id = int(thread_name.split(' ')[1][:-1]) + if task_id >= task_threads: + return 7, 'Too many ET_TASK threads created.' + elif task_id in task_check: + return 8, 'ET_TASK thread with duplicate thread id created.' + else: + task_check.add(task_id) + + elif thread_name.startswith('[ET_AIO'): + + # Get the id of this thread and check if it's in range. + aio_id = int(thread_name.split(' ')[1].split(':')[0]) + if aio_id >= aio_threads: + return 10, 'Too many ET_AIO threads created.' + else: + aio_check.add(aio_id) + + # Check the size of the sets, must be equal to the expected size. + if len(etnet_check) != etnet_threads: + return 4, 'Expected ET_NET threads: {0}, found: {1}.'.format(etnet_threads, len(etnet_check)) + elif len(accept_check) != accept_threads: + return 6, 'Expected ACCEPT threads: {0}, found: {1}.'.format(accept_threads, len(accept_check)) + elif len(task_check) != task_threads: + return 9, 'Expected ET_TASK threads: {0}, found: {1}.'.format(task_threads, len(task_check)) + elif len(aio_check) != aio_threads: + return 11, 'Expected ET_AIO threads: {0}, found: {1}.'.format(aio_threads, len(aio_check)) + else: + return 0, '' + + return 1, 'Expected ATS process [TS_MAIN] with cwd {0}, but it was not found.'.format(ts_path) + + +def count_threads( + ts_path, + etnet_threads, + accept_threads, + task_threads, + aio_threads, + wait_seconds=COUNT_THREAD_WAIT_SECONDS, + poll_seconds=COUNT_THREAD_POLL_SECONDS): + deadline = time.monotonic() + wait_seconds + + # Retry on startup/transient states: + # 1 : ATS process not found yet + # 4/6/9/11: expected thread count not reached yet + retry_codes = {1, 4, 6, 9, 11} + + while True: + code, message = _count_threads_once(ts_path, etnet_threads, accept_threads, task_threads, aio_threads) + if code == 0: + return 0 + if code not in retry_codes or time.monotonic() >= deadline: + sys.stderr.write(message + '\n') + return code + time.sleep(poll_seconds) def main(): diff --git a/tests/gold_tests/thread_config/thread_config.test.py b/tests/gold_tests/thread_config/thread_config.test.py index 8adc59814bf..d583ec301fa 100644 --- a/tests/gold_tests/thread_config/thread_config.test.py +++ b/tests/gold_tests/thread_config/thread_config.test.py @@ -20,6 +20,7 @@ Test.Summary = 'Test that Trafficserver starts with different thread configurations.' Test.ContinueOnFail = True +Test.SkipUnless(Condition.IsPlatform("linux")) ts = Test.MakeATSProcess('ts-1_exec-0_accept-1_task-1_aio') ts.Disk.records_config.update( diff --git a/tests/gold_tests/timeout/replay/http2_no_activity_timeout.replay.yaml b/tests/gold_tests/timeout/replay/http2_no_activity_timeout.replay.yaml index 0cc88b140e4..c659322a50c 100644 --- a/tests/gold_tests/timeout/replay/http2_no_activity_timeout.replay.yaml +++ b/tests/gold_tests/timeout/replay/http2_no_activity_timeout.replay.yaml @@ -19,10 +19,9 @@ meta: sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: example.com + stack: http2 + tls: + sni: example.com transactions: - client-request: diff --git a/tests/gold_tests/timeout/replay/quic_no_activity_timeout.replay.yaml b/tests/gold_tests/timeout/replay/quic_no_activity_timeout.replay.yaml index 1937e6e6813..0b37ff19e33 100644 --- a/tests/gold_tests/timeout/replay/quic_no_activity_timeout.replay.yaml +++ b/tests/gold_tests/timeout/replay/quic_no_activity_timeout.replay.yaml @@ -19,10 +19,9 @@ meta: sessions: - protocol: - - name: http - version: 3 - - name: tls - sni: test_sni + stack: http3 + tls: + sni: test_sni transactions: - client-request: diff --git a/tests/gold_tests/timeout/slow_server.yaml b/tests/gold_tests/timeout/slow_server.yaml index 920b2fc1565..69b6ba405cb 100644 --- a/tests/gold_tests/timeout/slow_server.yaml +++ b/tests/gold_tests/timeout/slow_server.yaml @@ -85,9 +85,8 @@ sessions: # # An HTTPS GET request. # -- protocol: [ {name: tls}, - {name: tcp}, - {name: ip} ] +- protocol: + stack: https transactions: - client-request: @@ -111,9 +110,8 @@ sessions: # # An HTTPS POST request. # -- protocol: [ {name: tls}, - {name: tcp}, - {name: ip} ] +- protocol: + stack: https transactions: - client-request: @@ -138,10 +136,8 @@ sessions: # # An HTTP/2 GET request. # -- protocol: [ {name: http, version: 2}, - {name: tls}, - {name: tcp}, - {name: ip} ] +- protocol: + stack: http2 transactions: @@ -166,10 +162,8 @@ sessions: # # An HTTP/2 POST request. # -- protocol: [ {name: http, version: 2}, - {name: tls}, - {name: tcp}, - {name: ip} ] +- protocol: + stack: http2 transactions: diff --git a/tests/gold_tests/timeout/ssl-delay-server.cc b/tests/gold_tests/timeout/ssl-delay-server.cc index d993696229e..3f509f0e369 100644 --- a/tests/gold_tests/timeout/ssl-delay-server.cc +++ b/tests/gold_tests/timeout/ssl-delay-server.cc @@ -39,6 +39,7 @@ #include #include #include +#include char req_buf[10000]; char post_buf[1000]; @@ -156,6 +157,10 @@ main(int argc, char *argv[]) ttfb_delay = atoi(argv[3]); const char *pem_file = argv[4]; + // Ignore SIGPIPE which can be raised when a client disconnects during + // the handshake delay, killing the process unexpectedly. + signal(SIGPIPE, SIG_IGN); + fprintf(stderr, "Listen on %d connect delay=%d ttfb delay=%d\n", listen_port, connect_delay, ttfb_delay); int listenfd = socket(AF_INET, SOCK_STREAM, 0); @@ -198,9 +203,11 @@ main(int argc, char *argv[]) for (;;) { sfd = accept(listenfd, (struct sockaddr *)nullptr, nullptr); - if (sfd <= 0) { - // Failure - printf("Listen failure\n"); + if (sfd < 0) { + if (errno == EINTR) { + continue; + } + printf("Listen failure errno=%d\n", errno); exit(1); } diff --git a/tests/gold_tests/tls/replay/ip_allow.replay.yaml b/tests/gold_tests/tls/replay/ip_allow.replay.yaml index 6209152c745..2a7198ecfae 100644 --- a/tests/gold_tests/tls/replay/ip_allow.replay.yaml +++ b/tests/gold_tests/tls/replay/ip_allow.replay.yaml @@ -20,13 +20,9 @@ meta: sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: block.me.com - - name: tcp - - name: ip - + stack: http2 + tls: + sni: block.me.com transactions: # @@ -56,13 +52,9 @@ sessions: size: 3432 - protocol: - - name: http - version: 2 - - name: tls - sni: allow.me.com - - name: tcp - - name: ip - + stack: http2 + tls: + sni: allow.me.com transactions: # diff --git a/tests/gold_tests/tls/replay/ip_allow_proxy.replay.yaml b/tests/gold_tests/tls/replay/ip_allow_proxy.replay.yaml index 88219d05735..29349e26179 100644 --- a/tests/gold_tests/tls/replay/ip_allow_proxy.replay.yaml +++ b/tests/gold_tests/tls/replay/ip_allow_proxy.replay.yaml @@ -20,17 +20,13 @@ meta: sessions: - protocol: - - name: http - version: 2 - - name: tls - sni: pp.block.me.com - - name: proxy-protocol - version: 2 - src-addr: "1.2.3.4:1111" - dst-addr: "5.6.7.8:2222" - - name: tcp - - name: ip - + stack: http2 + tls: + sni: pp.block.me.com + proxy-protocol: + version: 2 + src-addr: "1.2.3.4:1111" + dst-addr: "5.6.7.8:2222" transactions: # @@ -60,17 +56,13 @@ sessions: size: 3432 - protocol: - - name: http - version: 2 - - name: tls - sni: pp.allow.me.com - - name: proxy-protocol - version: 2 - src-addr: "1.2.3.4:1111" - dst-addr: "5.6.7.8:2222" - - name: tcp - - name: ip - + stack: http2 + tls: + sni: pp.allow.me.com + proxy-protocol: + version: 2 + src-addr: "1.2.3.4:1111" + dst-addr: "5.6.7.8:2222" transactions: # diff --git a/tests/gold_tests/tls/replay/ip_allow_tunnel.replay.yaml b/tests/gold_tests/tls/replay/ip_allow_tunnel.replay.yaml index aefd0b636ea..835d3ff404e 100644 --- a/tests/gold_tests/tls/replay/ip_allow_tunnel.replay.yaml +++ b/tests/gold_tests/tls/replay/ip_allow_tunnel.replay.yaml @@ -20,11 +20,9 @@ meta: sessions: - protocol: - - name: tls - sni: block.me.com - - name: tcp - - name: ip - + stack: https + tls: + sni: block.me.com transactions: # @@ -72,11 +70,9 @@ sessions: - [ X-Response, { as: absent } ] - protocol: - - name: tls - sni: allow.me.com - - name: tcp - - name: ip - + stack: https + tls: + sni: allow.me.com transactions: # # This should also be configured for tunneling, but allowed per sni.yaml ip_allow. diff --git a/tests/gold_tests/tls/tls_client_alpn_configuration.replay.yaml b/tests/gold_tests/tls/tls_client_alpn_configuration.replay.yaml index ba9fbef1a73..d0a29422c0b 100644 --- a/tests/gold_tests/tls/tls_client_alpn_configuration.replay.yaml +++ b/tests/gold_tests/tls/tls_client_alpn_configuration.replay.yaml @@ -27,11 +27,9 @@ sessions: # HTTP/1.1 over TLS. - protocol: - - name: tls - sni: www.example.com - - name: tcp - - name: ip - + stack: https + tls: + sni: www.example.com transactions: # This test has more to do with ALPN configuration than the transactions. The @@ -68,13 +66,9 @@ sessions: # HTTP/2 over TLS. - protocol: - - name: http - version: 2 - - name: tls - sni: www.example.com - - name: tcp - - name: ip - + stack: http2 + tls: + sni: www.example.com transactions: # This test has more to do with ALPN configuration than the transactions. The diff --git a/tests/gold_tests/tls/tls_session_key_logging.replay.yaml b/tests/gold_tests/tls/tls_session_key_logging.replay.yaml index 9d37fac1e68..515936b73b9 100644 --- a/tests/gold_tests/tls/tls_session_key_logging.replay.yaml +++ b/tests/gold_tests/tls/tls_session_key_logging.replay.yaml @@ -19,12 +19,7 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tls - - name: tcp - - name: ip - + stack: https transactions: - client-request: method: "GET" diff --git a/tests/gold_tests/tls/tls_sni_with_port.replay.yaml b/tests/gold_tests/tls/tls_sni_with_port.replay.yaml index d114d07b345..51e4de95de4 100644 --- a/tests/gold_tests/tls/tls_sni_with_port.replay.yaml +++ b/tests/gold_tests/tls/tls_sni_with_port.replay.yaml @@ -19,13 +19,9 @@ meta: sessions: - protocol: - - name: http - version: 1 - - name: tls - sni: yay.example.com - - name: tcp - - name: ip - + stack: https + tls: + sni: yay.example.com transactions: - client-request: method: "GET" diff --git a/tests/tools/condwait b/tests/tools/condwait index 45e3eff7be5..2a627f98897 100755 --- a/tests/tools/condwait +++ b/tests/tools/condwait @@ -22,6 +22,8 @@ # condwait [ MAX-WAIT [ POST-WAIT ] ] CONDITION # # CONDITION is the ('test' command) condition to wait for. (It may contain white space.) +# For file existence tests (-f, -e, -d), glob patterns are supported (e.g., -f /path/crash-*.log). +# Use "--contains FILE PATTERN COUNT" to wait until FILE contains PATTERN in at least COUNT lines. # # MAX-WAIT is the maximum number of seconds to wait for the condition. If it is omitted, it defaults to 60. # @@ -33,8 +35,13 @@ WAIT=60 POST_WAIT=0 +usage() { + echo "usage: condwait [ MAX-WAIT [ POST-WAIT ] ] TEST-CONDITION" >&2 + echo " condwait [ MAX-WAIT [ POST-WAIT ] ] --contains FILE PATTERN COUNT" >&2 +} + if [[ "$1" = "" ]] ; then - echo "usage: condwait [ MAX-WAIT [ POST-WAIT ] ] TEST-CONDTION" >&2 + usage exit 1 fi @@ -43,7 +50,7 @@ if [[ "$X" = "$1" ]] ; then WAIT=$1 shift if [[ "$1" = "" ]] ; then - echo "usage: condwait [ MAX-WAIT [ POST-WAIT ] ] TEST-CONDTION" >&2 + usage exit 1 fi X=$( echo "$1" | sed 's/x/yy/g' | sed 's/[^0-9]/x/g' ) @@ -54,13 +61,64 @@ if [[ "$X" = "$1" ]] ; then fi if [[ "$1" = "" ]] ; then - echo "usage: condwait [ MAX-WAIT [ POST-WAIT ] ] TEST-CONDTION" >&2 + usage exit 1 fi +if [[ "$1" = "--contains" ]]; then + if [[ $# -ne 4 ]] || ! [[ "$4" =~ ^[0-9]+$ ]]; then + usage + exit 1 + fi +fi + +# Check simple file existence tests (-f, -e, -d) specially so literal paths with +# whitespace work while glob patterns remain supported. +check_condition() { + if [[ "$1" = "--contains" ]]; then + [[ -f "$2" ]] || return 1 + local matches + matches=$(awk -v pattern="$3" -v expected="$4" ' + BEGIN { + if (expected == 0) { + print 0 + found = 1 + exit + } + } + index($0, pattern) { + count++ + if (count >= expected) { + print count + found = 1 + exit + } + } + END { + if (!found) { + print count + 0 + } + } + ' "$2") + (( matches >= $4 )) + elif [[ "$1" = "-f" || "$1" = "-e" || "$1" = "-d" ]] && [[ $# -eq 2 ]]; then + if [[ "$2" = *[\*\?\[]* ]]; then + # Use compgen for file existence tests to support glob patterns. + local match + while IFS= read -r match; do + test "$1" "$match" && return 0 + done < <(compgen -G "$2") + return 1 + fi + test "$1" "$2" + else + test "$@" + fi +} + while (( WAIT > 0 )) do - if test $* + if check_condition "$@" then if (( POST_WAIT > 0 )) then