mod common;
use technitium::{AddRecord, Ttl, ZoneType};
const TEST_ZONE: &str = "test-records.example.com";
#[tokio::test]
#[ignore = "requires running Technitium server"]
async fn record_crud() {
let client = common::authenticated_client().await;
let _ = client.delete_zone(TEST_ZONE).await;
client
.create_zone(TEST_ZONE, ZoneType::Primary)
.await
.expect("create zone");
client
.add_record(
TEST_ZONE,
&AddRecord::a(
format!("app.{TEST_ZONE}"),
Ttl(300),
"10.0.0.1".parse().unwrap(),
),
)
.await
.expect("add A record");
client
.add_record(
TEST_ZONE,
&AddRecord::aaaa(format!("app.{TEST_ZONE}"), Ttl(300), "::1".parse().unwrap()),
)
.await
.expect("add AAAA record");
client
.add_record(
TEST_ZONE,
&AddRecord::mx(TEST_ZONE, Ttl(3600), 10, format!("mail.{TEST_ZONE}")),
)
.await
.expect("add MX record");
client
.add_record(
TEST_ZONE,
&AddRecord::txt(TEST_ZONE, Ttl(300), "v=spf1 -all"),
)
.await
.expect("add TXT record");
client
.add_record(
TEST_ZONE,
&AddRecord::srv(
format!("_sip._tcp.{TEST_ZONE}"),
Ttl(300),
10,
60,
5060,
format!("sip.{TEST_ZONE}"),
),
)
.await
.expect("add SRV record");
client
.add_record(
TEST_ZONE,
&AddRecord::caa(TEST_ZONE, Ttl(3600), 0, "issue", "letsencrypt.org"),
)
.await
.expect("add CAA record");
let records = client
.list_records(TEST_ZONE, None)
.await
.expect("list records");
assert!(
records.len() >= 4,
"should have at least SOA, NS, and added records"
);
client.delete_zone(TEST_ZONE).await.expect("delete zone");
}