Skip to content

Commit 62180fc

Browse files
serrislewSerris Lew
andauthored
Check valid ts in curl command (#12532)
Co-authored-by: Serris Lew <lserris@apple.com>
1 parent fa6c728 commit 62180fc

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

tests/gold_tests/autest-site/curl.test.ext

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Tools to help with TestRun commands
3030
#
3131

3232

33-
def spawn_curl_commands(self, cmdstr, count, ts, retcode=0, use_default=True):
33+
def spawn_curl_commands(self, cmdstr, count, ts=None, retcode=0, use_default=True):
3434
ret = []
3535

36-
if self.Variables.get("CurlUds", False):
36+
if self.Variables.get("CurlUds", False) and ts != None:
3737
cmdstr = f'curl --unix-socket {ts.Variables.uds_path} ' + cmdstr
3838
else:
3939
cmdstr = 'curl ' + cmdstr
@@ -51,7 +51,7 @@ def spawn_curl_commands(self, cmdstr, count, ts, retcode=0, use_default=True):
5151
def curl_command(self, cmd, ts=None, p=None):
5252
if p == None:
5353
p = self.Processes.Default
54-
if self.Variables.get("CurlUds", False):
54+
if self.Variables.get("CurlUds", False) and ts != None:
5555
# curl via UDS doesn't add this header when proxy flag enabled, need to explicitly set for test
5656
# unless pipe is found, indicating multiple commands
5757
if "--proxy" in cmd and "|" not in cmd:
@@ -64,7 +64,7 @@ def curl_command(self, cmd, ts=None, p=None):
6464

6565
def curl_multiple_commands(self, cmd, ts=None):
6666
p = self.Processes.Default
67-
if self.Variables.get("CurlUds", False):
67+
if self.Variables.get("CurlUds", False) and ts != None:
6868
p.Command = cmd.format(curl=f'curl --unix-socket {ts.Variables.uds_path}', curl_base='curl')
6969
else:
7070
p.Command = cmd.format(curl='curl', curl_base='curl')

tests/gold_tests/pluginTest/xdebug/x_probe_full_json/x_probe_full_json.test.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def _setupJqValidation(self) -> None:
9292
tr.MakeCurlCommand(
9393
f'-s -H"uuid: 1" -H "Host: example.com" -H "X-Debug: probe-full-json" '
9494
f'http://127.0.0.1:{self._ts.Variables.port}/test | '
95-
"jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'")
95+
"jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'",
96+
ts=self._ts)
9697
tr.Processes.Default.ReturnCode = 0
9798
tr.Processes.Default.Streams.stdout = "gold/jq_escaped.gold"
9899

@@ -101,7 +102,8 @@ def _setupJqValidation(self) -> None:
101102
tr.MakeCurlCommand(
102103
f'-s -H"uuid: 2" -H "Host: example.com" -H "X-Debug: probe-full-json" '
103104
f'http://127.0.0.1:{self._ts.Variables.port}/binary | '
104-
"jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'")
105+
"jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'",
106+
ts=self._ts)
105107
tr.Processes.Default.ReturnCode = 0
106108
tr.Processes.Default.Streams.stdout += "gold/jq_hex.gold"
107109

@@ -110,7 +112,8 @@ def _setupJqValidation(self) -> None:
110112
tr.MakeCurlCommand(
111113
f'-s -H"uuid: 1" -H "Host: example.com" -H "X-Debug: probe-full-json=hex" '
112114
f'http://127.0.0.1:{self._ts.Variables.port}/test | '
113-
"jq '.\"server-body\"'")
115+
"jq '.\"server-body\"'",
116+
ts=self._ts)
114117
tr.Processes.Default.ReturnCode = 0
115118
tr.Processes.Default.Streams.stdout += Testers.ContainsExpression(
116119
'3c21444f43545950452068746d6c3e', "Should contain hex-encoded HTML content (forced hex override)")
@@ -120,7 +123,8 @@ def _setupJqValidation(self) -> None:
120123
tr.MakeCurlCommand(
121124
f'-s -H"uuid: 1" -H "Host: example.com" -H "X-Debug: probe-full-json=escape" '
122125
f'http://127.0.0.1:{self._ts.Variables.port}/test | '
123-
"jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'")
126+
"jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'",
127+
ts=self._ts)
124128
tr.Processes.Default.ReturnCode = 0
125129
tr.Processes.Default.Streams.stdout += "gold/jq_escaped.gold"
126130

@@ -129,7 +133,8 @@ def _setupJqValidation(self) -> None:
129133
tr.MakeCurlCommand(
130134
f'-s -H"uuid: 1" -H "Host: example.com" -H "X-Debug: probe-full-json=nobody" '
131135
f'http://127.0.0.1:{self._ts.Variables.port}/test | '
132-
"jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'")
136+
"jq '.\"client-request\".\"uuid\",.\"server-body\",.\"proxy-response\".\"x-response\"'",
137+
ts=self._ts)
133138
tr.Processes.Default.ReturnCode = 0
134139
tr.Processes.Default.Streams.stdout += "gold/jq_nobody.gold"
135140

0 commit comments

Comments
 (0)