feat: expand companion platform, device controls, and memoir workflows
ci / verify (push) Canceled after 0s

Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
This commit is contained in:
Codex Local
2026-10-08 10:06:44 +08:00
parent 98fb2965d0
commit bf1233d5df
861 changed files with 94614 additions and 3209 deletions
+60
View File
@@ -0,0 +1,60 @@
package onboarding
import (
"data-terminal-cloud/internal/identity"
"github.com/google/uuid"
"testing"
)
func TestBLEPlaintextBindingState(t *testing.T) {
f := newFixture(t)
in := BLEDeviceInput{DeviceID: f.d.FactoryID}
state, err := f.s.BLEDeviceState(f.ctx, f.user, in)
must(t, err)
if state["bound"] != false || state["id"] != f.d.PublicID {
t.Fatal(state)
}
device, err := f.s.DeviceBLEState(f.ctx, f.d)
must(t, err)
if device["bound"] != false {
t.Fatal(device)
}
_, err = f.s.BindBLE(f.ctx, f.d, uuid.NewString(), BLEBindInput{Token: ""})
if err == nil {
t.Fatal("empty token must not create a binding")
}
_, err = f.s.BLEDeviceState(f.ctx, identity.Principal{Issuer: f.user.Issuer, Subject: uuid.NewString()}, in)
if err == nil {
t.Fatal("unrelated account read binding state")
}
token := f.bleToken()
_, err = f.s.BindBLE(f.ctx, f.d, uuid.NewString(), BLEBindInput{Token: token})
must(t, err)
f.refresh()
generation := f.d.Generation
state, err = f.s.BLEDeviceState(f.ctx, f.user, in)
must(t, err)
if state["bound"] != true {
t.Fatal(state)
}
for i := 0; i < 3; i++ {
device, err = f.s.DeviceBLEState(f.ctx, f.d)
must(t, err)
if device["bound"] != true {
t.Fatal(device)
}
}
f.refresh()
if f.d.Generation != generation {
t.Fatal("WiFi checks modified ownership")
}
_, err = f.s.pool.Exec(f.ctx, `UPDATE device_binding SET unbound_at=now() WHERE device_id=$1::uuid AND unbound_at IS NULL`, f.d.ID)
must(t, err)
f.web.Hash = "" // Unbinding intentionally expires the fixture's old setup session.
f.refresh()
device, err = f.s.DeviceBLEState(f.ctx, f.d)
must(t, err)
if device["bound"] != false {
t.Fatal("stale bound state after unbind", device)
}
}