From f266c0418f7b1720efdb9dec31d58ab294ad09e0 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 2 Sep 2024 10:35:58 +0200 Subject: [PATCH] Fix parsing proxy config from environment --- server/svix-server/src/cfg.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server/svix-server/src/cfg.rs b/server/svix-server/src/cfg.rs index f3b8fb0a1..07b3e06c5 100644 --- a/server/svix-server/src/cfg.rs +++ b/server/svix-server/src/cfg.rs @@ -190,7 +190,7 @@ pub struct ConfigurationInner { pub dangerous_disable_tls_verification: bool, /// Optional configuration for sending webhooks through a proxy. - #[serde(rename = "proxy")] + #[serde(flatten)] pub proxy_config: Option, #[serde(flatten)] @@ -202,6 +202,7 @@ pub struct ProxyConfig { /// SOCKS5 proxy address. /// /// More proxy types may be supported in the future. + #[serde(rename = "proxy_addr")] pub addr: ProxyAddr, } @@ -514,6 +515,20 @@ mod tests { }); } + #[test] + fn test_proxy_addr_from_env_parsing() { + figment::Jail::expect_with(|jail| { + jail.set_env("SVIX_QUEUE_TYPE", "memory"); + jail.set_env("SVIX_JWT_SECRET", "x"); + jail.set_env("SVIX_PROXY_ADDR", "x"); + + let cfg = load().unwrap(); + assert!(cfg.proxy_config.is_some()); + + Ok(()) + }); + } + #[test] fn test_cache_or_queue_dsn_priority() { // NOTE: Does not use `figment::Jail` like the above because set env vars will leak into