Merge pull request #256 from Orange-OpenSource/release/1.3.1

Release 1.3.1
This commit is contained in:
Fabrice Reix 2021-09-11 08:46:42 +02:00 committed by GitHub
commit 6a9943407b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 64 additions and 13 deletions

View File

@ -1,3 +1,13 @@
[1.3.1 (2021-09-11)](https://github.com/Orange-OpenSource/hurl/blob/master/CHANGELOG.md#1.3.1)
========================================================================================================================
Bugs Fixes:
* Accept hyphen in variable name [#258](https://github.com/Orange-OpenSource/hurl/issues/258)
* Support # in header value [#255](https://github.com/Orange-OpenSource/hurl/issues/255)
[1.3.0 (2021-09-03)](https://github.com/Orange-OpenSource/hurl/blob/master/CHANGELOG.md#1.3.0) [1.3.0 (2021-09-03)](https://github.com/Orange-OpenSource/hurl/blob/master/CHANGELOG.md#1.3.0)
======================================================================================================================== ========================================================================================================================

4
Cargo.lock generated
View File

@ -807,9 +807,9 @@ dependencies = [
[[package]] [[package]]
name = "sha2" name = "sha2"
version = "0.9.6" version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9204c41a1597a8c5af23c82d1c921cb01ec0a4c59e07a9c7306062829a3903f3" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa"
dependencies = [ dependencies = [
"block-buffer", "block-buffer",
"cfg-if 1.0.0", "cfg-if 1.0.0",

View File

@ -1 +1 @@
<div class="hurl-file"><div class="hurl-entry"><div class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><span class="line"><span class="string">User-Agent</span><span>:</span> <span class="string">hurl/1.0</span></span><span class="line"><span class="string">Host</span><span>:</span> <span class="string">localhost:8000</span> <span class="comment"># comment</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><span class="line"><span class="string">User-Agent</span><span>:</span> <span class="string">hurl/1.0</span></span><span class="line"><span class="string">Host</span><span>:</span> <span class="string">localhost:8000</span> <span class="comment"># comment</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers</span></span></div><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Raspberry</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Apple</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Banana</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Grape</span></span><span class="line"><span class="string">Color</span><span>:</span> <span class="string">Green</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-utf8</span></span></div><span class="line"><span class="string">Beverage</span><span>:</span> <span class="string">café</span> <span class="comment"># send the utf8 string - expected to be decoded as ascii in the server side</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-quote</span></span></div><span class="line"><span class="string">Header1</span><span>:</span> <span class="string">'</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/response-headers</span></span></div><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span><span class="line"><span class="string">Beverage</span><span>:</span> <span class="string">cafe</span> <span class="comment"># TBC send utf8</span></span></div></div></div> <div class="hurl-file"><div class="hurl-entry"><div class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><span class="line"><span class="string">User-Agent</span><span>:</span> <span class="string">hurl/1.0</span></span><span class="line"><span class="string">Host</span><span>:</span> <span class="string">localhost:8000</span> <span class="comment"># comment</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/default-headers</span></span></div><span class="line"><span class="string">User-Agent</span><span>:</span> <span class="string">hurl/1.0</span></span><span class="line"><span class="string">Host</span><span>:</span> <span class="string">localhost:8000</span> <span class="comment"># comment</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers</span></span></div><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Raspberry</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Apple</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Banana</span></span><span class="line"><span class="string">Fruit</span><span>:</span> <span class="string">Grape</span></span><span class="line"><span class="string">Color</span><span>:</span> <span class="string">Green</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-utf8</span></span></div><span class="line"><span class="string">Beverage</span><span>:</span> <span class="string">café</span> <span class="comment"># send the utf8 string - expected to be decoded as ascii in the server side</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-value</span></span></div><span class="line"><span class="string">Id</span><span>:</span> <span class="string">#123</span> <span class="comment"># send a hash in the value</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/custom-headers-quote</span></span></div><span class="line"><span class="string">Header1</span><span>:</span> <span class="string">'</span></span><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span></div></div><div class="hurl-entry"><div class="request"><span class="line"></span><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/response-headers</span></span></div><div class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="status">200</span></span><span class="line"><span class="string">Beverage</span><span>:</span> <span class="string">cafe</span> <span class="comment"># TBC send utf8</span></span></div></div></div>

View File

@ -24,6 +24,10 @@ GET http://localhost:8000/custom-headers-utf8
Beverage: café # send the utf8 string - expected to be decoded as ascii in the server side Beverage: café # send the utf8 string - expected to be decoded as ascii in the server side
HTTP/1.0 200 HTTP/1.0 200
GET http://localhost:8000/custom-headers-value
Id: \#123 # send a hash in the value
HTTP/1.0 200
GET http://localhost:8000/custom-headers-quote GET http://localhost:8000/custom-headers-quote
Header1: ' Header1: '
HTTP/1.0 200 HTTP/1.0 200

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/default-headers"},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/default-headers","headers":[{"name":"User-Agent","value":"hurl/1.0"},{"name":"Host","value":"localhost:8000"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/default-headers","headers":[{"name":"User-Agent","value":"hurl/1.0"},{"name":"Host","value":"localhost:8000"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers","headers":[{"name":"Fruit","value":"Raspberry"},{"name":"Fruit","value":"Apple"},{"name":"Fruit","value":"Banana"},{"name":"Fruit","value":"Grape"},{"name":"Color","value":"Green"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-utf8","headers":[{"name":"Beverage","value":"café"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-quote","headers":[{"name":"Header1","value":"'"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/response-headers"},"response":{"version":"HTTP/1.0","status":200,"headers":[{"name":"Beverage","value":"cafe"}]}}]} {"entries":[{"request":{"method":"GET","url":"http://localhost:8000/default-headers"},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/default-headers","headers":[{"name":"User-Agent","value":"hurl/1.0"},{"name":"Host","value":"localhost:8000"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/default-headers","headers":[{"name":"User-Agent","value":"hurl/1.0"},{"name":"Host","value":"localhost:8000"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers","headers":[{"name":"Fruit","value":"Raspberry"},{"name":"Fruit","value":"Apple"},{"name":"Fruit","value":"Banana"},{"name":"Fruit","value":"Grape"},{"name":"Color","value":"Green"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-utf8","headers":[{"name":"Beverage","value":"café"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-value","headers":[{"name":"Id","value":"#123"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/custom-headers-quote","headers":[{"name":"Header1","value":"'"}]},"response":{"version":"HTTP/1.0","status":200}},{"request":{"method":"GET","url":"http://localhost:8000/response-headers"},"response":{"version":"HTTP/1.0","status":200,"headers":[{"name":"Beverage","value":"cafe"}]}}]}

View File

@ -24,6 +24,10 @@ def custom_headers_utf8():
assert request.headers['Beverage'] == '\x63\x61\x66\xc3\xa9' assert request.headers['Beverage'] == '\x63\x61\x66\xc3\xa9'
return '' return ''
@app.route("/custom-headers-value")
def custom_headers_value():
assert request.headers['Id'] == '#123'
return ''
@app.route("/custom-headers-quote") @app.route("/custom-headers-quote")
def custom_headers_quotes(): def custom_headers_quotes():

View File

@ -1 +1 @@
curl 'http://localhost:8000/variables' -H 'Content-Type: application/json' --data $'{\n "name": "Jennifer",\n "age": 30,\n "height": 1.700000000000000000,\n "female": true,\n "id": "123",\n "a_null": null\n}' curl 'http://localhost:8000/variables' -H 'Name: Jennifer' -H 'Age: 30' -H 'Height: 1.700000000000000000' -H 'Female: true' -H 'Id: 123' -H 'A_Null: null' -H 'Content-Type: application/json' --data $'{\n "name": "Jennifer",\n "age": 30,\n "height": 1.700000000000000000,\n "female": true,\n "id": "123",\n "a_null": null\n}'

View File

@ -1 +1 @@
<div class="hurl-file"><div class="hurl-entry"><div class="request"><span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/variables</span></span></div><span class="line">{<span class="line"> "name": "{{name}}",</span><span class="line"> "age": {{age}},</span><span class="line"> "height": {{height}},</span><span class="line"> "female": {{female}},</span><span class="line"> "id": "{{id}}",</span><span class="line"> "a_null": {{a_null}}</span><span class="line">}</span></span><div class="response"><span class="line"></span><span class="line"><span class="version">HTTP/*</span> <span class="status">200</span></span><span class="line section-header">[Asserts]</span><span class="line"><span class="query-type">variable</span> <span class="string">"name"</span> <span class="predicate-type">equals</span> <span class="string">"Jennifer"</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"female"</span> <span class="predicate-type">equals</span> <span class="boolean">true</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"age"</span> <span class="predicate-type">equals</span> <span class="number">30</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"height"</span> <span class="predicate-type">equals</span> <span class="number">1.70</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"a_null"</span> <span class="predicate-type">equals</span> <span class="null">null</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"id"</span> <span class="predicate-type">equals</span> <span class="string">"123"</span></span></div></div></div> <div class="hurl-file"><div class="hurl-entry"><div class="request"><span class="line"><span class="method">POST</span> <span class="url">http://localhost:8000/variables</span></span></div><span class="line"><span class="string">Name</span><span>:</span> <span class="string">{{name}}</span></span><span class="line"><span class="string">Age</span><span>:</span> <span class="string">{{age}}</span></span><span class="line"><span class="string">Height</span><span>:</span> <span class="string">{{height}}</span></span><span class="line"><span class="string">Female</span><span>:</span> <span class="string">{{female}}</span></span><span class="line"><span class="string">Id</span><span>:</span> <span class="string">{{my-id}}</span></span><span class="line"><span class="string">A_Null</span><span>:</span> <span class="string">{{a_null}}</span></span><span class="line">{<span class="line"> "name": "{{name}}",</span><span class="line"> "age": {{age}},</span><span class="line"> "height": {{height}},</span><span class="line"> "female": {{female}},</span><span class="line"> "id": "{{my-id}}",</span><span class="line"> "a_null": {{a_null}}</span><span class="line">}</span></span><div class="response"><span class="line"></span><span class="line"><span class="version">HTTP/*</span> <span class="status">200</span></span><span class="line section-header">[Asserts]</span><span class="line"><span class="query-type">variable</span> <span class="string">"name"</span> <span class="predicate-type">equals</span> <span class="string">"Jennifer"</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"female"</span> <span class="predicate-type">equals</span> <span class="boolean">true</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"age"</span> <span class="predicate-type">equals</span> <span class="number">30</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"height"</span> <span class="predicate-type">equals</span> <span class="number">1.70</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"a_null"</span> <span class="predicate-type">equals</span> <span class="null">null</span></span><span class="line"><span class="query-type">variable</span> <span class="string">"my-id"</span> <span class="predicate-type">equals</span> <span class="string">"123"</span></span></div></div></div>

View File

@ -1,10 +1,16 @@
POST http://localhost:8000/variables POST http://localhost:8000/variables
Name: {{name}}
Age: {{age}}
Height: {{height}}
Female: {{female}}
Id: {{my-id}}
A_Null: {{a_null}}
{ {
"name": "{{name}}", "name": "{{name}}",
"age": {{age}}, "age": {{age}},
"height": {{height}}, "height": {{height}},
"female": {{female}}, "female": {{female}},
"id": "{{id}}", "id": "{{my-id}}",
"a_null": {{a_null}} "a_null": {{a_null}}
} }
@ -15,4 +21,4 @@ variable "female" equals true
variable "age" equals 30 variable "age" equals 30
variable "height" equals 1.70 variable "height" equals 1.70
variable "a_null" equals null variable "a_null" equals null
variable "id" equals "123" variable "my-id" equals "123"

View File

@ -1 +1 @@
{"entries":[{"request":{"method":"POST","url":"http://localhost:8000/variables","body":{"type":"json","value":{"name":"{{name}}","age":"{{age}}","height":"{{height}}","female":"{{female}}","id":"{{id}}","a_null":"{{a_null}}"}}},"response":{"status":200,"asserts":[{"query":{"type":"variable","name":"name"},"predicate":{"type":"equal","value":"Jennifer"}},{"query":{"type":"variable","name":"female"},"predicate":{"type":"equal","value":true}},{"query":{"type":"variable","name":"age"},"predicate":{"type":"equal","value":30}},{"query":{"type":"variable","name":"height"},"predicate":{"type":"equal","value":1.70}},{"query":{"type":"variable","name":"a_null"},"predicate":{"type":"equal","value":null}},{"query":{"type":"variable","name":"id"},"predicate":{"type":"equal","value":"123"}}]}}]} {"entries":[{"request":{"method":"POST","url":"http://localhost:8000/variables","headers":[{"name":"Name","value":"{{name}}"},{"name":"Age","value":"{{age}}"},{"name":"Height","value":"{{height}}"},{"name":"Female","value":"{{female}}"},{"name":"Id","value":"{{my-id}}"},{"name":"A_Null","value":"{{a_null}}"}],"body":{"type":"json","value":{"name":"{{name}}","age":"{{age}}","height":"{{height}}","female":"{{female}}","id":"{{my-id}}","a_null":"{{a_null}}"}}},"response":{"status":200,"asserts":[{"query":{"type":"variable","name":"name"},"predicate":{"type":"equal","value":"Jennifer"}},{"query":{"type":"variable","name":"female"},"predicate":{"type":"equal","value":true}},{"query":{"type":"variable","name":"age"},"predicate":{"type":"equal","value":30}},{"query":{"type":"variable","name":"height"},"predicate":{"type":"equal","value":1.70}},{"query":{"type":"variable","name":"a_null"},"predicate":{"type":"equal","value":null}},{"query":{"type":"variable","name":"my-id"},"predicate":{"type":"equal","value":"123"}}]}}]}

View File

@ -2,6 +2,6 @@
name=Jennifer name=Jennifer
age=30 age=30
height=1.70 height=1.70
id="123" my-id="123"
a_null=null a_null=null

View File

@ -6,6 +6,13 @@ import json
@app.route('/variables', methods=['POST']) @app.route('/variables', methods=['POST'])
def variables(): def variables():
assert request.headers['Content-Type'] == 'application/json' assert request.headers['Content-Type'] == 'application/json'
assert request.headers['Name'] == 'Jennifer'
assert request.headers['Age'] == '30'
assert request.headers['Female'] == 'true'
assert request.headers['Id'] == '123'
assert request.headers['Height'] == '1.700000000000000000'
assert request.headers['A_null'] == 'null'
s = request.data.decode("utf-8") s = request.data.decode("utf-8")
data = json.loads(s) data = json.loads(s)
assert data['name'] == 'Jennifer' assert data['name'] == 'Jennifer'

View File

@ -36,7 +36,7 @@ percent-encoding = "2.1.0"
regex = "1.5.4" regex = "1.5.4"
serde = "1.0.130" serde = "1.0.130"
serde_json = "1.0.67" serde_json = "1.0.67"
sha2 = "0.9.6" sha2 = "0.9.8"
url = "2.2.2" url = "2.2.2"

1
packages/hurl/README.md Symbolic link
View File

@ -0,0 +1 @@
../../README.md

View File

@ -0,0 +1,5 @@
hurl_core
===============
The hurl_core crate provides the common functionalities used by both hurl and hurlfmt.

View File

@ -58,7 +58,7 @@ pub fn parse2(reader: &mut Reader) -> ParseResult<'static, Expr> {
fn variable_name(reader: &mut Reader) -> ParseResult<'static, Variable> { fn variable_name(reader: &mut Reader) -> ParseResult<'static, Variable> {
let start = reader.state.clone(); let start = reader.state.clone();
let name = reader.read_while(|c| c.is_alphanumeric() || *c == '_'); let name = reader.read_while(|c| c.is_alphanumeric() || *c == '_' || *c == '-');
if name.is_empty() { if name.is_empty() {
return Err(Error { return Err(Error {
pos: start.pos, pos: start.pos,
@ -143,5 +143,14 @@ mod tests {
source_info: SourceInfo::init(1, 1, 1, 5), source_info: SourceInfo::init(1, 1, 1, 5),
} }
); );
let mut reader = Reader::init("my-id");
assert_eq!(
variable_name(&mut reader).unwrap(),
Variable {
name: String::from("my-id"),
source_info: SourceInfo::init(1, 1, 1, 6),
}
);
} }
} }

View File

@ -229,7 +229,7 @@ fn escape_char(reader: &mut Reader) -> ParseResult<'static, char> {
try_literal("\\", reader)?; try_literal("\\", reader)?;
let start = reader.state.clone(); let start = reader.state.clone();
match reader.read() { match reader.read() {
// Some('#') => Ok('#'), Some('#') => Ok('#'),
Some('"') => Ok('"'), Some('"') => Ok('"'),
Some('\\') => Ok('\\'), Some('\\') => Ok('\\'),
Some('/') => Ok('/'), Some('/') => Ok('/'),

View File

@ -0,0 +1,5 @@
hurlfmt
=====================================
The hurlfmt crate provides the `hurlfmt` binary.
It can format hurl files and to export them to JSON/HTML.