hub(R-1218): never replace a recovery package that seals the off-site key with one that seals none (409)
gates / gates (push) Successful in 1m54s

SaveHostEscrowWithIdentity refuses (ErrEscrowWouldDropRepoKey); the PUT answers 409. Red-proved (store: superseded=true;
API: 500). Two older tests pinned the old demotion and are updated. Commit only.
This commit is contained in:
admin committed 2026-10-26 20:21:08 +01:00
1 parent 99c0f5e310
commit 09b5f02fc3
7 files changed
+102 -13

No files matched your search

+5 -3
View File
@@ -128,11 +128,13 @@ func TestHandleHostEscrow_StoresResticPwHash(t *testing.T) {
if got.ResticPwSHA256 != "dbfc02f987e1ac0c91911d5761267089b1144628745a3343e4d96194e43c08e4" {
t.Fatalf("hash not stored: %q", got.ResticPwSHA256)
}
// legacy upload without the field → stored empty, read back NULL-safe as ""
if rr := do(h, http.MethodPut, "/hosts/h1/escrow", "HKEY", escrowBody([]byte("legacy"))); rr.Code != http.StatusOK {
// legacy upload without the field → stored empty, read back NULL-safe as "" (on a host whose package has no hash;
// over a hashed package a hash-less upload is refused since R-1218 — TestR1218_TheEscrowPutRefusesToDropTheRepoKey)
st.UpsertHost(&store.Host{HostID: "h2", CustomerID: "c2", APIKey: "HKEY2"})
if rr := do(h, http.MethodPut, "/hosts/h2/escrow", "HKEY2", escrowBody([]byte("legacy"))); rr.Code != http.StatusOK {
t.Fatalf("legacy PUT = %d", rr.Code)
}
got2, err := st.GetHostEscrow("h1")
got2, err := st.GetHostEscrow("h2")
if err != nil || got2.ResticPwSHA256 != "" {
t.Fatalf("legacy upload must read back with an empty hash: %q err=%v", got2.ResticPwSHA256, err)
}