Skip to content

Commit

Permalink
WIP: Fix $TTL not taken into account with wildcard from zonefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
darnuria committed Dec 4, 2022
1 parent a074ffd commit bed20ba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
33 changes: 33 additions & 0 deletions crates/server/tests/store_file_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,36 @@ fn test_all_lines_are_loaded() {
};
assert!(authority.records_get_mut().get(&rrkey).is_some())
}

#[test]
pub fn test_ttl_wilcard() {
let config = FileConfig {
zone_file_path: "../../tests/test-data/named_test_configs/default/test.local.zone"
.to_string(),
};

let zone_name = LowerName::from_str("test.local.").unwrap();

let mut authority = FileAuthority::try_from_config(
Name::from(zone_name.clone()),
ZoneType::Primary,
false,
None,
&config,
)
.unwrap();

// This one pass.
let rrkey = RrKey {
record_type: RecordType::A,
name: LowerName::from(Name::from_ascii("simple.test.local.").unwrap()),
};
assert_eq!(authority.records_get_mut().get(&rrkey).unwrap().ttl(), 120);

// This one related to a wildcard don't pass arround $TTL
let rrkey = RrKey {
record_type: RecordType::A,
name: LowerName::from(Name::from_ascii("x.wc.test.local.").unwrap()),
};
assert_eq!(authority.records_get_mut().get(&rrkey).unwrap().ttl(), 120);
}
5 changes: 5 additions & 0 deletions tests/test-data/named_test_configs/default/test.local.zone
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$TTL 120
@ IN SOA ns.test.local. nobody.example.com. (2022120201 3600 1800 604800 60)
ns IN A 127.0.0.1
simple IN A 10.0.0.1
*.wc IN A 10.0.0.2

0 comments on commit bed20ba

Please sign in to comment.