Files
hickory-dns/crates/server/tests/store_file_tests.rs
Benjamin Fry 408d0baca0 Prepare 0.24 release with branding change to Hickory DNS (#2054)
* update all READMEs with notices about the name change

* update changelog for 0.24

* bump crate versions to 0.24

* update version notice information

* update readmes to back reference trust-dns

* rename all crates to hickory counterparts

* replace all Trust-DNS references in code and comments with Hickory DNS

* rename all Trust-DNS references to Hickory DNS in non-code

* rename all trust-dns-resolver references to hickory-resolver

* rename all trust-dns-client references to hickory-client

* rename all trust-dns-proto references to hickory-proto

* rename all trust-dns-server references to hickory-server

* rename all trust-dns-compatibility references to hickory-compatability

* rename all trust-dns-integration references to hickory-integration

* rename all trust-dns-util references to hickory-util

* Update MIT licenses to reference Hickory DNS

* update all trust-dns references to hickory-dns

* update all bluejekyll github references to hickorydns org

* Update name in Changelog

* make sure hickory-dns logs during tests

* add changelogs for recent main additions

* fix references to trust-dns and hickory in architecture

* update a few trust-dns references in READMEs

* fixup some dangling trust_dns references

* replace fka with formerly in change log

* replace all hickoydns org references to hickory-dns

* replace all http links with https

* update logos

* update hickorydns to hickory-dns for all other org references

* fix Notices of Trust-DNS to Hickory in each Readme
2023-10-13 18:39:28 -07:00

102 lines
2.8 KiB
Rust

use std::str::FromStr;
use hickory_proto::rr::{LowerName, Name, RecordType, RrKey};
use hickory_server::authority::{Authority, LookupOptions, ZoneType};
use hickory_server::store::file::{FileAuthority, FileConfig};
#[macro_use]
mod authority_battery;
fn file(master_file_path: &str, _module: &str, _test_name: &str) -> FileAuthority {
let config = FileConfig {
zone_file_path: master_file_path.to_string(),
};
FileAuthority::try_from_config(
Name::from_str("example.com.").unwrap(),
ZoneType::Primary,
false,
None,
&config,
)
.expect("failed to load file")
}
basic_battery!(file);
#[cfg(feature = "dnssec")]
dnssec_battery!(file);
#[test]
fn test_all_lines_are_loaded() {
let config = FileConfig {
zone_file_path: "../../tests/test-data/test_configs/default/nonewline.zone".to_string(),
};
let mut authority = FileAuthority::try_from_config(
Name::from_str("example.com.").unwrap(),
ZoneType::Primary,
false,
None,
&config,
)
.expect("failed to load");
let rrkey = RrKey {
record_type: RecordType::A,
name: LowerName::from(Name::from_ascii("ensure.nonewline.").unwrap()),
};
assert!(authority.records_get_mut().get(&rrkey).is_some())
}
#[test]
fn test_implicit_in_class() {
let config = FileConfig {
zone_file_path: "../../tests/test-data/test_configs/default/implicitclass.zone".to_string(),
};
let authority = FileAuthority::try_from_config(
Name::from_str("example.com.").unwrap(),
ZoneType::Primary,
false,
None,
&config,
);
assert!(authority.is_ok());
}
#[tokio::test]
async fn test_ttl_wilcard() {
let config = FileConfig {
zone_file_path: "../../tests/test-data/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 name = LowerName::from(Name::from_ascii("x.wc.test.local.").unwrap());
let rr = authority
.lookup(&name, RecordType::A, LookupOptions::default())
.await
.unwrap();
let data = rr
.into_iter()
.next()
.expect("A record not found in authority");
assert_eq!(data.record_type(), RecordType::A);
assert_eq!(data.ttl(), 120);
}