修复显示问题

This commit is contained in:
2026-03-28 18:03:13 +08:00
parent e5611df24e
commit b66ba41431
11 changed files with 139 additions and 27 deletions

View File

@@ -114,6 +114,26 @@ func TestTransferStatusUpdateRequiresParticipantOwnership(t *testing.T) {
}
}
func TestProtectedRoutesAcceptDeviceCredentialsFromCookies(t *testing.T) {
router, _ := newTestRouter()
device := registerDevice(t, router, map[string]any{
"device_id": "cookie-device",
"name": "Cookie Device",
"type": "desktop",
})
req := httptest.NewRequest(http.MethodGet, "/api/devices/candidates?deviceId="+device.ID, nil)
req.AddCookie(&http.Cookie{Name: deviceIDCookieName, Value: device.ID})
req.AddCookie(&http.Cookie{Name: deviceTokenCookieName, Value: device.AuthToken})
resp := httptest.NewRecorder()
router.ServeHTTP(resp, req)
if resp.Code != http.StatusOK {
t.Fatalf("expected cookie-authenticated request to succeed, got %d: %s", resp.Code, resp.Body.String())
}
}
func newTestRouter() (http.Handler, *store.MemoryStore) {
memStore := store.NewMemoryStore(model.RuntimeConfig{})
logger := slog.New(slog.NewTextHandler(io.Discard, nil))