From c669e3d39790559f1b411ba4726bd21b682952ce Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 10 May 2024 04:46:26 +0000 Subject: [PATCH] recursor_test: backfill a test which follows CNAMEs across NS --- .../integration-tests/tests/recursor_tests.rs | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/tests/integration-tests/tests/recursor_tests.rs b/tests/integration-tests/tests/recursor_tests.rs index b69f362e..c67aa502 100644 --- a/tests/integration-tests/tests/recursor_tests.rs +++ b/tests/integration-tests/tests/recursor_tests.rs @@ -60,6 +60,8 @@ net NS a.gtld-servers.net. org NS b0.org.afilias-nst.org. b0.org.afilias-nst.org. A 10.0.0.4 + +us NS b.cctld.us. "#; const ZONE_TLDS: &str = r#" @@ -101,13 +103,15 @@ example.com. A 10.0.100.1 www.example.com. A 10.0.100.1 cname.sub.example.com. CNAME www.example.com. cname.example.com. CNAME www.example.com. -org-cname.example.com. CNAME example.org. +example-org-cname.example.com. CNAME example.org. +inline-org-cname.example.com. CNAME inline.org. "#; const ZONE_ORG: &str = r#" @ IN SOA a0.org.afilias-nst.info. hostmaster.donuts.email. 20 7200 600 3600000 60 example.org. NS a.iana-servers.net. +inline.org. A 10.0.100.3 "#; const ZONE_EXAMPLE_ORG: &str = r#" @@ -489,10 +493,10 @@ fn test_cname_queried_as_v4() { fn test_cname_to_other_zone() { logger("DEBUG"); - let query = Query::query(Name::from_str("org-cname.example.com.").unwrap(), RecordType::A); + let query = Query::query(Name::from_str("example-org-cname.example.com.").unwrap(), RecordType::A); let expected_records = [ cname_record( - Name::from_str("org-cname.example.com.").unwrap(), + Name::from_str("example-org-cname.example.com.").unwrap(), Name::from_str("example.org.").unwrap(), ), v4_record( @@ -513,3 +517,33 @@ fn test_cname_to_other_zone() { assert_eq!(&*lookup.records().to_vec(), &expected_records); } + +/// Follow a CNAME from one zone to another zone, served by a different NS. +#[test] +fn test_cname_to_other_ns() { + logger("DEBUG"); + + let query = Query::query(Name::from_str("inline-org-cname.example.com.").unwrap(), RecordType::A); + let expected_records = [ + cname_record( + Name::from_str("inline-org-cname.example.com.").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); +}