Skip to content

Commit

Permalink
new test
Browse files Browse the repository at this point in the history
  • Loading branch information
joalopez1206 authored and FranciscaOrtegaG committed Oct 9, 2024
1 parent e63fb52 commit d81d53c
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions tests/edns_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ async fn query_from_ip_with_edns(domain_name: &str,
response.map(|lookup_response| lookup_response.to_dns_msg())
}

async fn query_response_edns(domain_name: &str,
protocol: &str,
qtype: &str,
max_payload: Option<u16>,
version: u8,
do_bit: bool,
async fn query_response_edns(domain_name: &str,
protocol: &str,
qtype: &str,
max_payload: Option<u16>,
version: u8,
do_bit: bool,
option: Option<Vec<u16>>) -> Result<DnsMessage, ClientError> {

let mut config = ResolverConfig::default();
Expand Down Expand Up @@ -152,5 +152,32 @@ async fn query_a_type_with_rrsig_edns() {
assert_eq!(opt.get_rtype(), Rrtype::OPT);
assert_eq!(opt.get_rclass(), Rclass::UNKNOWN(512));
println!("{:?}", opt);
}
}
}

#[tokio::test]
async fn query_from_root() {
const ROOTSV1: [u8; 4] = [192,58,128,30];

let mut ip2req = ROOTSV1.into();
let response = query_from_ip_with_edns("example.com",
"UDP", "A", Some(1024), 0, true,
Some(vec![3]), ip2req).await;
let response = match response {
Ok(rrs) => rrs,
Err(e) => panic!("{:?}", e),
};

println!("{}", response);

let additional_rrs = response.get_additional();

let a_rrs: Vec<_> = additional_rrs.iter()
.filter(|arrs|
if let Rdata::A(_) = arrs.get_rdata() {true}
else {false}).collect();

if let Rdata::A(rdata) = a_rrs[4].get_rdata() {
ip2req = rdata.get_address();
}
}

0 comments on commit d81d53c

Please sign in to comment.