feat: Telegram fleet alerts, forge sigil scramble, UI polish, agent ops
- Calibrate: per-event Telegram/SMTP toggles, test notification, chat ID help - Notify on agent connect/reconnect, offline/hashrate/rejection, forge complete - Sigil scramble post-forge uniquification and Dispense Reveal ceremony - Full system check, desktop push, BITS/host-binary persistence, Path Tracer - Dashboard/Crucible visual polish, haptics, sacred geometry, mobile nav - README documents alerts, sigil scramble, and pack-usb workflow - USB bundle repacked via pack-usb.bat (AetherForge.exe + synced agent source)
This commit is contained in:
@@ -64,7 +64,7 @@ func newTestFleetHandler(t *testing.T) (*FleetHandler, *db.Database, *WSHub, *AI
|
||||
t.Cleanup(func() { _ = database.Close() })
|
||||
ws := NewWSHub(database)
|
||||
ai := NewAIHandler(database)
|
||||
fh := NewFleetHandler(database, ws, ai, nil, nil, pool.Config{})
|
||||
fh := NewFleetHandler(database, ws, ai, nil, nil, pool.Config{}, "")
|
||||
return fh, database, ws, ai
|
||||
}
|
||||
|
||||
@@ -182,10 +182,10 @@ func TestFleetGetAlertsWithEvaluator(t *testing.T) {
|
||||
|
||||
evaluator := alerts.NewEvaluator(database, func() alerts.Thresholds {
|
||||
return alerts.Thresholds{OfflineMinutes: 5}
|
||||
}, func() alerts.NotifyConfig { return alerts.NotifyConfig{} }, nil)
|
||||
}, func() alerts.Settings { return alerts.NewSettings(alerts.NotifyConfig{}, alerts.EventToggles{}) }, nil)
|
||||
evaluator.RunOnce()
|
||||
|
||||
fh := NewFleetHandler(database, NewWSHub(database), NewAIHandler(database), nil, evaluator, pool.Config{})
|
||||
fh := NewFleetHandler(database, NewWSHub(database), NewAIHandler(database), nil, evaluator, pool.Config{}, "")
|
||||
rec := httptest.NewRecorder()
|
||||
fh.GetAlerts(rec, httptest.NewRequest(http.MethodGet, "/alerts", nil))
|
||||
if rec.Code != http.StatusOK {
|
||||
@@ -200,6 +200,48 @@ func TestFleetGetAlertsWithEvaluator(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFleetPostAlertTestUnconfigured(t *testing.T) {
|
||||
evaluator := alerts.NewEvaluator(nil, func() alerts.Thresholds { return alerts.Thresholds{} },
|
||||
func() alerts.Settings { return alerts.NewSettings(alerts.NotifyConfig{}, alerts.EventToggles{}) }, nil)
|
||||
fh := NewFleetHandler(nil, NewWSHub(nil), NewAIHandler(nil), nil, evaluator, pool.Config{}, "")
|
||||
rec := httptest.NewRecorder()
|
||||
fh.PostAlertTest(rec, httptest.NewRequest(http.MethodPost, "/alerts/test", nil))
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status %d", rec.Code)
|
||||
}
|
||||
var body map[string]struct {
|
||||
Sent bool `json:"sent"`
|
||||
Error *string `json:"error"`
|
||||
}
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["telegram"].Sent || body["smtp"].Sent {
|
||||
t.Fatalf("expected no sends, got %+v", body)
|
||||
}
|
||||
if body["telegram"].Error == nil || *body["telegram"].Error != "not configured" {
|
||||
t.Fatalf("telegram: %+v", body["telegram"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestFleetPostAlertTestNilEvaluator(t *testing.T) {
|
||||
fh, _, _, _ := newTestFleetHandler(t)
|
||||
rec := httptest.NewRecorder()
|
||||
fh.PostAlertTest(rec, httptest.NewRequest(http.MethodPost, "/alerts/test", nil))
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status %d", rec.Code)
|
||||
}
|
||||
var body map[string]struct {
|
||||
Error *string `json:"error"`
|
||||
}
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["telegram"].Error == nil || *body["telegram"].Error != "alert evaluator not configured" {
|
||||
t.Fatalf("got %+v", body["telegram"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestFleetGetPoolStatusNilManager(t *testing.T) {
|
||||
fh, _, _, _ := newTestFleetHandler(t)
|
||||
rec := httptest.NewRecorder()
|
||||
@@ -556,7 +598,7 @@ func TestFleetPostAgentCommandErrors(t *testing.T) {
|
||||
fh, _, ws, _ := newTestFleetHandler(t)
|
||||
|
||||
t.Run("nil ws", func(t *testing.T) {
|
||||
bad := NewFleetHandler(fh.db, nil, fh.ai, fh.pools, fh.alerts, fh.defaultPool)
|
||||
bad := NewFleetHandler(fh.db, nil, fh.ai, fh.pools, fh.alerts, fh.defaultPool, "")
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodPost, "/agents/a1/command", strings.NewReader(`{"action":"pause"}`))
|
||||
fleetChiRoute(http.MethodPost, "/agents/{id}/command", bad.PostAgentCommand).ServeHTTP(rec, req)
|
||||
@@ -736,7 +778,7 @@ func TestFleetPostBulkCommandErrors(t *testing.T) {
|
||||
fh, _, _, _ := newTestFleetHandler(t)
|
||||
|
||||
t.Run("nil ws", func(t *testing.T) {
|
||||
bad := NewFleetHandler(fh.db, nil, fh.ai, fh.pools, fh.alerts, fh.defaultPool)
|
||||
bad := NewFleetHandler(fh.db, nil, fh.ai, fh.pools, fh.alerts, fh.defaultPool, "")
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodPost, "/agents/bulk-command",
|
||||
strings.NewReader(`{"agent_ids":["a"],"action":"pause"}`))
|
||||
|
||||
Reference in New Issue
Block a user