mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-23 00:44:55 +03:00
Combine InvalidUrl RunnerError
This commit is contained in:
parent
d72d3ebb12
commit
01ce239f54
@ -2,6 +2,6 @@ error: Invalid URL
|
||||
--> tests_failed/invalid_url_1.hurl:3:5
|
||||
|
|
||||
3 | GET {{host}}
|
||||
| ^^^^^^^^ URL <localhost:8000> must start with http:// or https://
|
||||
| ^^^^^^^^ invalid URL <localhost:8000> (Missing protocol http or https)
|
||||
|
|
||||
|
||||
|
@ -139,114 +139,121 @@ error: Invalid regex
|
||||
| ^^^^ regex expression is not valid
|
||||
|
|
||||
|
||||
error: Invalid URL
|
||||
--> tests_failed/runner_errors.hurl:94:5
|
||||
|
|
||||
94 | GET {{url}}
|
||||
| ^^^^^^^ invalid URL <localhost:8000/runner_errors> (Missing protocol http or https)
|
||||
|
|
||||
|
||||
error: No query result
|
||||
--> tests_failed/runner_errors.hurl:103:8
|
||||
--> tests_failed/runner_errors.hurl:102:8
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors
|
||||
| ...
|
||||
103 | count: header "count"
|
||||
102 | count: header "count"
|
||||
| ^^^^^^^^^^^^^^ The query didn't return any result
|
||||
|
|
||||
|
||||
error: Header not found
|
||||
--> tests_failed/runner_errors.hurl:108:1
|
||||
--> tests_failed/runner_errors.hurl:107:1
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors
|
||||
| ...
|
||||
108 | count: 10
|
||||
107 | count: 10
|
||||
| ^^^^^ this header has not been found in the response
|
||||
|
|
||||
|
||||
error: Invalid JSON
|
||||
--> tests_failed/runner_errors.hurl:114:1
|
||||
--> tests_failed/runner_errors.hurl:113:1
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors
|
||||
| ...
|
||||
114 | jsonpath "$.count" == 10
|
||||
113 | jsonpath "$.count" == 10
|
||||
| ^^^^^^^^^^^^^^^^^^ the HTTP response is not a valid JSON
|
||||
|
|
||||
|
||||
error: Invalid JSONPath
|
||||
--> tests_failed/runner_errors.hurl:120:10
|
||||
--> tests_failed/runner_errors.hurl:119:10
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors
|
||||
| ...
|
||||
120 | jsonpath "xxx" == 10
|
||||
119 | jsonpath "xxx" == 10
|
||||
| ^^^^^ the JSONPath expression 'xxx' is not valid
|
||||
|
|
||||
|
||||
error: Invalid XML
|
||||
--> tests_failed/runner_errors.hurl:126:1
|
||||
--> tests_failed/runner_errors.hurl:125:1
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors/invalid-xml
|
||||
| ...
|
||||
126 | xpath "//a" == 10
|
||||
125 | xpath "//a" == 10
|
||||
| ^^^^^^^^^^^ the HTTP response is not a valid XML
|
||||
|
|
||||
|
||||
error: Invalid XPath expression
|
||||
--> tests_failed/runner_errors.hurl:132:7
|
||||
--> tests_failed/runner_errors.hurl:131:7
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors
|
||||
| ...
|
||||
132 | xpath "//" == 10
|
||||
131 | xpath "//" == 10
|
||||
| ^^^^ the XPath expression is not valid
|
||||
|
|
||||
|
||||
error: Invalid variable type
|
||||
--> tests_failed/runner_errors.hurl:138:12
|
||||
--> tests_failed/runner_errors.hurl:137:12
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors
|
||||
| ...
|
||||
138 | verbose: {{verbose}}
|
||||
137 | verbose: {{verbose}}
|
||||
| ^^^^^^^ expecting boolean, actual value is <1>
|
||||
|
|
||||
|
||||
error: Undefined variable
|
||||
--> tests_failed/runner_errors.hurl:143:10
|
||||
--> tests_failed/runner_errors.hurl:142:10
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors
|
||||
| ...
|
||||
143 | param: {{value}}
|
||||
142 | param: {{value}}
|
||||
| ^^^^^ you must set the variable value
|
||||
|
|
||||
|
||||
error: HTTP connection
|
||||
--> tests_failed/runner_errors.hurl:146:5
|
||||
--> tests_failed/runner_errors.hurl:145:5
|
||||
|
|
||||
146 | GET http://localhost:8000/runner_errors/redirect/2
|
||||
145 | GET http://localhost:8000/runner_errors/redirect/2
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ too many redirect
|
||||
|
|
||||
|
||||
error: Unauthorized file access
|
||||
--> tests_failed/runner_errors.hurl:153:6
|
||||
--> tests_failed/runner_errors.hurl:152:6
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors
|
||||
153 | file,/root/file;
|
||||
152 | file,/root/file;
|
||||
| ^^^^^^^^^^ unauthorized access to file /root/file, check --file-root option
|
||||
|
|
||||
|
||||
error: Unrenderable variable
|
||||
--> tests_failed/runner_errors.hurl:161:4
|
||||
--> tests_failed/runner_errors.hurl:160:4
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors
|
||||
161 | `{{list}}`
|
||||
160 | `{{list}}`
|
||||
| ^^^^ variable <list> with value [1,2,3] can not be rendered
|
||||
|
|
||||
|
||||
error: Decompression error
|
||||
--> tests_failed/runner_errors.hurl:167:1
|
||||
--> tests_failed/runner_errors.hurl:166:1
|
||||
|
|
||||
| GET http://localhost:8000/runner_errors/unsupported-content-encoding
|
||||
| ...
|
||||
167 | bytes count == 10
|
||||
166 | bytes count == 10
|
||||
| ^^^^^ compression unknown is not supported
|
||||
|
|
||||
|
||||
error: Unsupported HTTP version
|
||||
--> tests_failed/runner_errors.hurl:170:5
|
||||
--> tests_failed/runner_errors.hurl:169:5
|
||||
|
|
||||
170 | GET http://localhost:8000/runner_errors
|
||||
169 | GET http://localhost:8000/runner_errors
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ HTTP/3 is not supported, check --version
|
||||
|
|
||||
|
||||
|
@ -91,10 +91,9 @@ HTTP 200
|
||||
body regex "{}" == "a"
|
||||
|
||||
# InvalidUrl
|
||||
#GET http:///
|
||||
|
||||
# InvalidUrlPrefix
|
||||
# TODO: remove enum variant if not used
|
||||
GET {{url}}
|
||||
[Options]
|
||||
variable: url=localhost:8000/runner_errors
|
||||
|
||||
# NoQueryResult
|
||||
GET http://localhost:8000/runner_errors
|
||||
|
@ -139,114 +139,121 @@
|
||||
[1;34m |[0m[1;31m ^^^^ [0m[1;31mregex expression is not valid[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mInvalid URL[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:94:5
|
||||
[1;34m |[0m
|
||||
[1;34m 94 |[0m GET {{url}}
|
||||
[1;34m |[0m[1;31m ^^^^^^^ [0m[1;31minvalid URL <localhost:8000/runner_errors> (Missing protocol http or https)[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mNo query result[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:103:8
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:102:8
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors[0m
|
||||
[1;34m |[0m[90m ...[0m
|
||||
[1;34m103 |[0m count: header "count"
|
||||
[1;34m102 |[0m count: header "count"
|
||||
[1;34m |[0m[1;31m ^^^^^^^^^^^^^^ [0m[1;31mThe query didn't return any result[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mHeader not found[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:108:1
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:107:1
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors[0m
|
||||
[1;34m |[0m[90m ...[0m
|
||||
[1;34m108 |[0m count: 10
|
||||
[1;34m107 |[0m count: 10
|
||||
[1;34m |[0m[1;31m ^^^^^ [0m[1;31mthis header has not been found in the response[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mInvalid JSON[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:114:1
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:113:1
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors[0m
|
||||
[1;34m |[0m[90m ...[0m
|
||||
[1;34m114 |[0m jsonpath "$.count" == 10
|
||||
[1;34m113 |[0m jsonpath "$.count" == 10
|
||||
[1;34m |[0m[1;31m ^^^^^^^^^^^^^^^^^^ [0m[1;31mthe HTTP response is not a valid JSON[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mInvalid JSONPath[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:120:10
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:119:10
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors[0m
|
||||
[1;34m |[0m[90m ...[0m
|
||||
[1;34m120 |[0m jsonpath "xxx" == 10
|
||||
[1;34m119 |[0m jsonpath "xxx" == 10
|
||||
[1;34m |[0m[1;31m ^^^^^ [0m[1;31mthe JSONPath expression 'xxx' is not valid[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mInvalid XML[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:126:1
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:125:1
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors/invalid-xml[0m
|
||||
[1;34m |[0m[90m ...[0m
|
||||
[1;34m126 |[0m xpath "//a" == 10
|
||||
[1;34m125 |[0m xpath "//a" == 10
|
||||
[1;34m |[0m[1;31m ^^^^^^^^^^^ [0m[1;31mthe HTTP response is not a valid XML[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mInvalid XPath expression[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:132:7
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:131:7
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors[0m
|
||||
[1;34m |[0m[90m ...[0m
|
||||
[1;34m132 |[0m xpath "//" == 10
|
||||
[1;34m131 |[0m xpath "//" == 10
|
||||
[1;34m |[0m[1;31m ^^^^ [0m[1;31mthe XPath expression is not valid[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mInvalid variable type[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:138:12
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:137:12
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors[0m
|
||||
[1;34m |[0m[90m ...[0m
|
||||
[1;34m138 |[0m verbose: {{verbose}}
|
||||
[1;34m137 |[0m verbose: {{verbose}}
|
||||
[1;34m |[0m[1;31m ^^^^^^^ [0m[1;31mexpecting boolean, actual value is <1>[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mUndefined variable[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:143:10
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:142:10
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors[0m
|
||||
[1;34m |[0m[90m ...[0m
|
||||
[1;34m143 |[0m param: {{value}}
|
||||
[1;34m142 |[0m param: {{value}}
|
||||
[1;34m |[0m[1;31m ^^^^^ [0m[1;31myou must set the variable value[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mHTTP connection[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:146:5
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:145:5
|
||||
[1;34m |[0m
|
||||
[1;34m146 |[0m GET http://localhost:8000/runner_errors/redirect/2
|
||||
[1;34m145 |[0m GET http://localhost:8000/runner_errors/redirect/2
|
||||
[1;34m |[0m[1;31m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [0m[1;31mtoo many redirect[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mUnauthorized file access[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:153:6
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:152:6
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors[0m
|
||||
[1;34m153 |[0m file,/root/file;
|
||||
[1;34m152 |[0m file,/root/file;
|
||||
[1;34m |[0m[1;31m ^^^^^^^^^^ [0m[1;31munauthorized access to file /root/file, check --file-root option[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mUnrenderable variable[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:161:4
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:160:4
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors[0m
|
||||
[1;34m161 |[0m `{{list}}`
|
||||
[1;34m160 |[0m `{{list}}`
|
||||
[1;34m |[0m[1;31m ^^^^ [0m[1;31mvariable <list> with value [1,2,3] can not be rendered[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mDecompression error[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:167:1
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:166:1
|
||||
[1;34m |[0m
|
||||
[1;34m |[0m [90mGET http://localhost:8000/runner_errors/unsupported-content-encoding[0m
|
||||
[1;34m |[0m[90m ...[0m
|
||||
[1;34m167 |[0m bytes count == 10
|
||||
[1;34m166 |[0m bytes count == 10
|
||||
[1;34m |[0m[1;31m ^^^^^ [0m[1;31mcompression unknown is not supported[0m
|
||||
[1;34m |[0m
|
||||
|
||||
[1;31merror[0m: [1mUnsupported HTTP version[0m
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:170:5
|
||||
[1;34m-->[0m tests_failed/runner_errors.hurl:169:5
|
||||
[1;34m |[0m
|
||||
[1;34m170 |[0m GET http://localhost:8000/runner_errors
|
||||
[1;34m169 |[0m GET http://localhost:8000/runner_errors
|
||||
[1;34m |[0m[1;31m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [0m[1;31mHTTP/3 is not supported, check --version[0m
|
||||
[1;34m |[0m
|
||||
|
||||
|
@ -44,8 +44,7 @@ pub enum HttpError {
|
||||
description: String,
|
||||
},
|
||||
UnsupportedHttpVersion(RequestedHttpVersion),
|
||||
InvalidUrl(String),
|
||||
InvalidUrlPrefix(String),
|
||||
InvalidUrl(String, String),
|
||||
}
|
||||
|
||||
impl From<curl::Error> for HttpError {
|
||||
|
@ -108,15 +108,23 @@ impl Request {
|
||||
// FIXME: is it possible to do it with libcurl?
|
||||
let url = match Url::parse(&self.url) {
|
||||
Ok(url) => url,
|
||||
Err(_) => return Err(HttpError::InvalidUrl(self.url.clone())),
|
||||
Err(e) => return Err(HttpError::InvalidUrl(self.url.clone(), e.to_string())),
|
||||
};
|
||||
let scheme = url.scheme();
|
||||
if scheme != "http" && scheme != "https" {
|
||||
return Err(HttpError::InvalidUrlPrefix(self.url.clone()));
|
||||
return Err(HttpError::InvalidUrl(
|
||||
self.url.clone(),
|
||||
"Missing protocol http or https".to_string(),
|
||||
));
|
||||
}
|
||||
let host = match url.host() {
|
||||
Some(host) => host,
|
||||
None => return Err(HttpError::InvalidUrl(self.url.clone())),
|
||||
None => {
|
||||
return Err(HttpError::InvalidUrl(
|
||||
self.url.clone(),
|
||||
"Can not extract host".to_string(),
|
||||
))
|
||||
}
|
||||
};
|
||||
let port = match url.port() {
|
||||
Some(port) => format!(":{port}"),
|
||||
|
@ -87,8 +87,7 @@ pub enum RunnerError {
|
||||
charset: String,
|
||||
},
|
||||
InvalidRegex,
|
||||
InvalidUrl(String),
|
||||
InvalidUrlPrefix(String),
|
||||
InvalidUrl(String, String),
|
||||
NoQueryResult,
|
||||
QueryHeaderNotFound,
|
||||
QueryInvalidJsonpathExpression {
|
||||
@ -144,7 +143,6 @@ impl hurl_core::error::Error for Error {
|
||||
RunnerError::InvalidJson { .. } => "Invalid JSON".to_string(),
|
||||
RunnerError::InvalidRegex => "Invalid regex".to_string(),
|
||||
RunnerError::InvalidUrl(..) => "Invalid URL".to_string(),
|
||||
RunnerError::InvalidUrlPrefix(..) => "Invalid URL".to_string(),
|
||||
RunnerError::NoQueryResult => "No query result".to_string(),
|
||||
RunnerError::QueryHeaderNotFound => "Header not found".to_string(),
|
||||
RunnerError::QueryInvalidJson => "Invalid JSON".to_string(),
|
||||
@ -214,10 +212,8 @@ impl hurl_core::error::Error for Error {
|
||||
format!("actual value is <{value}>")
|
||||
}
|
||||
RunnerError::InvalidRegex => "regex expression is not valid".to_string(),
|
||||
RunnerError::InvalidUrl(url) => format!("invalid URL <{url}>"),
|
||||
RunnerError::InvalidUrlPrefix(url) => {
|
||||
format!("URL <{url}> must start with http:// or https://")
|
||||
}
|
||||
RunnerError::InvalidUrl(url, reason) => format!("invalid URL <{url}> ({reason})"),
|
||||
|
||||
RunnerError::NoQueryResult => "The query didn't return any result".to_string(),
|
||||
RunnerError::QueryHeaderNotFound => {
|
||||
"this header has not been found in the response".to_string()
|
||||
@ -276,8 +272,7 @@ impl From<HttpError> for RunnerError {
|
||||
}
|
||||
HttpError::InvalidCharset { charset } => RunnerError::InvalidCharset { charset },
|
||||
HttpError::InvalidDecoding { charset } => RunnerError::InvalidDecoding { charset },
|
||||
HttpError::InvalidUrl(url) => RunnerError::InvalidUrl(url),
|
||||
HttpError::InvalidUrlPrefix(url) => RunnerError::InvalidUrlPrefix(url),
|
||||
HttpError::InvalidUrl(url, reason) => RunnerError::InvalidUrl(url, reason),
|
||||
HttpError::Libcurl { code, description } => {
|
||||
RunnerError::HttpConnection(format!("({code}) {description}"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user