Add test infrastructure with fixtures, helpers, and integration tests

- Add [lib] target to enable integration test imports
- Add rcgen and reqwest dev-dependencies for TLS and HTTP test helpers
- Create src/config/test_fixtures.rs with test_static_config() and test_dynamic_config()
- Create tests/ with integration tests, HTTP test helper (TestUpstream), and TLS test helper (SelfSignedCert)
- Add Clone derives to StaticConfig and related structs for test fixture construction
- All existing tests continue to pass
This commit is contained in:
2026-06-11 11:46:43 +00:00
parent 9b4cabc4d6
commit 75f7b778df
11 changed files with 853 additions and 23 deletions

32
tests/integration_test.rs Normal file
View File

@@ -0,0 +1,32 @@
mod helpers;
#[tokio::test]
async fn test_upstream_spawn_and_connect() {
let upstream = helpers::http_test_helper::TestUpstream::spawn_ok().await;
let client = reqwest::Client::new();
let resp = client
.get(format!("http://127.0.0.1:{}/", upstream.addr.port()))
.send()
.await
.unwrap();
assert_eq!(resp.status(), reqwest::StatusCode::OK);
let _ = upstream.shutdown_tx.send(());
}
#[test]
fn test_self_signed_cert_generation() {
let cert = helpers::tls_test_helper::generate_self_signed_cert(&["test.local"]);
assert!(!cert.cert_pem.is_empty());
assert!(!cert.key_pem.is_empty());
assert!(cert.cert_pem.contains("BEGIN CERTIFICATE"));
assert!(cert.key_pem.contains("BEGIN"));
}
#[test]
fn test_config_fixtures() {
let static_config = reverse_proxy::config::test_fixtures::test_static_config();
assert!(!static_config.listeners.is_empty());
let dynamic_config = reverse_proxy::config::test_fixtures::test_dynamic_config();
assert!(!dynamic_config.sites.is_empty());
}