This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolver: test that DS query is sent to parent zone
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
mod section_3; | ||
mod section_4; |
1 change: 1 addition & 0 deletions
1
packages/conformance-tests/src/resolver/dnssec/rfc4035/section_3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod section_3_1; |
1 change: 1 addition & 0 deletions
1
packages/conformance-tests/src/resolver/dnssec/rfc4035/section_3/section_3_1.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod section_3_1_4; |
78 changes: 78 additions & 0 deletions
78
...ages/conformance-tests/src/resolver/dnssec/rfc4035/section_3/section_3_1/section_3_1_4.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use dns_test::{ | ||
client::{Client, DigSettings}, | ||
name_server::{Graph, NameServer, Sign}, | ||
record::RecordType, | ||
tshark::{Capture, Direction}, | ||
Network, Resolver, Result, FQDN, | ||
}; | ||
|
||
#[test] | ||
#[ignore] | ||
fn on_clients_ds_query_it_queries_the_parent_zone() -> Result<()> { | ||
let peer = dns_test::peer(); | ||
let network = Network::new()?; | ||
|
||
let leaf_ns = NameServer::new(&peer, FQDN::NAMESERVERS, &network)?; | ||
|
||
let Graph { | ||
nameservers, | ||
root, | ||
trust_anchor, | ||
} = Graph::build(leaf_ns, Sign::Yes)?; | ||
|
||
let mut com_ns_addr = None; | ||
for nameserver in &nameservers { | ||
if nameserver.zone() == &FQDN::COM { | ||
com_ns_addr = Some(nameserver.ipv4_addr()); | ||
} | ||
} | ||
let com_ns_addr = com_ns_addr.expect("com. NS not found"); | ||
|
||
let trust_anchor = &trust_anchor.unwrap(); | ||
let resolver = Resolver::new(&network, root) | ||
.trust_anchor(trust_anchor) | ||
.start(&dns_test::subject())?; | ||
|
||
let mut tshark = resolver.eavesdrop()?; | ||
|
||
let resolver_addr = resolver.ipv4_addr(); | ||
|
||
let client = Client::new(&network)?; | ||
let settings = *DigSettings::default().recurse(); | ||
let output = client.dig(settings, resolver_addr, RecordType::DS, &FQDN::NAMESERVERS)?; | ||
|
||
tshark.wait_for_capture()?; | ||
|
||
let captures = tshark.terminate()?; | ||
|
||
// check that we were able to retrieve the DS record | ||
assert!(output.status.is_noerror()); | ||
let [record] = output.answer.try_into().unwrap(); | ||
let ds = record.try_into_ds().unwrap(); | ||
assert_eq!(ds.zone, FQDN::NAMESERVERS); | ||
|
||
// check that DS query was forwarded to the `com.` (parent zone) nameserver | ||
let client_addr = client.ipv4_addr(); | ||
let mut outgoing_ds_query_count = 0; | ||
for Capture { message, direction } in captures { | ||
if let Direction::Outgoing { destination } = direction { | ||
if destination != client_addr { | ||
let queries = message.as_value()["Queries"] | ||
.as_object() | ||
.expect("expected Object"); | ||
for query in queries.keys() { | ||
if query.contains("type DS") { | ||
assert!(query.contains("nameservers.com")); | ||
assert_eq!(com_ns_addr, destination); | ||
|
||
outgoing_ds_query_count += 1; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
assert_eq!(1, outgoing_ds_query_count); | ||
|
||
Ok(()) | ||
} |