From 74cce8b994037494ca8148e0737acd3406392db5 Mon Sep 17 00:00:00 2001 From: jcamiel Date: Sun, 4 Dec 2022 18:27:03 +0100 Subject: [PATCH] Harden bom integration test. --- integration/tests_ok/bom.curl | 2 +- integration/tests_ok/bom.html | 16 +++++++++++++--- integration/tests_ok/bom.hurl | 12 +++++++++++- integration/tests_ok/bom.json | 2 +- integration/tests_ok/bom.py | 5 +++++ integration/tests_ok/bom.windows.curl | 2 ++ 6 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 integration/tests_ok/bom.windows.curl diff --git a/integration/tests_ok/bom.curl b/integration/tests_ok/bom.curl index 37b689875..539a4c6b7 100644 --- a/integration/tests_ok/bom.curl +++ b/integration/tests_ok/bom.curl @@ -1,2 +1,2 @@ curl 'http://localhost:8000/utf8_bom' - +curl 'http://localhost:8000/mirror' -H 'Content-Type:' --data '@tests_ok/bom.hurl' diff --git a/integration/tests_ok/bom.html b/integration/tests_ok/bom.html index d2fb130c1..50268efdb 100644 --- a/integration/tests_ok/bom.html +++ b/integration/tests_ok/bom.html @@ -1,6 +1,16 @@ -
GET http://localhost:8000/utf8_bom
+
# This Hurl file begins with a BOM marker.
+# You can check it with 'hexdump -c bom.hurl'
+GET http://localhost:8000/utf8_bom
 
 HTTP 200
 ```Hello World!```
-
-
+
+# We send the content of this file and get back the same +# bytes from /mirror to test the presence of the BOM marker. +POST http://localhost:8000/mirror +file,bom.hurl; + +HTTP 200 +[Asserts] +bytes startsWith hex,efbbbf; +
diff --git a/integration/tests_ok/bom.hurl b/integration/tests_ok/bom.hurl index 8b8382de6..632f1ce80 100644 --- a/integration/tests_ok/bom.hurl +++ b/integration/tests_ok/bom.hurl @@ -1,5 +1,15 @@ -GET http://localhost:8000/utf8_bom +# This Hurl file begins with a BOM marker. +# You can check it with 'hexdump -c bom.hurl' +GET http://localhost:8000/utf8_bom HTTP 200 ```Hello World!``` +# We send the content of this file and get back the same +# bytes from /mirror to test the presence of the BOM marker. +POST http://localhost:8000/mirror +file,bom.hurl; + +HTTP 200 +[Asserts] +bytes startsWith hex,efbbbf; diff --git a/integration/tests_ok/bom.json b/integration/tests_ok/bom.json index f24e6f786..8008ee1bb 100644 --- a/integration/tests_ok/bom.json +++ b/integration/tests_ok/bom.json @@ -1 +1 @@ -{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/utf8_bom"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}}]} +{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/utf8_bom"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}},{"request":{"method":"POST","url":"http://localhost:8000/mirror","body":{"type":"file","filename":"bom.hurl"}},"response":{"status":200,"asserts":[{"query":{"type":"bytes"},"predicate":{"type":"start-with","value":"77u/","encoding":"base64"}}]}}]} diff --git a/integration/tests_ok/bom.py b/integration/tests_ok/bom.py index 51ddb0e22..cd074d4ce 100644 --- a/integration/tests_ok/bom.py +++ b/integration/tests_ok/bom.py @@ -5,3 +5,8 @@ from flask import request @app.route("/utf8_bom") def utf8_bom(): return "Hello World!" + + +@app.route("/mirror", methods=["POST"]) +def mirror(): + return request.data diff --git a/integration/tests_ok/bom.windows.curl b/integration/tests_ok/bom.windows.curl new file mode 100644 index 000000000..e2204704f --- /dev/null +++ b/integration/tests_ok/bom.windows.curl @@ -0,0 +1,2 @@ +curl 'http://localhost:8000/utf8_bom' +curl 'http://localhost:8000/mirror' -H 'Content-Type:' --data '@tests_ok\bom.hurl'