Registry: trend chart, always-pass indicator, subnet columns in the address list dialog
- Registry: "Динамика по запускам" chart (Chart.js 4.5.1, vendored) over finalized runs per target or site, % or count, subnet and calendar period filters; GET /admin/registry/trend - Registry: clickable "Всегда проходили" indicator with the address list and CSV; GET /admin/registry/always-pass and /always-pass/list - Address list dialog: "Подсеть" and "Метка подсети" columns from the administrator's subnet list (shared db.SubnetMatcher), per-subnet summary chips with a client-side filter; "прочие" renamed to "вне списка подсетей" - Rebuild control-api and admin-dashboard binaries; plans and summaries in docs/changes, README, API and USAGE updated Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c13139cd41
commit
1536723196
50 files changed
+3560
-154
No files matched your search
@@ -612,3 +612,82 @@ func TestRegistryBreakdownChartAndProxy(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The trend chart of /registry: its frame is on the page only with a direction
|
||||
// and carries the period; the data block is a separate request that passes just
|
||||
// the subnet, direction, protocol and period to control-api.
|
||||
func TestRegistryTrendBlock(t *testing.T) {
|
||||
fake, ts := analyticsFake(t)
|
||||
now := time.Now().UTC()
|
||||
fake.trend = registryTrend{Group: "target", Runs: []trendRun{{ID: 4, StartedAt: now, Addresses: 3}, {ID: 5, StartedAt: now, Addresses: 3}},
|
||||
Series: []trendSeries{{Key: "https://a.test", Label: "a.test", Points: []trendPoint{{RunID: 5, Total: 3, OK: 2}}}}}
|
||||
|
||||
page := get(t, ts, "/registry?direction=egress&protocol=https&subnet=9.9.9.0/24&trend_from=2026-09-01&trend_view=count&run=1&q=9")
|
||||
for _, want := range []string{`id="registry-trend-panel"`, "Динамика по запускам · Egress · https", `value="2026-09-01"`, `name="trend_view" value="count"`,
|
||||
`hx-get="/registry/trend?direction=egress&protocol=https&subnet=9.9.9.0%2F24&trend_from=2026-09-01"`} {
|
||||
if !strings.Contains(page, want) {
|
||||
t.Errorf("expected %q in the page", want)
|
||||
}
|
||||
}
|
||||
if strings.Contains(get(t, ts, "/registry?protocol=https"), `id="registry-trend-panel"`) {
|
||||
t.Error("no trend frame without a direction")
|
||||
}
|
||||
|
||||
frag := get(t, ts, "/registry/trend?direction=egress&protocol=https&run=1&q=9&trend_to=2026-09-30&trend_to_x=1")
|
||||
if !strings.Contains(frag, `data-trend="`) || !strings.Contains(frag, "a.test") || !strings.Contains(frag, "2 из 3") {
|
||||
t.Errorf("fragment lacks the data: %s", frag)
|
||||
}
|
||||
fake.mu.Lock()
|
||||
req := fake.trendReqs[len(fake.trendReqs)-1]
|
||||
fake.mu.Unlock()
|
||||
if !strings.Contains(req, "direction=egress") || !strings.Contains(req, "to=2026-09-30") || strings.Contains(req, "run=") || strings.Contains(req, "q=") {
|
||||
t.Errorf("trend request %q", req)
|
||||
}
|
||||
if frag = get(t, ts, "/registry/trend?protocol=https"); strings.Contains(frag, "data-trend") || !strings.Contains(frag, "Выберите направление") {
|
||||
t.Errorf("no direction: %s", frag)
|
||||
}
|
||||
}
|
||||
|
||||
// The "always passed" tile of /registry: its slot is in the trend frame only
|
||||
// with a direction; the fragment is a button with the numbers, passes the
|
||||
// search and the period to control-api (not the run or the status), and the
|
||||
// list and CSV proxies need a direction.
|
||||
func TestRegistryAlwaysPassTile(t *testing.T) {
|
||||
fake, ts := analyticsFake(t)
|
||||
first, last := time.Date(2026, 9, 1, 10, 0, 0, 0, time.UTC), time.Date(2026, 9, 30, 10, 0, 0, 0, time.UTC)
|
||||
fake.alwaysPass = registryAlwaysPass{Runs: 22, FirstRunAt: &first, LastRunAt: &last, Addresses: 8, AlwaysPass: 3}
|
||||
|
||||
page := get(t, ts, "/registry?direction=egress&protocol=https&q=9&trend_from=2026-09-01")
|
||||
if !strings.Contains(page, `hx-get="/registry/always-pass?direction=egress&protocol=https&q=9&trend_from=2026-09-01"`) {
|
||||
t.Errorf("no tile slot in the page")
|
||||
}
|
||||
if strings.Contains(get(t, ts, "/registry?protocol=https"), `id="registry-always-pass"`) {
|
||||
t.Error("no tile slot without a direction")
|
||||
}
|
||||
|
||||
frag := get(t, ts, "/registry/always-pass?direction=egress&protocol=https&q=9&run=1&status=fail&trend_from=2026-09-01")
|
||||
for _, want := range []string{`class="ap-tile"`, `aria-label="Всегда проходили: 3 из 8 адресов, 37,5 %`, "из 8 адресов · 37,5 %", "за 22 запуска, 2026-09-01 — 2026-09-30", `data-ap-qs="`} {
|
||||
if !strings.Contains(frag, want) {
|
||||
t.Errorf("expected %q in %s", want, frag)
|
||||
}
|
||||
}
|
||||
fake.mu.Lock()
|
||||
req := fake.alwaysPassReqs[len(fake.alwaysPassReqs)-1]
|
||||
fake.mu.Unlock()
|
||||
if !strings.Contains(req, "q=9") || !strings.Contains(req, "from=2026-09-01") || strings.Contains(req, "run=") || strings.Contains(req, "last_result") {
|
||||
t.Errorf("always-pass request %q", req)
|
||||
}
|
||||
if frag = get(t, ts, "/registry/always-pass?protocol=https"); strings.Contains(frag, "ap-tile") || !strings.Contains(frag, "Выберите направление") {
|
||||
t.Errorf("no direction: %s", frag)
|
||||
}
|
||||
|
||||
if body := get(t, ts, "/registry/always-pass/list?direction=egress&protocol=https&trend_to=2026-09-30"); !strings.Contains(body, "1.2.3.4") {
|
||||
t.Errorf("list proxy: %s", body)
|
||||
}
|
||||
if body := get(t, ts, "/registry/always-pass/csv?direction=egress&protocol=https"); !strings.Contains(body, "1.2.3.4") {
|
||||
t.Errorf("csv proxy: %s", body)
|
||||
}
|
||||
if resp, err := http.Get(ts.URL + "/registry/always-pass/list?protocol=https"); err != nil || resp.StatusCode != http.StatusBadRequest {
|
||||
t.Errorf("list without a direction: %v %v", resp, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user