use hyper_custom_cert::HttpClient;
use std::collections::HashMap;
use std::time::Duration;
#[tokio::test]
async fn test_default_client_against_example_endpoints() {
let client = HttpClient::new();
let _ = client;
}
#[tokio::test]
async fn test_builder_client_against_example_endpoints() {
let client = HttpClient::builder().build();
let _ = client;
}
#[test]
fn test_timeout_configuration_for_example_server() {
let client = HttpClient::builder()
.with_timeout(Duration::from_secs(10))
.build();
let _ = client;
}
#[test]
fn test_headers_configuration_for_example_server() {
let mut headers = HashMap::new();
headers.insert(
"User-Agent".to_string(),
"hyper-custom-cert-integration-test/1.0".to_string(),
);
headers.insert("X-Test-Client".to_string(), "integration".to_string());
headers.insert("Accept".to_string(), "application/json".to_string());
let client = HttpClient::builder().with_default_headers(headers).build();
let _ = client;
}
#[test]
fn test_combined_configuration_for_example_server() {
let mut headers = HashMap::new();
headers.insert(
"User-Agent".to_string(),
"hyper-custom-cert-combined-test/1.0".to_string(),
);
let client = HttpClient::builder()
.with_timeout(Duration::from_secs(30))
.with_default_headers(headers)
.build();
let _ = client;
}
#[cfg(feature = "native-tls")]
#[test]
fn test_native_tls_feature_with_example_server() {
let client = HttpClient::builder()
.with_timeout(Duration::from_secs(15))
.build();
let _ = client;
}
#[cfg(feature = "rustls")]
#[test]
fn test_rustls_feature_with_example_server() {
let client = HttpClient::builder()
.with_timeout(Duration::from_secs(15))
.build();
let _ = client;
}
#[cfg(feature = "rustls")]
#[test]
fn test_rustls_custom_ca_configuration() {
let dummy_ca_pem = b"-----BEGIN CERTIFICATE-----\nDUMMY\n-----END CERTIFICATE-----";
let client = HttpClient::builder()
.with_root_ca_pem(dummy_ca_pem)
.with_timeout(Duration::from_secs(10))
.build();
let _ = client;
}
#[cfg(feature = "rustls")]
#[test]
fn test_rustls_cert_pinning_configuration() {
let dummy_pin = [0u8; 32];
let pins = vec![dummy_pin];
let client = HttpClient::builder().with_pinned_cert_sha256(pins).build();
let _ = client;
}
#[cfg(feature = "insecure-dangerous")]
#[test]
fn test_insecure_feature_with_example_server() {
let client = HttpClient::builder()
.insecure_accept_invalid_certs(true)
.build();
let _ = client;
}
#[cfg(feature = "insecure-dangerous")]
#[test]
fn test_self_signed_convenience_constructor() {
let client = HttpClient::with_self_signed_certs();
let _ = client;
}
#[tokio::test]
async fn test_request_options() {
use hyper_custom_cert::RequestOptions;
use std::collections::HashMap;
use std::time::Duration;
let client = HttpClient::new();
let mut headers = HashMap::new();
headers.insert("X-Custom-Header".to_string(), "test-value".to_string());
let options = RequestOptions::new()
.with_headers(headers)
.with_timeout(Duration::from_secs(15));
let _ = (client, options);
}
#[tokio::test]
async fn test_get_requests_to_example_server() {
let client = HttpClient::new();
let _ = client;
}
#[tokio::test]
async fn test_post_requests_to_example_server() {
let client = HttpClient::new();
let _ = client;
}
#[test]
fn test_timeout_error_handling() {
let client = HttpClient::builder()
.with_timeout(Duration::from_millis(1)) .build();
let _ = client;
}
#[tokio::test]
async fn test_invalid_url_handling() {
let client = HttpClient::new();
let _ = client;
}
#[tokio::test]
async fn test_connection_error_handling() {
let client = HttpClient::new();
let _ = client;
}
#[cfg(all(feature = "rustls", feature = "insecure-dangerous"))]
#[test]
fn test_rustls_with_insecure_combination() {
let client = HttpClient::builder()
.insecure_accept_invalid_certs(true)
.with_root_ca_pem(b"-----BEGIN CERTIFICATE-----\nDUMMY\n-----END CERTIFICATE-----")
.build();
let _ = client;
}
#[cfg(all(feature = "native-tls", feature = "insecure-dangerous"))]
#[test]
fn test_native_tls_with_insecure_combination() {
let client = HttpClient::builder()
.insecure_accept_invalid_certs(true)
.build();
let _ = client;
}
#[tokio::test]
async fn test_default_trait_implementations() {
let client = HttpClient::default();
let builder = hyper_custom_cert::HttpClientBuilder::default();
let _ = (client, builder);
}
#[test]
fn test_builder_chaining() {
let mut headers = HashMap::new();
headers.insert("Test-Header".to_string(), "test-value".to_string());
let mut client_builder = HttpClient::builder()
.with_timeout(Duration::from_secs(20))
.with_default_headers(headers);
#[cfg(feature = "insecure-dangerous")]
{
client_builder = client_builder.insecure_accept_invalid_certs(false);
}
#[cfg(feature = "rustls")]
{
client_builder = client_builder.with_root_ca_pem(b"dummy");
}
let client = client_builder.build();
let _ = client;
}
#[tokio::test]
async fn test_basic_usage_example() {
let client = HttpClient::new();
let _ = client;
}
#[tokio::test]
async fn test_builder_usage_example() {
let mut headers = HashMap::new();
headers.insert("User-Agent".to_string(), "my-app/1.0".to_string());
let client = HttpClient::builder()
.with_timeout(Duration::from_secs(30))
.with_default_headers(headers)
.build();
let _ = client;
}
#[cfg(feature = "rustls")]
#[tokio::test]
async fn test_rustls_usage_example() {
let client = HttpClient::builder()
.with_root_ca_pem(b"-----BEGIN CERTIFICATE-----\nDUMMY\n-----END CERTIFICATE-----")
.build();
let _ = client;
}
#[cfg(feature = "insecure-dangerous")]
#[tokio::test]
async fn test_insecure_usage_example() {
let client = HttpClient::builder()
.insecure_accept_invalid_certs(true)
.build();
let client2 = HttpClient::with_self_signed_certs();
let _ = (client, client2);
}