2

Simplify the dashboard recent IP view

This commit is contained in:
2026-03-12 02:15:45 +01:00
parent 7bd3933215
commit a82421ba3f
8 changed files with 404 additions and 57 deletions

View File

@@ -126,6 +126,21 @@ sources:
t.Fatalf("expected observed state, got %+v", observedState)
}
recentRows, err := svc.ListRecentIPs(context.Background(), time.Now().UTC().Add(-time.Hour), 10)
if err != nil {
t.Fatalf("list recent ips: %v", err)
}
blockedRow, found := findRecentIPRow(recentRows, "203.0.113.10")
if !found {
t.Fatalf("expected blocked IP row in recent rows: %+v", recentRows)
}
if blockedRow.SourceName != "main" || blockedRow.Events != 1 {
t.Fatalf("unexpected blocked recent row: %+v", blockedRow)
}
if !blockedRow.Actions.CanUnblock || blockedRow.Actions.CanBlock {
t.Fatalf("unexpected blocked recent row actions: %+v", blockedRow.Actions)
}
if err := svc.ForceAllow(context.Background(), "203.0.113.10", "test", "manual unblock"); err != nil {
t.Fatalf("force allow: %v", err)
}
@@ -245,3 +260,12 @@ func waitFor(t *testing.T, timeout time.Duration, condition func() bool) {
}
t.Fatalf("condition was not met within %s", timeout)
}
func findRecentIPRow(items []model.RecentIPRow, ip string) (model.RecentIPRow, bool) {
for _, item := range items {
if item.IP == ip {
return item, true
}
}
return model.RecentIPRow{}, false
}