From 3853156b0dd28abeb6b7b1674443574d1f886553 Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Fri, 10 Sep 2021 07:56:45 +0200 Subject: [PATCH 1/6] Update version to 1.3.1 --- Cargo.lock | 6 +++--- packages/hurl/Cargo.toml | 2 +- packages/hurl_core/Cargo.toml | 2 +- packages/hurlfmt/Cargo.toml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d9fd34b5..1cbc6a125 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -379,7 +379,7 @@ checksum = "21e4590e13640f19f249fe3e4eca5113bc4289f2497710378190e7f4bd96f45b" [[package]] name = "hurl" -version = "1.3.0" +version = "1.3.1" dependencies = [ "atty", "base64", @@ -408,7 +408,7 @@ dependencies = [ [[package]] name = "hurl_core" -version = "1.3.0" +version = "1.3.1" dependencies = [ "float-cmp", "regex", @@ -417,7 +417,7 @@ dependencies = [ [[package]] name = "hurlfmt" -version = "1.3.0" +version = "1.3.1" dependencies = [ "atty", "base64", diff --git a/packages/hurl/Cargo.toml b/packages/hurl/Cargo.toml index 5b3217b17..875df870a 100644 --- a/packages/hurl/Cargo.toml +++ b/packages/hurl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hurl" -version = "1.3.0" +version = "1.3.1" authors = ["Fabrice Reix "] edition = "2018" license = "Apache-2.0" diff --git a/packages/hurl_core/Cargo.toml b/packages/hurl_core/Cargo.toml index 30b25b31a..69c119c41 100644 --- a/packages/hurl_core/Cargo.toml +++ b/packages/hurl_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hurl_core" -version = "1.3.0" +version = "1.3.1" authors = ["Fabrice Reix "] edition = "2018" license = "Apache-2.0" diff --git a/packages/hurlfmt/Cargo.toml b/packages/hurlfmt/Cargo.toml index 1ecb0d2dc..d4992411b 100644 --- a/packages/hurlfmt/Cargo.toml +++ b/packages/hurlfmt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hurlfmt" -version = "1.3.0" +version = "1.3.1" authors = ["Fabrice Reix "] edition = "2018" license = "Apache-2.0" From 6da5b24d98e72e4d7bc0080dde4abd4f707b6e1a Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Fri, 10 Sep 2021 08:01:02 +0200 Subject: [PATCH 2/6] Update dependency - crate sha2 --- Cargo.lock | 4 ++-- packages/hurl/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1cbc6a125..a08002168 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -807,9 +807,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.6" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9204c41a1597a8c5af23c82d1c921cb01ec0a4c59e07a9c7306062829a3903f3" +checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", "cfg-if 1.0.0", diff --git a/packages/hurl/Cargo.toml b/packages/hurl/Cargo.toml index 875df870a..d6d5cdf95 100644 --- a/packages/hurl/Cargo.toml +++ b/packages/hurl/Cargo.toml @@ -36,7 +36,7 @@ percent-encoding = "2.1.0" regex = "1.5.4" serde = "1.0.130" serde_json = "1.0.67" -sha2 = "0.9.6" +sha2 = "0.9.8" url = "2.2.2" From 40ddfe520ea04fb3acbd234afa1c416a8db42dc3 Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Fri, 10 Sep 2021 08:17:59 +0200 Subject: [PATCH 3/6] add README in each crate --- packages/hurl/README.md | 1 + packages/hurl_core/README.md | 5 +++++ packages/hurlfmt/README.md | 5 +++++ 3 files changed, 11 insertions(+) create mode 120000 packages/hurl/README.md create mode 100644 packages/hurl_core/README.md create mode 100644 packages/hurlfmt/README.md diff --git a/packages/hurl/README.md b/packages/hurl/README.md new file mode 120000 index 000000000..fe8400541 --- /dev/null +++ b/packages/hurl/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/packages/hurl_core/README.md b/packages/hurl_core/README.md new file mode 100644 index 000000000..b449fd590 --- /dev/null +++ b/packages/hurl_core/README.md @@ -0,0 +1,5 @@ +hurl_core +=============== + +The hurl_core crate provides the common functionalities used by both hurl and hurlfmt. + diff --git a/packages/hurlfmt/README.md b/packages/hurlfmt/README.md new file mode 100644 index 000000000..7d18f5daf --- /dev/null +++ b/packages/hurlfmt/README.md @@ -0,0 +1,5 @@ +hurlfmt +===================================== + +The hurlfmt crate provides the `hurlfmt` binary. +It can format hurl files and to export them to JSON/HTML. From 187ca03698a45eb61503adc3e7d9b93ea966bbbd Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Fri, 10 Sep 2021 08:37:15 +0200 Subject: [PATCH 4/6] Escape Hash(#) in hurl string value --- integration/tests/headers.html | 2 +- integration/tests/headers.hurl | 4 ++++ integration/tests/headers.json | 2 +- integration/tests/headers.py | 4 ++++ packages/hurl_core/src/parser/string.rs | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/integration/tests/headers.html b/integration/tests/headers.html index 08e89946b..beea08c09 100644 --- a/integration/tests/headers.html +++ b/integration/tests/headers.html @@ -1 +1 @@ -
GET http://localhost:8000/default-headers
HTTP/1.0 200
GET http://localhost:8000/default-headers
User-Agent: hurl/1.0Host: localhost:8000 # comment
HTTP/1.0 200
GET http://localhost:8000/default-headers
User-Agent: hurl/1.0Host: localhost:8000 # comment
HTTP/1.0 200
GET http://localhost:8000/custom-headers
Fruit: RaspberryFruit: AppleFruit: BananaFruit: GrapeColor: Green
HTTP/1.0 200
GET http://localhost:8000/custom-headers-utf8
Beverage: café # send the utf8 string - expected to be decoded as ascii in the server side
HTTP/1.0 200
GET http://localhost:8000/custom-headers-quote
Header1: '
HTTP/1.0 200
GET http://localhost:8000/response-headers
HTTP/1.0 200Beverage: cafe # TBC send utf8
\ No newline at end of file +
GET http://localhost:8000/default-headers
HTTP/1.0 200
GET http://localhost:8000/default-headers
User-Agent: hurl/1.0Host: localhost:8000 # comment
HTTP/1.0 200
GET http://localhost:8000/default-headers
User-Agent: hurl/1.0Host: localhost:8000 # comment
HTTP/1.0 200
GET http://localhost:8000/custom-headers
Fruit: RaspberryFruit: AppleFruit: BananaFruit: GrapeColor: Green
HTTP/1.0 200
GET http://localhost:8000/custom-headers-utf8
Beverage: café # send the utf8 string - expected to be decoded as ascii in the server side
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
Header1: '
HTTP/1.0 200
GET http://localhost:8000/response-headers
HTTP/1.0 200Beverage: cafe # TBC send utf8
\ No newline at end of file diff --git a/integration/tests/headers.hurl b/integration/tests/headers.hurl index 9adfff045..92bda2f0d 100644 --- a/integration/tests/headers.hurl +++ b/integration/tests/headers.hurl @@ -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 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 Header1: ' HTTP/1.0 200 diff --git a/integration/tests/headers.json b/integration/tests/headers.json index da93a1794..0e830d573 100644 --- a/integration/tests/headers.json +++ b/integration/tests/headers.json @@ -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"}]}}]} \ No newline at end of file diff --git a/integration/tests/headers.py b/integration/tests/headers.py index 3d555eff6..04d1d3213 100644 --- a/integration/tests/headers.py +++ b/integration/tests/headers.py @@ -24,6 +24,10 @@ def custom_headers_utf8(): assert request.headers['Beverage'] == '\x63\x61\x66\xc3\xa9' return '' +@app.route("/custom-headers-value") +def custom_headers_value(): + assert request.headers['Id'] == '#123' + return '' @app.route("/custom-headers-quote") def custom_headers_quotes(): diff --git a/packages/hurl_core/src/parser/string.rs b/packages/hurl_core/src/parser/string.rs index ae4763342..51bb19ef2 100644 --- a/packages/hurl_core/src/parser/string.rs +++ b/packages/hurl_core/src/parser/string.rs @@ -229,7 +229,7 @@ fn escape_char(reader: &mut Reader) -> ParseResult<'static, char> { try_literal("\\", reader)?; let start = reader.state.clone(); match reader.read() { - // Some('#') => Ok('#'), + Some('#') => Ok('#'), Some('"') => Ok('"'), Some('\\') => Ok('\\'), Some('/') => Ok('/'), From bd540070e05f64bb81ab7edf171780727a7d2d89 Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Fri, 10 Sep 2021 17:35:23 +0200 Subject: [PATCH 5/6] Accept hyphen in variable name --- integration/tests/variables.curl | 2 +- integration/tests/variables.html | 2 +- integration/tests/variables.hurl | 10 ++++++++-- integration/tests/variables.json | 2 +- integration/tests/variables.properties | 2 +- integration/tests/variables.py | 7 +++++++ packages/hurl_core/src/parser/expr.rs | 11 ++++++++++- 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/integration/tests/variables.curl b/integration/tests/variables.curl index b9db3c482..4e151ffdf 100644 --- a/integration/tests/variables.curl +++ b/integration/tests/variables.curl @@ -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}' diff --git a/integration/tests/variables.html b/integration/tests/variables.html index a44bbdb51..0203398a8 100644 --- a/integration/tests/variables.html +++ b/integration/tests/variables.html @@ -1 +1 @@ -
POST http://localhost:8000/variables
{ "name": "{{name}}", "age": {{age}}, "height": {{height}}, "female": {{female}}, "id": "{{id}}", "a_null": {{a_null}}}
HTTP/* 200[Asserts]variable "name" equals "Jennifer"variable "female" equals truevariable "age" equals 30variable "height" equals 1.70variable "a_null" equals nullvariable "id" equals "123"
\ No newline at end of file +
POST http://localhost:8000/variables
Name: {{name}}Age: {{age}}Height: {{height}}Female: {{female}}Id: {{my-id}}A_Null: {{a_null}}{ "name": "{{name}}", "age": {{age}}, "height": {{height}}, "female": {{female}}, "id": "{{my-id}}", "a_null": {{a_null}}}
HTTP/* 200[Asserts]variable "name" equals "Jennifer"variable "female" equals truevariable "age" equals 30variable "height" equals 1.70variable "a_null" equals nullvariable "my-id" equals "123"
\ No newline at end of file diff --git a/integration/tests/variables.hurl b/integration/tests/variables.hurl index ac9dd9585..36606c946 100644 --- a/integration/tests/variables.hurl +++ b/integration/tests/variables.hurl @@ -1,10 +1,16 @@ POST http://localhost:8000/variables +Name: {{name}} +Age: {{age}} +Height: {{height}} +Female: {{female}} +Id: {{my-id}} +A_Null: {{a_null}} { "name": "{{name}}", "age": {{age}}, "height": {{height}}, "female": {{female}}, - "id": "{{id}}", + "id": "{{my-id}}", "a_null": {{a_null}} } @@ -15,4 +21,4 @@ variable "female" equals true variable "age" equals 30 variable "height" equals 1.70 variable "a_null" equals null -variable "id" equals "123" +variable "my-id" equals "123" diff --git a/integration/tests/variables.json b/integration/tests/variables.json index ce35ac529..ab95acac6 100644 --- a/integration/tests/variables.json +++ b/integration/tests/variables.json @@ -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"}}]}}]} \ No newline at end of file +{"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"}}]}}]} \ No newline at end of file diff --git a/integration/tests/variables.properties b/integration/tests/variables.properties index 0cdfc6885..9a8c6ef8f 100644 --- a/integration/tests/variables.properties +++ b/integration/tests/variables.properties @@ -2,6 +2,6 @@ name=Jennifer age=30 height=1.70 -id="123" +my-id="123" a_null=null diff --git a/integration/tests/variables.py b/integration/tests/variables.py index 366da750b..d796a07d9 100644 --- a/integration/tests/variables.py +++ b/integration/tests/variables.py @@ -6,6 +6,13 @@ import json @app.route('/variables', methods=['POST']) def variables(): 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") data = json.loads(s) assert data['name'] == 'Jennifer' diff --git a/packages/hurl_core/src/parser/expr.rs b/packages/hurl_core/src/parser/expr.rs index a30c440c5..b23d46cf8 100644 --- a/packages/hurl_core/src/parser/expr.rs +++ b/packages/hurl_core/src/parser/expr.rs @@ -58,7 +58,7 @@ pub fn parse2(reader: &mut Reader) -> ParseResult<'static, Expr> { fn variable_name(reader: &mut Reader) -> ParseResult<'static, Variable> { 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() { return Err(Error { pos: start.pos, @@ -143,5 +143,14 @@ mod tests { 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), + } + ); } } From 7aca732ae8794149390be29f4915586d5d958d27 Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Fri, 10 Sep 2021 23:05:41 +0200 Subject: [PATCH 6/6] Update CHANGELOG --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46112a341..5ae4f14e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) ========================================================================================================================