feat(import): preserve supported HTTP contracts
This commit is contained in:
1 parent
083974c27f
commit
f8ee7c9bfe
87 files changed
+7496
-534
No files matched your search
@@ -0,0 +1,32 @@
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
|
||||
|
||||
use crate::client::{OutboundHttpPolicy, ip_match_hosts};
|
||||
|
||||
#[test]
|
||||
fn denied_resolved_ip_overrides_explicitly_allowed_hostname() {
|
||||
let policy = OutboundHttpPolicy::try_new_with_limits(
|
||||
vec!["api.example.test".to_owned()],
|
||||
vec!["169.254.169.254".to_owned()],
|
||||
4 * 1024 * 1024,
|
||||
4 * 1024 * 1024,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert!(policy.is_explicitly_allowed("api.example.test"));
|
||||
assert!(policy.is_denied_ip(IpAddr::V4(Ipv4Addr::new(169, 254, 169, 254))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn denied_resolved_ip_checks_ipv4_mapped_ipv6_alias() {
|
||||
let policy = OutboundHttpPolicy::try_new_with_limits(
|
||||
vec!["api.example.test".to_owned()],
|
||||
vec!["127.0.0.1".to_owned()],
|
||||
4 * 1024 * 1024,
|
||||
4 * 1024 * 1024,
|
||||
)
|
||||
.unwrap();
|
||||
let mapped = IpAddr::V6(Ipv6Addr::from(0xffff_7f00_0001u128));
|
||||
|
||||
assert!(ip_match_hosts(mapped).contains(&"127.0.0.1".to_owned()));
|
||||
assert!(policy.is_denied_ip(mapped));
|
||||
}
|
||||
Reference in new issue
Block a user