@@ -477,5 +477,28 @@ mod nsec_rdata_test{
477
477
assert_eq ! ( nsec_rdata. to_bytes( ) , bytes_to_test) ;
478
478
}
479
479
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
+ }
480
503
481
504
}
0 commit comments