mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-30 19:17:11 +03:00
Merge pull request #148 from Orange-OpenSource/feature/improve-ssl-error-message
Be more specific for SSL Certificate errors
This commit is contained in:
commit
a2ae1944e3
@ -1,7 +1,7 @@
|
|||||||
error: Http Connection
|
error: SSL Certificate
|
||||||
--> ssl/error_self_signed_certificate.hurl:1:5
|
--> ssl/error_self_signed_certificate.hurl:1:5
|
||||||
|
|
|
|
||||||
1 | GET https://localhost:8001/hello
|
1 | GET https://localhost:8001/hello
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SSL certificate problem
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SSL certificate problem: self signed certificate
|
||||||
|
|
|
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ pub enum HttpError {
|
|||||||
FailToConnect,
|
FailToConnect,
|
||||||
TooManyRedirect,
|
TooManyRedirect,
|
||||||
CouldNotParseResponse,
|
CouldNotParseResponse,
|
||||||
SSLCertificate,
|
SSLCertificate(Option<String>),
|
||||||
InvalidUrl,
|
InvalidUrl,
|
||||||
Timeout,
|
Timeout,
|
||||||
StatuslineIsMissing,
|
StatuslineIsMissing,
|
||||||
@ -201,7 +201,9 @@ impl Client {
|
|||||||
6 => Err(HttpError::CouldNotResolveHost),
|
6 => Err(HttpError::CouldNotResolveHost),
|
||||||
7 => Err(HttpError::FailToConnect),
|
7 => Err(HttpError::FailToConnect),
|
||||||
28 => Err(HttpError::Timeout),
|
28 => Err(HttpError::Timeout),
|
||||||
60 => Err(HttpError::SSLCertificate),
|
60 => Err(HttpError::SSLCertificate(
|
||||||
|
e.extra_description().map(String::from),
|
||||||
|
)),
|
||||||
_ => Err(HttpError::Other {
|
_ => Err(HttpError::Other {
|
||||||
code: e.code() as i32, // due to windows build
|
code: e.code() as i32, // due to windows build
|
||||||
description: e.description().to_string(),
|
description: e.description().to_string(),
|
||||||
|
@ -133,7 +133,7 @@ pub enum RunnerError {
|
|||||||
Timeout,
|
Timeout,
|
||||||
TooManyRedirect,
|
TooManyRedirect,
|
||||||
CouldNotParseResponse,
|
CouldNotParseResponse,
|
||||||
SSLCertificate,
|
SSLCertificate(String),
|
||||||
|
|
||||||
UnsupportedContentEncoding(String),
|
UnsupportedContentEncoding(String),
|
||||||
CouldNotUncompressResponse(String),
|
CouldNotUncompressResponse(String),
|
||||||
|
@ -109,7 +109,9 @@ pub fn run(
|
|||||||
HttpError::Timeout => RunnerError::Timeout,
|
HttpError::Timeout => RunnerError::Timeout,
|
||||||
HttpError::TooManyRedirect => RunnerError::TooManyRedirect,
|
HttpError::TooManyRedirect => RunnerError::TooManyRedirect,
|
||||||
HttpError::CouldNotParseResponse => RunnerError::CouldNotParseResponse,
|
HttpError::CouldNotParseResponse => RunnerError::CouldNotParseResponse,
|
||||||
HttpError::SSLCertificate => RunnerError::SSLCertificate,
|
HttpError::SSLCertificate(description) => RunnerError::SSLCertificate(
|
||||||
|
description.unwrap_or_else(|| "SSL certificate problem".to_string()),
|
||||||
|
),
|
||||||
HttpError::InvalidUrl => RunnerError::InvalidURL(http_request.url.clone()),
|
HttpError::InvalidUrl => RunnerError::InvalidURL(http_request.url.clone()),
|
||||||
HttpError::StatuslineIsMissing => RunnerError::HttpConnection {
|
HttpError::StatuslineIsMissing => RunnerError::HttpConnection {
|
||||||
message: "status line is missing".to_string(),
|
message: "status line is missing".to_string(),
|
||||||
|
@ -25,7 +25,7 @@ impl Error for runner::Error {
|
|||||||
RunnerError::Timeout => "Http Connection".to_string(),
|
RunnerError::Timeout => "Http Connection".to_string(),
|
||||||
RunnerError::TooManyRedirect => "Http Connection".to_string(),
|
RunnerError::TooManyRedirect => "Http Connection".to_string(),
|
||||||
RunnerError::CouldNotParseResponse => "Http Connection".to_string(),
|
RunnerError::CouldNotParseResponse => "Http Connection".to_string(),
|
||||||
RunnerError::SSLCertificate => "Http Connection".to_string(),
|
RunnerError::SSLCertificate { .. } => "SSL Certificate".to_string(),
|
||||||
RunnerError::PredicateValue { .. } => "Assert - Predicate Value Failed".to_string(),
|
RunnerError::PredicateValue { .. } => "Assert - Predicate Value Failed".to_string(),
|
||||||
RunnerError::InvalidRegex {} => "Invalid regex".to_string(),
|
RunnerError::InvalidRegex {} => "Invalid regex".to_string(),
|
||||||
RunnerError::FileReadAccess { .. } => "File ReadAccess".to_string(),
|
RunnerError::FileReadAccess { .. } => "File ReadAccess".to_string(),
|
||||||
@ -67,7 +67,7 @@ impl Error for runner::Error {
|
|||||||
RunnerError::Timeout => "Timeout has been reached".to_string(),
|
RunnerError::Timeout => "Timeout has been reached".to_string(),
|
||||||
RunnerError::TooManyRedirect => "Too many redirect".to_string(),
|
RunnerError::TooManyRedirect => "Too many redirect".to_string(),
|
||||||
RunnerError::CouldNotParseResponse => "Could not parse response".to_string(),
|
RunnerError::CouldNotParseResponse => "Could not parse response".to_string(),
|
||||||
RunnerError::SSLCertificate => "SSL certificate problem".to_string(),
|
RunnerError::SSLCertificate(description) => description.clone(),
|
||||||
RunnerError::AssertVersion { actual, .. } => format!("actual value is <{}>", actual),
|
RunnerError::AssertVersion { actual, .. } => format!("actual value is <{}>", actual),
|
||||||
RunnerError::AssertStatus { actual, .. } => format!("actual value is <{}>", actual),
|
RunnerError::AssertStatus { actual, .. } => format!("actual value is <{}>", actual),
|
||||||
RunnerError::PredicateValue(value) => {
|
RunnerError::PredicateValue(value) => {
|
||||||
|
@ -519,6 +519,32 @@ fn test_error_could_not_resolve_proxy_name() {
|
|||||||
assert_eq!(error, HttpError::CouldNotResolveProxyName);
|
assert_eq!(error, HttpError::CouldNotResolveProxyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_error_ssl() {
|
||||||
|
let options = ClientOptions {
|
||||||
|
follow_location: false,
|
||||||
|
max_redirect: None,
|
||||||
|
cookie_input_file: None,
|
||||||
|
proxy: None,
|
||||||
|
no_proxy: None,
|
||||||
|
verbose: false,
|
||||||
|
insecure: false,
|
||||||
|
timeout: Default::default(),
|
||||||
|
connect_timeout: Default::default(),
|
||||||
|
user: None,
|
||||||
|
accept_encoding: None,
|
||||||
|
};
|
||||||
|
let mut client = Client::init(options);
|
||||||
|
let request = default_get_request("https://localhost:8001/hello".to_string());
|
||||||
|
let error = client.execute(&request, 0).err().unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
error,
|
||||||
|
HttpError::SSLCertificate(Some(
|
||||||
|
"SSL certificate problem: self signed certificate".to_string()
|
||||||
|
))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_timeout() {
|
fn test_timeout() {
|
||||||
let options = ClientOptions {
|
let options = ClientOptions {
|
||||||
|
Loading…
Reference in New Issue
Block a user