INNER CODE UNIT · Rust
browser_url_uses_localhost_for_https_local_bindings
TheWaWaR/simple-http-server · src/config.rs:616
fn browser_url_uses_localhost_for_https_local_bindings() {
let mut config = test_config(IpAddr::V4(Ipv4Addr::UNSPECIFIED));
config.cert = Some(PathBuf::from("localhost.p12"));
assert_eq!(browser_url(&config), "https://localhost:8000");
config.ip = IpAddr::V4(Ipv4Addr::LOCALHOST);
assert_eq!(browser_url(&config), "https://localhost:8000");
config.ip = IpAddr::V6(Ipv6Addr::LOCALHOST);
assert_eq!(browser_url(&config), "https://localhost:8000");
}
#[test]
fn browser_url_keeps_bind_address_when_not_local_https() {
let mut config = test_config(IpAddr::V4(Ipv4Addr::new(192, 168, 1, 10)));
config.cert = Some(PathBuf::from("server.p12"));
assert_eq!(browser_url(&config), "https://192.168.1.10:8000");