The UI had no way to add a device. Adds an admin-only Add device dialog
(IPv6/IPv4 addresses, SNMP v1/v2c/v3, synchronous discovery, reattach 409
flow) and a device-page Actions menu (Edit with parents and SNMP
replacement, Rediscover now, Retire). Purge now requires typing the name.
API: POST /api/v1/devices/{slug}/retire (admin, audited, 409 if already
retired). OpenAPI change is additive.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lx9FNLG2CqeBbVGGd9bFsP
25 lines
678 B
Go
25 lines
678 B
Go
package api_test
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
func TestRetireDevice(t *testing.T) {
|
|
e := newEnv(t, 0)
|
|
d := e.device(t, "Old Box", "", "")
|
|
rec := e.do("POST", "/api/v1/devices/"+d.Slug+"/retire", "")
|
|
if rec.Code != http.StatusOK {
|
|
t.Fatalf("retire: %d %s", rec.Code, rec.Body)
|
|
}
|
|
got, err := e.st.GetDeviceBySlug(t.Context(), d.Slug)
|
|
if err != nil || got.RetiredAt == nil {
|
|
t.Fatalf("not retired: %+v %v", got, err)
|
|
}
|
|
if e.ref.n.Load() == 0 {
|
|
t.Error("poller was not refreshed")
|
|
}
|
|
isProblem(t, e.do("POST", "/api/v1/devices/"+d.Slug+"/retire", ""), http.StatusConflict)
|
|
isProblem(t, e.do("POST", "/api/v1/devices/nope/retire", ""), http.StatusNotFound)
|
|
}
|