Skip to content

Commit

Permalink
run cargo fmt to pass the CI build
Browse files Browse the repository at this point in the history
  • Loading branch information
Guanqun Lu committed Sep 30, 2019
1 parent ba1f16a commit a4e3b81
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
18 changes: 11 additions & 7 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,11 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
"tlsv1.1" => SslVersion::Tlsv11,
"tlsv1.2" => SslVersion::Tlsv12,
"tlsv1.3" => SslVersion::Tlsv13,
_ => bail!("Invalid ssl version `{}`,\
choose from 'default', 'tlsv1', 'tlsv1.0', 'tlsv1.1', 'tlsv1.2', 'tlsv1.3'.",
s),
_ => bail!(
"Invalid ssl version `{}`,\
choose from 'default', 'tlsv1', 'tlsv1.0', 'tlsv1.1', 'tlsv1.2', 'tlsv1.3'.",
s
),
};
Ok(version)
}
Expand All @@ -459,10 +461,12 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
SslVersionConfig::Single(s) => {
let version = to_ssl_version(s.as_str())?;
handle.ssl_version(version)?;
},
SslVersionConfig::Range(SslVersionConfigRange{ min, max}) => {
let min_version = min.map_or(Ok(SslVersion::Default), |s| to_ssl_version(s.as_str()))?;
let max_version = max.map_or(Ok(SslVersion::Default), |s| to_ssl_version(s.as_str()))?;
}
SslVersionConfig::Range(SslVersionConfigRange { min, max }) => {
let min_version =
min.map_or(Ok(SslVersion::Default), |s| to_ssl_version(s.as_str()))?;
let max_version =
max.map_or(Ok(SslVersion::Default), |s| to_ssl_version(s.as_str()))?;
handle.ssl_min_max_version(min_version, max_version)?;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/cargo/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1880,4 +1880,3 @@ pub struct SslVersionConfigRange {
pub min: Option<String>,
pub max: Option<String>,
}

23 changes: 17 additions & 6 deletions tests/testsuite/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,12 @@ hello = 'world'

let config = new_config(&[]);

assert!(config.get::<Option<SslVersionConfig>>("http.ssl-version").unwrap().is_none());
assert!(config
.get::<Option<SslVersionConfig>>("http.ssl-version")
.unwrap()
.is_none());

let b = config.get_string("http.ssl-version").unwrap();
let b = config.get_string("http.ssl-version").unwrap();
println!("b: {:?}", if b.is_some() { "some" } else { "none" });
}

Expand All @@ -862,7 +865,10 @@ ssl-version = 'tlsv1.2'

let config = new_config(&[]);

let a = config.get::<Option<SslVersionConfig>>("http.ssl-version").unwrap().unwrap();
let a = config
.get::<Option<SslVersionConfig>>("http.ssl-version")
.unwrap()
.unwrap();
match a {
SslVersionConfig::Single(v) => assert_eq!(&v, "tlsv1.2"),
SslVersionConfig::Range(_) => panic!("Did not expect ssl version min/max."),
Expand All @@ -881,7 +887,10 @@ ssl-version.max = 'tlsv1.3'

let config = new_config(&[]);

let a = config.get::<Option<SslVersionConfig>>("http.ssl-version").unwrap().unwrap();
let a = config
.get::<Option<SslVersionConfig>>("http.ssl-version")
.unwrap()
.unwrap();
match a {
SslVersionConfig::Single(_) => panic!("Did not expect exact ssl version."),
SslVersionConfig::Range(range) => {
Expand All @@ -906,6 +915,8 @@ ssl-version.max = 'tlsv1.3'
let config = new_config(&[]);

assert!(config.get::<SslVersionConfig>("http.ssl-version").is_err());
assert!(config.get::<Option<SslVersionConfig>>("http.ssl-version").unwrap().is_none());
assert!(config
.get::<Option<SslVersionConfig>>("http.ssl-version")
.unwrap()
.is_none());
}

0 comments on commit a4e3b81

Please sign in to comment.