1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2025 Erick Bourgeois, firestoned
// SPDX-License-Identifier: MIT
//! Tests for nsupdate executor
#[cfg(test)]
mod tests {
use crate::nsupdate::NsupdateExecutor;
#[test]
fn test_new_executor_with_full_tsig() {
let executor = NsupdateExecutor::new(
"127.0.0.1".to_string(),
53,
Some("update-key".to_string()),
Some("HMAC-SHA256".to_string()),
Some("dGVzdC1zZWNyZXQ=".to_string()),
);
assert!(executor.is_ok());
}
#[test]
fn test_new_executor_without_tsig() {
let executor = NsupdateExecutor::new("10.0.0.1".to_string(), 5353, None, None, None);
assert!(executor.is_ok());
}
#[test]
fn test_new_executor_custom_port() {
let executor = NsupdateExecutor::new(
"192.168.1.1".to_string(),
8053,
Some("key".to_string()),
Some("HMAC-SHA512".to_string()),
Some("c2VjcmV0".to_string()),
);
assert!(executor.is_ok());
}
// Note: We cannot easily test the execute() method and record operations
// without a real BIND9 server, so these are integration tests that should
// be run separately with a test environment.
//
// For unit testing, we validate the struct creation and error parsing logic,
// which are in the main nsupdate.rs file.
}