watcher, config: no Record Change or Inconsistency for listed names (closes #255)
check / check (push) Successful in 2m6s
check / check (push) Successful in 2m6s
DNSWATCHER_SKIP_RECORD_NOTIFICATIONS takes a comma-separated list of names from DNSWATCHER_TARGETS, read as the targets are (letter case, trailing dot, repeats). For a listed name no Record Change and no Inconsistency notification is sent; its records are still checked and saved, and its other notifications are sent. A listed name that is not a target stops startup with an error naming it. The two detections return early for a listed name. Apex domains are covered too: their own records go through the same detection. Live DNS cannot be made to disagree on purpose, so the Inconsistency test feeds records to the change detection directly, as the existing inconsistency tests do; the live test covers Record Change. Model: opus-5-5
This commit is contained in:
@@ -57,6 +57,7 @@ func TestNew_DefaultValues(t *testing.T) {
|
||||
assert.Empty(t, cfg.MetricsUsername)
|
||||
assert.Empty(t, cfg.MetricsPassword)
|
||||
assert.False(t, cfg.SendTestNotification)
|
||||
assert.Empty(t, cfg.SkipRecordNotifications)
|
||||
}
|
||||
|
||||
func TestNew_EnvironmentOverrides(t *testing.T) {
|
||||
@@ -235,6 +236,33 @@ func TestNew_TargetsWithTrailingComma(t *testing.T) {
|
||||
"trailing comma should be ignored")
|
||||
}
|
||||
|
||||
func TestNew_SkipRecordNotifications(t *testing.T) {
|
||||
viper.Reset()
|
||||
t.Setenv("DNSWATCHER_TARGETS", "example.net,www.example.net,example.org")
|
||||
t.Setenv("DNSWATCHER_SKIP_RECORD_NOTIFICATIONS",
|
||||
" WWW.Example.net. , example.net,www.example.net")
|
||||
|
||||
cfg, err := config.New(nil, newTestParams(t))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t,
|
||||
[]string{"www.example.net", "example.net"},
|
||||
cfg.SkipRecordNotifications,
|
||||
"names are written as targets are, each once",
|
||||
)
|
||||
}
|
||||
|
||||
func TestNew_SkipRecordNotificationsNotInTargetsStopsStartup(t *testing.T) {
|
||||
viper.Reset()
|
||||
t.Setenv("DNSWATCHER_TARGETS", "example.net")
|
||||
t.Setenv("DNSWATCHER_SKIP_RECORD_NOTIFICATIONS",
|
||||
"example.net,www.example.net")
|
||||
|
||||
_, err := config.New(nil, newTestParams(t))
|
||||
require.ErrorIs(t, err, config.ErrNotInTargets)
|
||||
require.ErrorContains(t, err, "DNSWATCHER_SKIP_RECORD_NOTIFICATIONS")
|
||||
require.ErrorContains(t, err, `"www.example.net"`)
|
||||
}
|
||||
|
||||
func TestNew_CustomDNSIntervalDuration(t *testing.T) {
|
||||
viper.Reset()
|
||||
t.Setenv("DNSWATCHER_TARGETS", "example.com")
|
||||
|
||||
Reference in New Issue
Block a user