test: add watcher orchestrator tests with mock dependencies
Tests cover: first-run baseline, NS change detection, record change detection, port state changes, TLS expiry warnings, graceful shutdown, and NS failure/recovery scenarios.
This commit is contained in:
60
internal/watcher/interfaces.go
Normal file
60
internal/watcher/interfaces.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Package watcher provides the main monitoring orchestrator.
|
||||
package watcher
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"sneak.berlin/go/dnswatcher/internal/tlscheck"
|
||||
)
|
||||
|
||||
// DNSResolver performs iterative DNS resolution.
|
||||
type DNSResolver interface {
|
||||
// LookupNS discovers authoritative nameservers for a domain.
|
||||
LookupNS(
|
||||
ctx context.Context,
|
||||
domain string,
|
||||
) ([]string, error)
|
||||
|
||||
// LookupAllRecords queries all record types for a hostname,
|
||||
// returning results keyed by nameserver then record type.
|
||||
LookupAllRecords(
|
||||
ctx context.Context,
|
||||
hostname string,
|
||||
) (map[string]map[string][]string, error)
|
||||
|
||||
// ResolveIPAddresses resolves a hostname to all IP addresses.
|
||||
ResolveIPAddresses(
|
||||
ctx context.Context,
|
||||
hostname string,
|
||||
) ([]string, error)
|
||||
}
|
||||
|
||||
// PortChecker tests TCP port connectivity.
|
||||
type PortChecker interface {
|
||||
// CheckPort tests TCP connectivity to an address and port.
|
||||
CheckPort(
|
||||
ctx context.Context,
|
||||
address string,
|
||||
port int,
|
||||
) (bool, error)
|
||||
}
|
||||
|
||||
// TLSChecker inspects TLS certificates.
|
||||
type TLSChecker interface {
|
||||
// CheckCertificate connects via TLS and returns cert info.
|
||||
CheckCertificate(
|
||||
ctx context.Context,
|
||||
ip string,
|
||||
hostname string,
|
||||
) (*tlscheck.CertificateInfo, error)
|
||||
}
|
||||
|
||||
// Notifier delivers notifications to configured endpoints.
|
||||
type Notifier interface {
|
||||
// SendNotification sends a notification with the given
|
||||
// details.
|
||||
SendNotification(
|
||||
ctx context.Context,
|
||||
title, message, priority string,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user