From e63809343e79d09a8890dbc9ff73cb6cf1c99ea7 Mon Sep 17 00:00:00 2001 From: Serris Lew Date: Tue, 30 Sep 2025 11:32:15 -0700 Subject: [PATCH] Check valid ts in curl command --- tests/gold_tests/autest-site/curl.test.ext | 8 ++++---- .../x_probe_full_json/x_probe_full_json.test.py | 15 ++++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/gold_tests/autest-site/curl.test.ext b/tests/gold_tests/autest-site/curl.test.ext index 5d19bf1e839..f25d05cae36 100644 --- a/tests/gold_tests/autest-site/curl.test.ext +++ b/tests/gold_tests/autest-site/curl.test.ext @@ -30,10 +30,10 @@ Tools to help with TestRun commands # -def spawn_curl_commands(self, cmdstr, count, ts, retcode=0, use_default=True): +def spawn_curl_commands(self, cmdstr, count, ts=None, retcode=0, use_default=True): ret = [] - if self.Variables.get("CurlUds", False): + if self.Variables.get("CurlUds", False) and ts != None: cmdstr = f'curl --unix-socket {ts.Variables.uds_path} ' + cmdstr else: cmdstr = 'curl ' + cmdstr @@ -51,7 +51,7 @@ def spawn_curl_commands(self, cmdstr, count, ts, retcode=0, use_default=True): def curl_command(self, cmd, ts=None, p=None): if p == None: p = self.Processes.Default - if self.Variables.get("CurlUds", False): + if self.Variables.get("CurlUds", False) and ts != None: # curl via UDS doesn't add this header when proxy flag enabled, need to explicitly set for test # unless pipe is found, indicating multiple commands if "--proxy" in cmd and "|" not in cmd: @@ -64,7 +64,7 @@ def curl_command(self, cmd, ts=None, p=None): def curl_multiple_commands(self, cmd, ts=None): p = self.Processes.Default - if self.Variables.get("CurlUds", False): + if self.Variables.get("CurlUds", False) and ts != None: p.Command = cmd.format(curl=f'curl --unix-socket {ts.Variables.uds_path}', curl_base='curl') else: p.Command = cmd.format(curl='curl', curl_base='curl') diff --git a/tests/gold_tests/pluginTest/xdebug/x_probe_full_json/x_probe_full_json.test.py b/tests/gold_tests/pluginTest/xdebug/x_probe_full_json/x_probe_full_json.test.py index 5b69bf08a51..505f07b1a0e 100644 --- a/tests/gold_tests/pluginTest/xdebug/x_probe_full_json/x_probe_full_json.test.py +++ b/tests/gold_tests/pluginTest/xdebug/x_probe_full_json/x_probe_full_json.test.py @@ -92,7 +92,8 @@ def _setupJqValidation(self) -> None: tr.MakeCurlCommand( f'-s -H"uuid: 1" -H "Host: example.com" -H "X-Debug: probe-full-json" ' f'http://127.0.0.1:{self._ts.Variables.port}/test | ' - "jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'") + "jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'", + ts=self._ts) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout = "gold/jq_escaped.gold" @@ -101,7 +102,8 @@ def _setupJqValidation(self) -> None: tr.MakeCurlCommand( f'-s -H"uuid: 2" -H "Host: example.com" -H "X-Debug: probe-full-json" ' f'http://127.0.0.1:{self._ts.Variables.port}/binary | ' - "jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'") + "jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'", + ts=self._ts) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout += "gold/jq_hex.gold" @@ -110,7 +112,8 @@ def _setupJqValidation(self) -> None: tr.MakeCurlCommand( f'-s -H"uuid: 1" -H "Host: example.com" -H "X-Debug: probe-full-json=hex" ' f'http://127.0.0.1:{self._ts.Variables.port}/test | ' - "jq '.\"server-body\"'") + "jq '.\"server-body\"'", + ts=self._ts) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout += Testers.ContainsExpression( '3c21444f43545950452068746d6c3e', "Should contain hex-encoded HTML content (forced hex override)") @@ -120,7 +123,8 @@ def _setupJqValidation(self) -> None: tr.MakeCurlCommand( f'-s -H"uuid: 1" -H "Host: example.com" -H "X-Debug: probe-full-json=escape" ' f'http://127.0.0.1:{self._ts.Variables.port}/test | ' - "jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'") + "jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'", + ts=self._ts) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout += "gold/jq_escaped.gold" @@ -129,7 +133,8 @@ def _setupJqValidation(self) -> None: tr.MakeCurlCommand( f'-s -H"uuid: 1" -H "Host: example.com" -H "X-Debug: probe-full-json=nobody" ' f'http://127.0.0.1:{self._ts.Variables.port}/test | ' - "jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'") + "jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'", + ts=self._ts) tr.Processes.Default.ReturnCode = 0 tr.Processes.Default.Streams.stdout += "gold/jq_nobody.gold"