Skip to content

Commit ea7a0da

Browse files
committed
tests: inline tls_config() helper
And avoid unused code warnings for redundant verifier configs.
1 parent 2119f9c commit ea7a0da

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/connector.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -245,29 +245,29 @@ mod tests {
245245
assert_eq!(message, "unsupported scheme http");
246246
}
247247

248-
fn tls_config() -> rustls::ClientConfig {
249-
#[cfg(feature = "rustls-platform-verifier")]
250-
return rustls::ClientConfig::builder()
251-
.with_platform_verifier()
252-
.with_no_client_auth();
253-
254-
#[cfg(feature = "rustls-native-certs")]
255-
return rustls::ClientConfig::builder()
256-
.with_native_roots()
257-
.unwrap()
258-
.with_no_client_auth();
259-
260-
#[cfg(feature = "webpki-roots")]
261-
return rustls::ClientConfig::builder()
262-
.with_webpki_roots()
263-
.with_no_client_auth();
264-
}
265-
266248
async fn connect(
267249
https_only: bool,
268250
https: bool,
269251
) -> Result<MaybeHttpsStream<TokioIo<TcpStream>>, BoxError> {
270-
let builder = HttpsConnectorBuilder::new().with_tls_config(tls_config());
252+
let config_builder = rustls::ClientConfig::builder();
253+
#[cfg(feature = "rustls-platform-verifier")]
254+
let config_builder = config_builder.with_platform_verifier();
255+
#[cfg(all(
256+
not(feature = "rustls-platform-verifier"),
257+
feature = "rustls-native-certs"
258+
))]
259+
let config_builder = config_builder
260+
.with_native_roots()
261+
.unwrap();
262+
#[cfg(all(
263+
not(feature = "rustls-platform-verifier"),
264+
not(feature = "rustls-native-certs"),
265+
feature = "webpki-roots"
266+
))]
267+
let config_builder = config_builder.with_webpki_roots();
268+
269+
let builder =
270+
HttpsConnectorBuilder::new().with_tls_config(config_builder.with_no_client_auth());
271271
let mut service = match https_only {
272272
true => builder.https_only(),
273273
false => builder.https_or_http(),

0 commit comments

Comments
 (0)