package bind import "testing" func TestResultClassification(t *testing.T) { // named-checkconf exited 0: everything it printed is a warning. ok := newResult(`both "recursion no;" and "allow-recursion" active for view external zone example.com/IN/internal: loaded serial 1 `, 0) if !ok.OK || len(ok.Messages) != 2 || ok.Messages[0].Error || ok.Messages[1].Error { t.Errorf("exit 0: %+v", ok) } // Non-zero exit: real problems stay errors. bad := newResult(`/etc/bind/jarl/named.conf:12: unknown option 'recursoin' `, 1) if bad.OK || len(bad.Messages) != 1 || !bad.Messages[0].Error || bad.Messages[0].Line != 12 { t.Errorf("exit 1: %+v", bad) } } func TestParseZoneStatusSigned(t *testing.T) { // rndc zonestatus of a zone named signs with dnssec-policy (BIND 9.20). zs := ParseZoneStatus(`name: example.test type: primary files: /var/lib/bind/jarl/_default/example.test.zone serial: 2026100802 signed serial: 2026100804 nodes: 4 last loaded: Thu, 08 Oct 2026 19:03:31 GMT secure: yes inline signing: yes key maintenance: automatic next key event: Thu, 08 Oct 2026 21:08:31 GMT next resign node: new.example.test/A next resign time: Sat, 17 Oct 2026 07:32:59 GMT dynamic: no reconfigurable via modzone: no `) if zs.Serial != 2026100802 || zs.SignedSerial != 2026100804 || !zs.Secure || !zs.InlineSigning || zs.NextKeyEvent != "Thu, 08 Oct 2026 21:08:31 GMT" { t.Errorf("%+v", zs) } if s, ok := zs.ServedSerial(); !ok || s != 2026100804 { t.Errorf("served serial %d %v", s, ok) } plain := ParseZoneStatus("name: example.com\nserial: 7\nsecure: no\n") if s, ok := plain.ServedSerial(); !ok || s != 7 || plain.HasSignedSerial { t.Errorf("unsigned: %+v", plain) } }