Skip to content

Commit 03f9452

Browse files
committed
test(policy-fetcher): Add unit test for env vars capitalization
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
1 parent 475bd72 commit 03f9452

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/policy-fetcher/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ x509-parser = "0.18"
5151
anyhow = { workspace = true }
5252
rcgen = "0.14"
5353
rstest = { workspace = true }
54+
temp-env = "0.3"
5455
tempfile = { workspace = true }
5556
testcontainers = { version = "0.27", default-features = false, features = [
5657
"aws-lc-rs",

crates/policy-fetcher/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,4 +570,34 @@ mod tests {
570570
!success
571571
);
572572
}
573+
574+
#[test]
575+
fn test_get_proxy_env_vars_case_insensitivity() {
576+
temp_env::with_vars(
577+
[
578+
("http_proxy", Some("http://lowercase-http")),
579+
("https_proxy", Some("http://lowercase-https")),
580+
("no_proxy", Some("localhost,127.0.0.1")),
581+
],
582+
|| {
583+
let (http, https, no) = get_proxy_env_vars();
584+
assert_eq!(http, Some("http://lowercase-http".to_string()));
585+
assert_eq!(https, Some("http://lowercase-https".to_string()));
586+
assert_eq!(no, Some("localhost,127.0.0.1".to_string()));
587+
},
588+
);
589+
temp_env::with_vars(
590+
[
591+
("HTTP_PROXY", Some("http://uppercase-http")),
592+
("HTTPS_PROXY", Some("http://uppercase-https")),
593+
("NO_PROXY", Some("our.example")),
594+
],
595+
|| {
596+
let (http, https, no) = get_proxy_env_vars();
597+
assert_eq!(http, Some("http://uppercase-http".to_string()));
598+
assert_eq!(https, Some("http://uppercase-https".to_string()));
599+
assert_eq!(no, Some("our.example".to_string()));
600+
},
601+
);
602+
}
573603
}

0 commit comments

Comments
 (0)