recursor_test: backfill a test which follows CNAMEs through more than one layer

This commit is contained in:
Colin 2024-05-10 04:51:58 +00:00
parent c669e3d397
commit 6e251e348d

View File

@ -105,6 +105,7 @@ cname.sub.example.com. CNAME www.example.com.
cname.example.com. CNAME www.example.com.
example-org-cname.example.com. CNAME example.org.
inline-org-cname.example.com. CNAME inline.org.
double-cname.sub.example.com. CNAME inline-org-cname.example.org.
"#;
const ZONE_ORG: &str = r#"
@ -123,6 +124,7 @@ const ZONE_EXAMPLE_ORG: &str = r#"
60) ; MINIMUM
example.org. A 10.0.100.2
inline-org-cname.example.org. CNAME inline.org.
"#;
type HardcodedNameServer = NameServer<HardcodedConnProvider>;
@ -547,3 +549,37 @@ fn test_cname_to_other_ns() {
assert_eq!(&*lookup.records().to_vec(), &expected_records);
}
/// Follow more than one CNAME to an existing record.
#[test]
fn test_double_cname() {
logger("DEBUG");
let query = Query::query(Name::from_str("double-cname.sub.example.com.").unwrap(), RecordType::A);
let expected_records = [
cname_record(
Name::from_str("double-cname.sub.example.com.").unwrap(),
Name::from_str("inline-org-cname.example.org.").unwrap(),
),
cname_record(
Name::from_str("inline-org-cname.example.org.").unwrap(),
Name::from_str("inline.org.").unwrap(),
),
v4_record(
Name::from_str("inline.org.").unwrap(),
Ipv4Addr::new(10, 0, 100, 3),
),
];
let roots = NameServerPool::from_nameservers(
Default::default(),
vec![mock_nameserver(NS_ROOT)],
vec![],
);
let recursor = Recursor::new_with_pool(roots, 1024, 1048576).unwrap();
let now = Instant::now();
let lookup = block_on(recursor.resolve(query, now)).unwrap();
assert_eq!(&*lookup.records().to_vec(), &expected_records);
}