Skip to content

Commit

Permalink
Skip connector tests when no crypto provider is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
saleemrashid committed Dec 19, 2024
1 parent 63dc4f8 commit 17fdefa
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,45 @@ pub trait ResolveServerName {
) -> Result<ServerName<'static>, Box<dyn std::error::Error + Sync + Send>>;
}

#[cfg(test)]
#[cfg(all(
test,
any(feature = "ring", feature = "aws-lc-rs"),
any(feature = "rustls-native-certs", feature = "webpki-roots")
))]
mod tests {
use http::Uri;
use hyper_util::client::legacy::connect::HttpConnector;
use tower::ServiceExt;

use super::HttpsConnector;
use crate::HttpsConnectorBuilder;
use crate::{ConfigBuilderExt, HttpsConnectorBuilder};

fn https_or_http_connector() -> HttpsConnector<HttpConnector> {
HttpsConnectorBuilder::new()
#[cfg(feature = "rustls-native-certs")]
fn tls_config() -> rustls::ClientConfig {
rustls::ClientConfig::builder()
.with_native_roots()
.unwrap()
.with_no_client_auth()
}

#[cfg(all(not(feature = "rustls-native-certs"), feature = "webpki-roots"))]
fn tls_config() -> rustls::ClientConfig {
rustls::ClientConfig::builder()
.with_webpki_roots()
.with_no_client_auth()
}

fn https_or_http_connector() -> HttpsConnector<HttpConnector> {
HttpsConnectorBuilder::new()
.with_tls_config(tls_config())
.https_or_http()
.enable_http1()
.build()
}

fn https_only_connector() -> HttpsConnector<HttpConnector> {
HttpsConnectorBuilder::new()
.with_native_roots()
.unwrap()
.with_tls_config(tls_config())
.https_only()
.enable_http1()
.build()
Expand Down

0 comments on commit 17fdefa

Please sign in to comment.