81 lines
2.1 KiB
Rust
81 lines
2.1 KiB
Rust
|
|
//! DNS Integration Tests
|
||
|
|
|
||
|
|
use provisioning_orchestrator::dns::{DnsManager, DnsRecord, DnsRecordType};
|
||
|
|
use std::net::IpAddr;
|
||
|
|
|
||
|
|
#[tokio::test]
|
||
|
|
async fn test_dns_manager_initialization() {
|
||
|
|
let manager = DnsManager::new(
|
||
|
|
"http://localhost:53".to_string(),
|
||
|
|
true,
|
||
|
|
300,
|
||
|
|
);
|
||
|
|
|
||
|
|
// Manager should be created successfully
|
||
|
|
assert_eq!(true, true); // Placeholder assertion
|
||
|
|
}
|
||
|
|
|
||
|
|
#[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().unwrap();
|
||
|
|
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().unwrap();
|
||
|
|
|
||
|
|
match ip {
|
||
|
|
IpAddr::V4(_) => {
|
||
|
|
let record_type = DnsRecordType::A;
|
||
|
|
assert_eq!(record_type, DnsRecordType::A);
|
||
|
|
}
|
||
|
|
IpAddr::V6(_) => panic!("Expected IPv4"),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[tokio::test]
|
||
|
|
async fn test_dns_record_type_ipv6() {
|
||
|
|
let ip: IpAddr = "2001:db8::1".parse().unwrap();
|
||
|
|
|
||
|
|
match ip {
|
||
|
|
IpAddr::V4(_) => panic!("Expected IPv6"),
|
||
|
|
IpAddr::V6(_) => {
|
||
|
|
let record_type = DnsRecordType::AAAA;
|
||
|
|
assert_eq!(record_type, 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");
|
||
|
|
}
|