Skip to content

Commit

Permalink
Fix parsing proxy config from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-jplatte committed Sep 2, 2024
1 parent a799b8b commit f266c04
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion server/svix-server/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProxyConfig>,

#[serde(flatten)]
Expand All @@ -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,
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f266c04

Please sign in to comment.