//! DNS Integration Tests — exercise the post-D.2 DnsManager facade. #![allow(unused_variables)] use std::net::IpAddr; use provisioning_orchestrator::dns::{DnsManager, DnsRecord, DnsRecordType}; #[tokio::test] async fn test_dns_manager_initialization() { let manager = DnsManager::new("http://localhost:53".to_string(), true, 300); assert!(manager.auto_register()); assert_eq!(manager.default_ttl(), 300); } #[tokio::test] async fn test_dns_registration_disabled() { let manager = DnsManager::new( "http://localhost:53".to_string(), false, // Disabled 300, ); let ip: IpAddr = "192.168.1.10".parse().expect("valid IP"); let result = manager .register_server_dns("test-server.example.com", ip) .await; // Should succeed but do nothing when disabled. assert!(result.is_ok()); } #[tokio::test] async fn test_dns_record_creation() { let record = DnsRecord { name: "test.example.com".to_string(), record_type: DnsRecordType::A, value: "192.168.1.10".to_string(), ttl: 300, }; assert_eq!(record.name, "test.example.com"); assert_eq!(record.record_type, DnsRecordType::A); assert_eq!(record.value, "192.168.1.10"); assert_eq!(record.ttl, 300); } #[tokio::test] async fn test_dns_record_type_ipv4() { let ip: IpAddr = "192.168.1.10".parse().expect("valid IP"); match ip { IpAddr::V4(_) => { assert_eq!(DnsRecordType::A, DnsRecordType::A); } IpAddr::V6(_) => panic!("Expected IPv4"), } } #[tokio::test] async fn test_dns_record_type_ipv6() { let ip: IpAddr = "2001:db8::1".parse().expect("valid IP"); match ip { IpAddr::V4(_) => panic!("Expected IPv6"), IpAddr::V6(_) => { assert_eq!(DnsRecordType::AAAA, DnsRecordType::AAAA); } } } #[test] fn test_dns_record_type_display() { assert_eq!(DnsRecordType::A.to_string(), "A"); assert_eq!(DnsRecordType::AAAA.to_string(), "AAAA"); assert_eq!(DnsRecordType::CNAME.to_string(), "CNAME"); assert_eq!(DnsRecordType::TXT.to_string(), "TXT"); }