Skip to content

Commit 1167f44

Browse files
committed
add test empty domain in to bytes in nsec (fails for a bug)
1 parent 727a5b7 commit 1167f44

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/message/rdata/nsec_rdata.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,5 +477,28 @@ mod nsec_rdata_test{
477477
assert_eq!(nsec_rdata.to_bytes(), bytes_to_test);
478478
}
479479

480+
#[test]
481+
fn from_bytes_empty_domain() {
482+
let next_domain_name_bytes = vec![0, 0]; //codification for domain name = ""
483+
484+
let bit_map_bytes_to_test = vec![0, 6, 64, 1, 0, 0, 0, 3,
485+
4, 27, 0, 0, 0, 0, 0, 0, 0,
486+
0, 0, 0, 0, 0, 0, 0, 0, 0,
487+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32];
488+
489+
let bytes_to_test = [next_domain_name_bytes, bit_map_bytes_to_test].concat();
490+
491+
//FIXME: If the domain name in bytes is the "", then from_bytes reads the 64 like the map lenght instead of 6
492+
// this must because are two zeros in the domain, and after read the first zero, the other (the second) became part of the bitmap
493+
let nsec_rdata = NsecRdata::from_bytes(&bytes_to_test, &bytes_to_test).unwrap();
494+
495+
let expected_next_domain_name = String::from("");
496+
497+
assert_eq!(nsec_rdata.get_next_domain_name().get_name(), expected_next_domain_name);
498+
499+
let expected_type_bit_maps = vec![Rtype::A, Rtype::MX, Rtype::RRSIG, Rtype::NSEC, Rtype::UNKNOWN(1234)];
500+
501+
assert_eq!(nsec_rdata.get_type_bit_maps(), expected_type_bit_maps);
502+
}
480503

481504
}

0 commit comments

Comments
 (0)