more
Build and Publish / Metadata (push) Successful in 2s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m31s

This commit is contained in:
mats committed 2026-09-19 20:14:51 +02:00
1 parent 2237fbda55
commit 5076036709
11 files changed
+299 -8

No files matched your search

+17
View File
@@ -39,3 +39,20 @@ func TestHandleIPsRequiresToken(t *testing.T) {
t.Fatalf("got %d and %q", recorder.Code, recorder.Body.String())
}
}
func TestRecordTelemetryPromotesTheObservedSourceIP(t *testing.T) {
tracker := New(Config{Threshold: 2, TTL: time.Minute})
if tracker.RecordTelemetry("203.0.113.20", "/mail.php") {
t.Fatal("must not promote before threshold")
}
if !tracker.RecordTelemetry("203.0.113.20", "/settings.php") {
t.Fatal("must promote at threshold")
}
if tracker.RecordTelemetry("203.0.113.20", "/index.html") {
t.Fatal("normal paths must not be tracked")
}
ips := tracker.PromotedIPs()
if len(ips) != 1 || ips[0].Address != "203.0.113.20" {
t.Fatalf("unexpected promoted IPs: %+v", ips)
}
}