This is an automated email from the ASF dual-hosted git repository.
shinrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 959a1b8aac Fix chunked-encoding test to run with more basic netcat
(#10853)
959a1b8aac is described below
commit 959a1b8aac2eb0bfc2ce176fcbc0b3e89c84cc62
Author: Susan Hinrichs <[email protected]>
AuthorDate: Tue Nov 28 17:29:50 2023 -0600
Fix chunked-encoding test to run with more basic netcat (#10853)
---
tests/gold_tests/chunked_encoding/case1.sh | 19 -------------
tests/gold_tests/chunked_encoding/case2.sh | 19 -------------
tests/gold_tests/chunked_encoding/case3.sh | 19 -------------
tests/gold_tests/chunked_encoding/case4.sh | 20 -------------
.../chunked_encoding/chunked_encoding.test.py | 8 ++++--
.../chunked_encoding/chunked_encoding_h2.test.py | 33 ++++++++++++++--------
tests/gold_tests/chunked_encoding/delay-server.sh | 31 +++++++++++++++++---
tests/gold_tests/chunked_encoding/server2.sh | 27 ++++++++++++++++--
tests/gold_tests/chunked_encoding/server3.sh | 27 ++++++++++++++++--
tests/gold_tests/chunked_encoding/server4.sh | 29 +++++++++++++++++--
10 files changed, 131 insertions(+), 101 deletions(-)
diff --git a/tests/gold_tests/chunked_encoding/case1.sh
b/tests/gold_tests/chunked_encoding/case1.sh
deleted file mode 100644
index 4262283977..0000000000
--- a/tests/gold_tests/chunked_encoding/case1.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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.
-
-nc -l ${2} -o outserver1 -c "sh ./delay-server.sh" &
-sleep 1
-nghttp -vv https://127.0.0.1:${1}/delay-chunked-response
diff --git a/tests/gold_tests/chunked_encoding/case2.sh
b/tests/gold_tests/chunked_encoding/case2.sh
deleted file mode 100644
index be4d76f57c..0000000000
--- a/tests/gold_tests/chunked_encoding/case2.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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.
-
-nc -l ${2} -o outserver2 -c "sh ./server2.sh" &
-sleep 1
-curl --http2 -k https://127.0.0.1:${1}/post --verbose -H "Transfer-encoding:
chunked" -d "Knock knock"
diff --git a/tests/gold_tests/chunked_encoding/case3.sh
b/tests/gold_tests/chunked_encoding/case3.sh
deleted file mode 100644
index 4af2d92b9d..0000000000
--- a/tests/gold_tests/chunked_encoding/case3.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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.
-
-nc -l ${2} -o outserver3 -c "sh ./server3.sh" &
-sleep 1
-curl --http2 -k https://127.0.0.1:${1}/post-chunked --verbose -H
"Transfer-encoding: chunked" -d "Knock knock"
diff --git a/tests/gold_tests/chunked_encoding/case4.sh
b/tests/gold_tests/chunked_encoding/case4.sh
deleted file mode 100644
index b6637156a6..0000000000
--- a/tests/gold_tests/chunked_encoding/case4.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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.
-
-nc -l ${2} -o outserver4 -c "sh ./server4.sh" &
-sleep 1
-./smuggle-client 127.0.0.1 ${1}
-kill %1
diff --git a/tests/gold_tests/chunked_encoding/chunked_encoding.test.py
b/tests/gold_tests/chunked_encoding/chunked_encoding.test.py
index 6aff817da5..f28eb215f9 100644
--- a/tests/gold_tests/chunked_encoding/chunked_encoding.test.py
+++ b/tests/gold_tests/chunked_encoding/chunked_encoding.test.py
@@ -35,6 +35,9 @@ server = Test.MakeOriginServer("server")
server2 = Test.MakeOriginServer("server2", ssl=True)
server3 = Test.MakeOriginServer("server3")
+server4 = Test.Processes.Process("server4", "bash -c '" + Test.TestDirectory +
+ "/server4.sh {}
outserver4'".format(Test.Variables.upstream_port))
+
testName = ""
request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n",
"timestamp": "1469733493.993",
@@ -141,10 +144,9 @@ server4_out.Content = Testers.ExcludesExpression("sneaky",
"Extra body bytes sho
# HTTP/1.1 Try to smuggle another request to the origin
tr = Test.AddTestRun()
+tr.Processes.Default.StartBefore(server4)
tr.TimeOut = 5
-tr.Setup.Copy('server4.sh')
-tr.Setup.Copy('case4.sh')
-tr.Processes.Default.Command = 'sh ./case4.sh {0}
{1}'.format(ts.Variables.ssl_port, Test.Variables.upstream_port)
+tr.Processes.Default.Command = "./smuggle-client 127.0.0.1
{0}".format(ts.Variables.ssl_port)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All =
Testers.ExcludesExpression("content-length:", "Response should not include
content length")
# Transfer encoding to origin, but no content-length
diff --git a/tests/gold_tests/chunked_encoding/chunked_encoding_h2.test.py
b/tests/gold_tests/chunked_encoding/chunked_encoding_h2.test.py
index 8b9cff7869..511da2e6c1 100644
--- a/tests/gold_tests/chunked_encoding/chunked_encoding_h2.test.py
+++ b/tests/gold_tests/chunked_encoding/chunked_encoding_h2.test.py
@@ -27,6 +27,8 @@ Test.SkipUnless(
Test.ContinueOnFail = True
Test.GetTcpPort("upstream_port")
+Test.GetTcpPort("upstream_port2")
+Test.GetTcpPort("upstream_port3")
# Define default ATS
ts = Test.MakeATSProcess("ts", enable_tls=True)
@@ -34,8 +36,15 @@ ts = Test.MakeATSProcess("ts", enable_tls=True)
# add ssl materials like key, certificates for the server
ts.addDefaultSSLFiles()
+delay_server = Test.Processes.Process("delay-server", "bash -c '" +
Test.TestDirectory +
+ "/delay-server.sh {}
outserver1'".format(Test.Variables.upstream_port))
+server2 = Test.Processes.Process("server2", "bash -c '" + Test.TestDirectory +
+ "/server2.sh {}
outserver2'".format(Test.Variables.upstream_port2))
+server3 = Test.Processes.Process("server3", "bash -c '" + Test.TestDirectory +
+ "/server3.sh {}
outserver3'".format(Test.Variables.upstream_port3))
+
ts.Disk.records_config.update({
- 'proxy.config.diags.debug.enabled': 0,
+ 'proxy.config.diags.debug.enabled': 1,
'proxy.config.diags.debug.tags': 'http',
'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir),
'proxy.config.ssl.server.private_key.path':
'{0}'.format(ts.Variables.SSLDir),
@@ -46,7 +55,10 @@ ts.Disk.remap_config.AddLine(
'map /delay-chunked-response
http://127.0.0.1:{0}'.format(Test.Variables.upstream_port)
)
ts.Disk.remap_config.AddLine(
- 'map / http://127.0.0.1:{0}'.format(Test.Variables.upstream_port)
+ 'map /post-full http://127.0.0.1:{0}'.format(Test.Variables.upstream_port2)
+)
+ts.Disk.remap_config.AddLine(
+ 'map /post-chunked
http://127.0.0.1:{0}'.format(Test.Variables.upstream_port3)
)
ts.Disk.ssl_multicert_config.AddLine(
@@ -62,11 +74,10 @@ ts.Disk.ssl_multicert_config.AddLine(
# delay before final chunk size
server1_out = Test.Disk.File("outserver1")
tr = Test.AddTestRun()
-tr.Setup.Copy('delay-server.sh')
-tr.Setup.Copy('case1.sh')
-tr.Processes.Default.Command = 'sh ./case1.sh {0}
{1}'.format(ts.Variables.ssl_port, Test.Variables.upstream_port)
+tr.Processes.Default.Command = 'nghttp -vv
https://127.0.0.1:{}/delay-chunked-response'.format(ts.Variables.ssl_port)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.StartBefore(Test.Processes.ts)
+tr.Processes.Default.StartBefore(delay_server)
tr.Processes.Default.Streams.All = Testers.ExcludesExpression("RST_STREAM",
"Delayed chunk close should not cause reset")
tr.Processes.Default.Streams.All +=
Testers.ExcludesExpression("content-length", "Should return chunked")
tr.Processes.Default.Streams.All += Testers.ContainsExpression(":status: 200",
"Should get successful response")
@@ -77,9 +88,9 @@ tr.StillRunningAfter = ts
# HTTP2 POST: www.example.com Host, chunked body
server2_out = Test.Disk.File("outserver2")
tr = Test.AddTestRun()
-tr.Setup.Copy('server2.sh')
-tr.Setup.Copy('case2.sh')
-tr.Processes.Default.Command = 'sh ./case2.sh {0}
{1}'.format(ts.Variables.ssl_port, Test.Variables.upstream_port)
+tr.Processes.Default.StartBefore(server2)
+tr.Processes.Default.Command = 'curl --http2 -k https://127.0.0.1:{}/post-full
--verbose -H "Transfer-encoding: chunked" -d "Knock knock"'.format(
+ ts.Variables.ssl_port)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/2 200",
"Request should succeed")
tr.Processes.Default.Streams.All +=
Testers.ContainsExpression("content-length:", "Response should include content
length")
@@ -91,9 +102,9 @@ server2_out = Testers.ContainsExpression("Transfer-Encoding:
chunked", "Request
# HTTP2 POST: chunked post body and chunked response
server3_out = Test.Disk.File("outserver3")
tr = Test.AddTestRun()
-tr.Setup.Copy('server3.sh')
-tr.Setup.Copy('case3.sh')
-tr.Processes.Default.Command = 'sh ./case3.sh {0}
{1}'.format(ts.Variables.ssl_port, Test.Variables.upstream_port)
+tr.Processes.Default.StartBefore(server3)
+tr.Processes.Default.Command = 'curl --http2 -k
https://127.0.0.1:{}/post-chunked --verbose -H "Transfer-encoding: chunked" -d
"Knock knock"'.format(
+ ts.Variables.ssl_port)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/2 200",
"Request should succeed")
tr.Processes.Default.Streams.All +=
Testers.ExcludesExpression("content-length:", "Response should not include
content length")
diff --git a/tests/gold_tests/chunked_encoding/delay-server.sh
b/tests/gold_tests/chunked_encoding/delay-server.sh
old mode 100644
new mode 100755
index 670c9f1e72..c4d4846ddc
--- a/tests/gold_tests/chunked_encoding/delay-server.sh
+++ b/tests/gold_tests/chunked_encoding/delay-server.sh
@@ -14,7 +14,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-printf "HTTP/1.1 200\r\nTransfer-encoding: chunked\r\n\r\n"
-printf "F\r\n123456789012345\r\n"
-sleep 1
-printf "0\r\n\r\n"
+# A very simple cleartext server for one HTTP transaction. Does no validation
of the Request message.
+# Sends a fixed response message
+
+response ()
+{
+ # Wait for end of Request message.
+ #
+ while (( 1 == 1 ))
+ do
+ if [[ -f $outfile ]] ; then
+ if tr '\r\n' '=!' < $outfile | grep '=!=!' > /dev/null
+ then
+ break;
+ fi
+ fi
+ sleep 1
+ done
+
+ # delay before finishing the chunk
+ printf "HTTP/1.1 200\r\nTransfer-encoding: chunked\r\n\r\n"
+ printf "F\r\n123456789012345\r\n"
+ sleep 1
+ printf "0\r\n\r\n"
+
+}
+outfile=$2
+response | nc -l $1 > "$outfile"
diff --git a/tests/gold_tests/chunked_encoding/server2.sh
b/tests/gold_tests/chunked_encoding/server2.sh
old mode 100644
new mode 100755
index 4e48d75dd7..2fd88f60da
--- a/tests/gold_tests/chunked_encoding/server2.sh
+++ b/tests/gold_tests/chunked_encoding/server2.sh
@@ -14,5 +14,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-printf "HTTP/1.1 200\r\nContent-length: 15\r\n\r\n"
-printf "123456789012345"
+# A very simple cleartext server for one HTTP transaction. Does no validation
of the Request message.
+# Sends a fixed response message
+
+
+response ()
+{
+ # Wait for end of Request message.
+ #
+ while (( 1 == 1 ))
+ do
+ if [[ -f $outfile ]] ; then
+ if tr '\r\n' '=!' < $outfile | grep '=!=!' > /dev/null
+ then
+ break;
+ fi
+ fi
+ sleep 1
+ done
+
+ printf "HTTP/1.1 200\r\nContent-length: 15\r\n\r\n"
+ printf "123456789012345"
+
+}
+outfile=$2
+response | nc -l $1 > "$outfile"
diff --git a/tests/gold_tests/chunked_encoding/server3.sh
b/tests/gold_tests/chunked_encoding/server3.sh
old mode 100644
new mode 100755
index bf73609cc0..e08087faef
--- a/tests/gold_tests/chunked_encoding/server3.sh
+++ b/tests/gold_tests/chunked_encoding/server3.sh
@@ -14,5 +14,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-printf "HTTP/1.1 200\r\nTransfer-encoding: chunked\r\n\r\n"
-printf "F\r\n123456789012345\r\n0\r\n\r\n"
+# A very simple cleartext server for one HTTP transaction. Does no validation
of the Request message.
+# Sends a fixed response message
+
+
+response ()
+{
+ # Wait for end of Request message.
+ #
+ while (( 1 == 1 ))
+ do
+ if [[ -f $outfile ]] ; then
+ if tr '\r\n' '=!' < $outfile | grep '=!=!' > /dev/null
+ then
+ break;
+ fi
+ fi
+ sleep 1
+ done
+
+ printf "HTTP/1.1 200\r\nTransfer-encoding: chunked\r\n\r\n"
+ printf "F\r\n123456789012345\r\n0\r\n\r\n"
+
+}
+outfile=$2
+response | nc -l $1 > "$outfile"
diff --git a/tests/gold_tests/chunked_encoding/server4.sh
b/tests/gold_tests/chunked_encoding/server4.sh
old mode 100644
new mode 100755
index bf73609cc0..774d75e133
--- a/tests/gold_tests/chunked_encoding/server4.sh
+++ b/tests/gold_tests/chunked_encoding/server4.sh
@@ -14,5 +14,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-printf "HTTP/1.1 200\r\nTransfer-encoding: chunked\r\n\r\n"
-printf "F\r\n123456789012345\r\n0\r\n\r\n"
+# A very simple cleartext server for one HTTP transaction. Does no validation
of the Request message.
+# Sends a fixed response message
+
+response ()
+{
+ # Wait for end of Request message.
+ #
+ while (( 1 == 1 ))
+ do
+ if [[ -f $outfile ]] ; then
+ if tr '\r\n' '=!' < $outfile | grep '=!=!' > /dev/null
+ then
+ break;
+ fi
+ fi
+ sleep 1
+ done
+
+ # Send back an empty chunk
+
+ printf "HTTP/1.1 200\r\nTransfer-encoding: chunked\r\n\r\n"
+ printf "F\r\n123456789012345\r\n0\r\n\r\n"
+
+}
+
+outfile=$2
+response | nc -l $1 > $outfile