Merge remote-tracking branch 'origin/feat/setup/test-infrastructure'
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
pub mod dynamic_config;
|
||||
pub mod static_config;
|
||||
pub mod test_fixtures;
|
||||
pub mod validation;
|
||||
|
||||
65
src/config/test_fixtures.rs
Normal file
65
src/config/test_fixtures.rs
Normal file
@@ -0,0 +1,65 @@
|
||||
use crate::config::dynamic_config::{BodyConfig, DynamicConfig, RateLimitConfig, SiteConfig};
|
||||
use crate::config::static_config::{ListenerConfig, LoggingConfig, StaticConfig, TlsConfig};
|
||||
|
||||
pub fn test_static_config() -> StaticConfig {
|
||||
StaticConfig {
|
||||
listeners: vec![ListenerConfig {
|
||||
bind_addr: "127.0.0.1".to_string(),
|
||||
http_port: 80,
|
||||
https_port: 443,
|
||||
tls: TlsConfig {
|
||||
mode: "manual".to_string(),
|
||||
acme_domains: vec![],
|
||||
acme_cache_dir: String::new(),
|
||||
acme_directory: "production".to_string(),
|
||||
cert_path: "/tmp/test-cert.pem".to_string(),
|
||||
key_path: "/tmp/test-key.pem".to_string(),
|
||||
},
|
||||
sites: vec![],
|
||||
}],
|
||||
allow_wildcard_bind: false,
|
||||
health_check_port: 9900,
|
||||
admin_socket_path: "/tmp/reverse-proxy-test/admin.sock".to_string(),
|
||||
shutdown_timeout_secs: 30,
|
||||
logging: LoggingConfig::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn test_dynamic_config() -> DynamicConfig {
|
||||
DynamicConfig {
|
||||
sites: vec![SiteConfig {
|
||||
host: "test.local".to_string(),
|
||||
upstream: "127.0.0.1:8080".to_string(),
|
||||
upstream_scheme: "http".to_string(),
|
||||
upstream_connect_timeout_secs: 5,
|
||||
upstream_request_timeout_secs: 60,
|
||||
}],
|
||||
rate_limit: RateLimitConfig {
|
||||
requests_per_second: 10,
|
||||
burst: 20,
|
||||
},
|
||||
body: BodyConfig {
|
||||
limit_bytes: 104857600,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_static_config_fixture_is_valid() {
|
||||
let config = test_static_config();
|
||||
assert!(!config.listeners.is_empty());
|
||||
assert_eq!(config.health_check_port, 9900);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dynamic_config_fixture_is_valid() {
|
||||
let config = test_dynamic_config();
|
||||
assert!(!config.sites.is_empty());
|
||||
assert_eq!(config.rate_limit.requests_per_second, 10);
|
||||
assert_eq!(config.body.limit_bytes, 104857600);
|
||||
}
|
||||
}
|
||||
8
src/lib.rs
Normal file
8
src/lib.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
pub mod admin;
|
||||
pub mod config;
|
||||
pub mod health;
|
||||
pub mod logging;
|
||||
pub mod proxy;
|
||||
pub mod rate_limit;
|
||||
pub mod shutdown;
|
||||
pub mod tls;
|
||||
@@ -1,12 +1,3 @@
|
||||
mod admin;
|
||||
mod config;
|
||||
mod health;
|
||||
mod logging;
|
||||
mod proxy;
|
||||
mod rate_limit;
|
||||
mod shutdown;
|
||||
mod tls;
|
||||
|
||||
fn main() {
|
||||
tracing::info!("reverse-proxy starting");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user