package web import ( "net/http" "net/http/httptest" "strings" "testing" "gitea.dooplex.hu/admin/felhom-hub/internal/store" ) // felhom.eu architecture/16-storage-physical-identity.md §3 (agent v0.157.0): the host page shows, per // storage place, the physical disk keys and whether the agent proved them. Shown only — no alarm (build A). func TestHostDetail_ShowsPhysicalDiskIdentity(t *testing.T) { s, st := newTestServer(t) if err := st.UpsertHost(&store.Host{HostID: "h1", CustomerID: "c1", APIKey: "k"}); err != nil { t.Fatal(err) } report := `{"host_id":"h1","agent_version":"0.157.0","storage_targets":[` + `{"name":"local-lvm","type":"lvmthin","state":"attached","kind":"system","physical_disks":["serial:ata:SanDisk_X600:182195804614"],"identity":"proven","smart":{"health":"UNKNOWN"}},` + `{"name":"felhom-usb","type":"usb","state":"attached","kind":"disk","physical_disks":["serial:scsi:QEMU_HARDDISK:drive-scsi1"],"identity":"unknown","identity_reason":"vm","smart":{"health":"UNKNOWN"}},` + `{"name":"old-agent","type":"local","state":"attached","smart":{"health":"UNKNOWN"}}]}` if err := st.SaveHostReport("h1", "c1", []byte(report), store.HostReportDenorm{AgentVersion: "0.157.0"}); err != nil { t.Fatal(err) } rr := httptest.NewRecorder() s.handleHostDetail(rr, httptest.NewRequest(http.MethodGet, "/hosts/h1", nil), "h1") if rr.Code != http.StatusOK { t.Fatalf("status = %d", rr.Code) } body := rr.Body.String() for _, want := range []string{"Physical disk", "serial:ata:SanDisk_X600:182195804614", ">proven<", "unknown (vm)", "· system", "· disk"} { if !strings.Contains(body, want) { t.Errorf("host page missing %q", want) } } v := parseHostStorageTargets(report) if len(v) != 3 || v[0].Identity != "proven" || v[1].IdentityReason != "vm" || v[2].Identity != "" { t.Errorf("parsed identity rows wrong: %+v", v) } }