mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2025-01-08 20:54:28 +03:00
Add integration test on --very-verbose.
This commit is contained in:
parent
487ab2ef53
commit
cb9823bac2
5
integration/tests_ok/very_verbose.curl
Normal file
5
integration/tests_ok/very_verbose.curl
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
curl 'http://localhost:8000/very-verbose/redirect' -L
|
||||||
|
curl 'http://localhost:8000/very-verbose/encoding/latin1' -L
|
||||||
|
curl 'http://localhost:8000/very-verbose/compressed/brotli' -X POST -H 'Accept-Encoding: brotli' -L
|
||||||
|
curl 'http://localhost:8000/very-verbose/cat' -L
|
||||||
|
curl 'http://localhost:8000/very-verbose/done' -L
|
158
integration/tests_ok/very_verbose.err.pattern
Normal file
158
integration/tests_ok/very_verbose.err.pattern
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
* Options:
|
||||||
|
* fail fast: true
|
||||||
|
* insecure: false
|
||||||
|
* follow redirect: true
|
||||||
|
* max redirect: 50
|
||||||
|
* ------------------------------------------------------------------------------
|
||||||
|
* Executing entry 1
|
||||||
|
*
|
||||||
|
* Cookie store:
|
||||||
|
*
|
||||||
|
* Request:
|
||||||
|
* GET http://localhost:8000/very-verbose/redirect
|
||||||
|
*
|
||||||
|
* Request can be run with the following curl command:
|
||||||
|
* curl 'http://localhost:8000/very-verbose/redirect' -L
|
||||||
|
*
|
||||||
|
> GET /very-verbose/redirect HTTP/1.1
|
||||||
|
> Host: localhost:8000
|
||||||
|
> Accept: */*
|
||||||
|
> User-Agent: hurl/~~~-snapshot
|
||||||
|
>
|
||||||
|
< HTTP/1.0 301 MOVED PERMANENTLY
|
||||||
|
< Content-Type: text/html; charset=utf-8
|
||||||
|
< Content-Length: 205
|
||||||
|
< Location: http://localhost:8000/very-verbose/redirected
|
||||||
|
< Server: Flask Server
|
||||||
|
< Date: ~~~, ~~ ~~~ ~~~~ ~~:~~:~~ GMT
|
||||||
|
<
|
||||||
|
* Response:
|
||||||
|
* <html>
|
||||||
|
* <head>
|
||||||
|
* <meta content="text/html;charset=utf-8">
|
||||||
|
* <title>301 Moved</title>
|
||||||
|
* </head>
|
||||||
|
* <body>
|
||||||
|
* <h1>301 Moved</h1>
|
||||||
|
* The document has moved
|
||||||
|
* <a href="/very-verbose/redirected">here</a>.
|
||||||
|
* </body>
|
||||||
|
* </html>
|
||||||
|
> GET /very-verbose/redirected HTTP/1.1
|
||||||
|
> Host: localhost:8000
|
||||||
|
> Accept: */*
|
||||||
|
> User-Agent: hurl/~~~-snapshot
|
||||||
|
>
|
||||||
|
< HTTP/1.0 200 OK
|
||||||
|
< Content-Type: text/html; charset=utf-8
|
||||||
|
< Content-Length: 11
|
||||||
|
< Server: Flask Server
|
||||||
|
< Date: ~~~, ~~ ~~~ ~~~~ ~~:~~:~~ GMT
|
||||||
|
<
|
||||||
|
* Response:
|
||||||
|
* Redirected.
|
||||||
|
*
|
||||||
|
* ------------------------------------------------------------------------------
|
||||||
|
* Executing entry 2
|
||||||
|
*
|
||||||
|
* Cookie store:
|
||||||
|
*
|
||||||
|
* Request:
|
||||||
|
* GET http://localhost:8000/very-verbose/encoding/latin1
|
||||||
|
*
|
||||||
|
* Request can be run with the following curl command:
|
||||||
|
* curl 'http://localhost:8000/very-verbose/encoding/latin1' -L
|
||||||
|
*
|
||||||
|
> GET /very-verbose/encoding/latin1 HTTP/1.1
|
||||||
|
> Host: localhost:8000
|
||||||
|
> Accept: */*
|
||||||
|
> User-Agent: hurl/~~~-snapshot
|
||||||
|
>
|
||||||
|
< HTTP/1.0 200 OK
|
||||||
|
< Content-Type: text/html; charset=ISO-8859-1
|
||||||
|
< Content-Length: 4
|
||||||
|
< Server: Flask Server
|
||||||
|
< Date: ~~~, ~~ ~~~ ~~~~ ~~:~~:~~ GMT
|
||||||
|
<
|
||||||
|
* Response:
|
||||||
|
* café
|
||||||
|
*
|
||||||
|
* ------------------------------------------------------------------------------
|
||||||
|
* Executing entry 3
|
||||||
|
*
|
||||||
|
* Cookie store:
|
||||||
|
*
|
||||||
|
* Request:
|
||||||
|
* POST http://localhost:8000/very-verbose/compressed/brotli
|
||||||
|
* Accept-Encoding: brotli
|
||||||
|
*
|
||||||
|
* Request can be run with the following curl command:
|
||||||
|
* curl 'http://localhost:8000/very-verbose/compressed/brotli' -X POST -H 'Accept-Encoding: brotli' -L
|
||||||
|
*
|
||||||
|
> POST /very-verbose/compressed/brotli HTTP/1.1
|
||||||
|
> Host: localhost:8000
|
||||||
|
> Accept: */*
|
||||||
|
> Accept-Encoding: brotli
|
||||||
|
> User-Agent: hurl/1.7.0-snapshot
|
||||||
|
>
|
||||||
|
< HTTP/1.0 200 OK
|
||||||
|
< Content-Type: text/html; charset=utf-8
|
||||||
|
< Content-Length: 17
|
||||||
|
< Content-Encoding: br
|
||||||
|
< Server: Flask Server
|
||||||
|
< Date: ~~~, ~~ ~~~ ~~~~ ~~:~~:~~ GMT
|
||||||
|
<
|
||||||
|
* Response:
|
||||||
|
* Hello World!
|
||||||
|
*
|
||||||
|
* ------------------------------------------------------------------------------
|
||||||
|
* Executing entry 4
|
||||||
|
*
|
||||||
|
* Cookie store:
|
||||||
|
*
|
||||||
|
* Request:
|
||||||
|
* GET http://localhost:8000/very-verbose/cat
|
||||||
|
*
|
||||||
|
* Request can be run with the following curl command:
|
||||||
|
* curl 'http://localhost:8000/very-verbose/cat' -L
|
||||||
|
*
|
||||||
|
> GET /very-verbose/cat HTTP/1.1
|
||||||
|
> Host: localhost:8000
|
||||||
|
> Accept: */*
|
||||||
|
> User-Agent: hurl/~~~-snapshot
|
||||||
|
>
|
||||||
|
< HTTP/1.0 200 OK
|
||||||
|
< Content-Type: image/jpeg
|
||||||
|
< Content-Length: 25992
|
||||||
|
< Server: Flask Server
|
||||||
|
< Date: ~~~, ~~ ~~~ ~~~~ ~~:~~:~~ GMT
|
||||||
|
<
|
||||||
|
* Response:
|
||||||
|
* Bytes <f198388ba26c2c53005f24643826384f15ba905b8ca070a470b61885c6639f8bbfe63fcee5fb498a630249e499e4eddcc9ca793406c14d02c97107e09c7af57a...>
|
||||||
|
*
|
||||||
|
* ------------------------------------------------------------------------------
|
||||||
|
* Executing entry 5
|
||||||
|
*
|
||||||
|
* Cookie store:
|
||||||
|
*
|
||||||
|
* Request:
|
||||||
|
* GET http://localhost:8000/very-verbose/done
|
||||||
|
*
|
||||||
|
* Request can be run with the following curl command:
|
||||||
|
* curl 'http://localhost:8000/very-verbose/done' -L
|
||||||
|
*
|
||||||
|
> GET /very-verbose/done HTTP/1.1
|
||||||
|
> Host: localhost:8000
|
||||||
|
> x-foo: bar
|
||||||
|
> Accept: */*
|
||||||
|
> User-Agent: hurl/~~~-snapshot
|
||||||
|
>
|
||||||
|
< HTTP/1.0 200 OK
|
||||||
|
< Content-Type: text/html; charset=utf-8
|
||||||
|
< Content-Length: 4
|
||||||
|
< Server: Flask Server
|
||||||
|
< Date: ~~~, ~~ ~~~ ~~~~ ~~:~~:~~ GMT
|
||||||
|
<
|
||||||
|
* Response:
|
||||||
|
* Done
|
||||||
|
*
|
1
integration/tests_ok/very_verbose.exit
Normal file
1
integration/tests_ok/very_verbose.exit
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
17
integration/tests_ok/very_verbose.html
Normal file
17
integration/tests_ok/very_verbose.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/very-verbose/redirect</span></span>
|
||||||
|
</span><span class="response"><span class="line"><span class="version">HTTP/*</span> <span class="number">200</span></span>
|
||||||
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||||
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/very-verbose/encoding/latin1</span></span>
|
||||||
|
</span><span class="response"><span class="line"><span class="version">HTTP/*</span> <span class="number">200</span></span>
|
||||||
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||||
|
<span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/very-verbose/compressed/brotli</span></span>
|
||||||
|
<span class="line"><span class="string">Accept-Encoding</span><span>:</span> <span class="string">brotli</span></span>
|
||||||
|
</span><span class="response"><span class="line"><span class="version">HTTP/*</span> <span class="number">200</span></span>
|
||||||
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||||
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/very-verbose/cat</span></span>
|
||||||
|
</span><span class="response"><span class="line"><span class="version">HTTP/*</span> <span class="number">200</span></span>
|
||||||
|
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
|
||||||
|
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/very-verbose/done</span></span>
|
||||||
|
<span class="line"><span class="string">x-foo</span><span>:</span> <span class="string">bar</span></span>
|
||||||
|
</span><span class="response"><span class="line"><span class="version">HTTP/*</span> <span class="number">200</span></span>
|
||||||
|
</span></span></code></pre>
|
16
integration/tests_ok/very_verbose.hurl
Normal file
16
integration/tests_ok/very_verbose.hurl
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
GET http://localhost:8000/very-verbose/redirect
|
||||||
|
HTTP/* 200
|
||||||
|
|
||||||
|
GET http://localhost:8000/very-verbose/encoding/latin1
|
||||||
|
HTTP/* 200
|
||||||
|
|
||||||
|
POST http://localhost:8000/very-verbose/compressed/brotli
|
||||||
|
Accept-Encoding: brotli
|
||||||
|
HTTP/* 200
|
||||||
|
|
||||||
|
GET http://localhost:8000/very-verbose/cat
|
||||||
|
HTTP/* 200
|
||||||
|
|
||||||
|
GET http://localhost:8000/very-verbose/done
|
||||||
|
x-foo: bar
|
||||||
|
HTTP/* 200
|
1
integration/tests_ok/very_verbose.json
Normal file
1
integration/tests_ok/very_verbose.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/very-verbose/redirect"},"response":{"status":200}},{"request":{"method":"GET","url":"http://localhost:8000/very-verbose/encoding/latin1"},"response":{"status":200}},{"request":{"method":"POST","url":"http://localhost:8000/very-verbose/compressed/brotli","headers":[{"name":"Accept-Encoding","value":"brotli"}]},"response":{"status":200}},{"request":{"method":"GET","url":"http://localhost:8000/very-verbose/cat"},"response":{"status":200}},{"request":{"method":"GET","url":"http://localhost:8000/very-verbose/done","headers":[{"name":"x-foo","value":"bar"}]},"response":{"status":200}}]}
|
2
integration/tests_ok/very_verbose.options
Normal file
2
integration/tests_ok/very_verbose.options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
--very-verbose
|
||||||
|
--location
|
68
integration/tests_ok/very_verbose.py
Normal file
68
integration/tests_ok/very_verbose.py
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
from app import app
|
||||||
|
from flask import Response, make_response, request
|
||||||
|
|
||||||
|
|
||||||
|
def redirect(location, status=301):
|
||||||
|
body = f"""<html>
|
||||||
|
<head>
|
||||||
|
<meta content="text/html;charset=utf-8">
|
||||||
|
<title>301 Moved</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>{status} Moved</h1>
|
||||||
|
The document has moved
|
||||||
|
<a href="{location}">here</a>.
|
||||||
|
</body>
|
||||||
|
</html>"""
|
||||||
|
response = Response(response=body, status=status, mimetype="text/html")
|
||||||
|
response.headers["Location"] = location
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/very-verbose/redirect")
|
||||||
|
def very_verbose_redirect():
|
||||||
|
return redirect(location="/very-verbose/redirected")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/very-verbose/redirected")
|
||||||
|
def very_verbose_redirected():
|
||||||
|
return "Redirected."
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/very-verbose/encoding/latin1")
|
||||||
|
def very_verbose_encoding_latin1():
|
||||||
|
result = BytesIO()
|
||||||
|
result.write(b"\x63\x61\x66\xe9") # café in ISO-8859-1
|
||||||
|
data = result.getvalue()
|
||||||
|
resp = make_response(data)
|
||||||
|
resp.content_type = "text/html; charset=ISO-8859-1"
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/very-verbose/compressed/brotli", methods=["GET", "POST"])
|
||||||
|
def very_verbose_compressed_brotli():
|
||||||
|
assert "br" in request.headers["Accept-Encoding"]
|
||||||
|
result = BytesIO()
|
||||||
|
result.write(
|
||||||
|
b"\x21\x2c\x00\x04\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x21\x03"
|
||||||
|
)
|
||||||
|
data = result.getvalue()
|
||||||
|
resp = make_response(data)
|
||||||
|
resp.headers["Content-Encoding"] = "br"
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/very-verbose/cat")
|
||||||
|
def very_verbose_image():
|
||||||
|
with open("tests_ok/cat.jpg.br", "rb") as f:
|
||||||
|
data = f.read()
|
||||||
|
resp = make_response(data)
|
||||||
|
resp.headers["Content-Type"] = "image/jpeg"
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/very-verbose/done")
|
||||||
|
def very_verbose_done():
|
||||||
|
return "Done"
|
Loading…
Reference in New Issue
Block a user