checker-blacklist/checker/source_test.go
Pierre-Olivier Mercier 219d9353c3
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Add Quad9 secure DNS blocklist source
Detects domains blocked by Quad9's threat intelligence by comparing
the secure resolver (9.9.9.9) against the unsecured peer (9.9.9.10).
No API key required; enabled by default via the enable_quad9 user option.
2026-05-16 11:00:50 +08:00

40 lines
1,004 B
Go

package checker
import (
"testing"
)
// TestRegisteredSourcesAreSane is a smoke test that runs over every
// init()-registered source and verifies basic invariants. New sources
// added later are picked up automatically.
func TestRegisteredSourcesAreSane(t *testing.T) {
seen := map[string]bool{}
for _, s := range Sources() {
if s.ID() == "" || s.Name() == "" {
t.Errorf("source has empty ID or Name: %+v", s)
}
if seen[s.ID()] {
t.Errorf("duplicate source ID: %s", s.ID())
}
seen[s.ID()] = true
o := s.Options()
for _, f := range append(append([]any{}, toAny(o.Admin)...), toAny(o.User)...) {
_ = f
}
}
// At least the built-in sources are present.
for _, want := range []string{"dnsbl", "google_safe_browsing", "openphish", "pulsedive", "quad9", "urlhaus", "virustotal"} {
if !seen[want] {
t.Errorf("missing built-in source %q", want)
}
}
}
func toAny[T any](in []T) []any {
out := make([]any, len(in))
for i, v := range in {
out[i] = v
}
return out
}