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.
28 lines
1.2 KiB
Go
28 lines
1.2 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
|
|
)
|
|
|
|
// R-1218 (hub half, the upload): an escrow PUT sealing no off-site password over a package that seals one is answered
|
|
// 409 with a sentence naming why — never „Internal error" — and the good package stays current.
|
|
// COMPANION RED-PROOF: without the errors.Is branch the handler answers 500.
|
|
func TestR1218_TheEscrowPutRefusesToDropTheRepoKey(t *testing.T) {
|
|
h, st, _ := newTestHandler(t)
|
|
st.UpsertHost(&store.Host{HostID: "h1", CustomerID: "c1", APIKey: "HKEY"})
|
|
if rr := do(h, http.MethodPut, "/hosts/h1/escrow", "HKEY", escrowBodyWithHash([]byte("good"), "SHA_GOOD", "")); rr.Code != http.StatusOK {
|
|
t.Fatalf("first PUT = %d", rr.Code)
|
|
}
|
|
rr := do(h, http.MethodPut, "/hosts/h1/escrow", "HKEY", escrowBodyWithHash([]byte("keyless"), "", ""))
|
|
if rr.Code != http.StatusConflict || !strings.Contains(rr.Body.String(), "off-site") {
|
|
t.Fatalf("a key-less PUT over a keyed package = %d %q, want 409 naming the off-site key", rr.Code, rr.Body.String())
|
|
}
|
|
if cur, _ := st.GetHostEscrow("h1"); cur == nil || string(cur.Blob) != "good" {
|
|
t.Fatalf("the good package is not current: %+v", cur)
|
|
}
|
|
}
|