Artifact f00fd11fc1a5f4593e4003e6793df3aca027f281c34060317d2190337d8ccaa8:
- File
internal/sync/shun_send_wire_test.go
— part of check-in
[a402aa5cc6]
at
2026-10-21 01:03:53
on branch feat/submanifest-reader
— fix(sync): withhold shunned payloads and clone delta bases
Match Fossil 2.28 send_file and send_compressed_file payload gates. A source-first clone must expand a dependent when its stored basis is shunned rather than forwarding that withheld basis. Preserve private notices, authorization and SHA3 refusal ordering.
Exercise real encoded requests through the ordinary handler and Fossil HTTP oracle. Canonical compressed clone can name a shunned public basis without sending it; this server expands instead to preserve its source-first guarantee. (user: [email protected], size: 1902) [annotate] [blame] [check-ins using] [more...]
package sync import ( "context" "testing" "github.com/danmestas/go-libfossil/internal/repo" "github.com/danmestas/go-libfossil/internal/xfer" ) func shunWireRound(t *testing.T, r *repo.Repo, cards []xfer.Card) *xfer.Message { t.Helper() wire, err := (&xfer.Message{Cards: cards}).Encode() if err != nil { t.Fatal(err) } req, err := xfer.Decode(wire, xfer.ContentTypeCompressed) if err != nil { t.Fatal(err) } resp, err := HandleSync(context.Background(), r, req) if err != nil { t.Fatal(err) } wire, err = resp.Encode() if err != nil { t.Fatal(err) } resp, err = xfer.Decode(wire, xfer.ContentTypeCompressed) if err != nil { t.Fatal(err) } return resp } // Shun enforcement must not weaken either the ordinary private boundary or // the requirement for an authorized pull/clone before answering a gimme. func TestShunSendPreservesAuthorization(t *testing.T) { for _, requested := range []bool{false, true} { r, baseUUID, targetUUID := shunSendFixture(t, true) resp := shunWireRound(t, r, shunSendCards(false, requested, baseUUID, targetUUID)) assertShunSend(t, resp, baseUUID, targetUUID) resp = shunWireRound(t, r, []xfer.Card{&xfer.GimmeCard{UUID: targetUUID}}) if shunHasFile(resp, targetUUID) { t.Fatal("gimme without authorized pull disclosed content") } _, err := r.DB().Exec("UPDATE user SET cap='' WHERE login IN ('nobody','anonymous')") if err != nil { t.Fatal(err) } resp = shunWireRound(t, r, shunSendCards(false, requested, baseUUID, targetUUID)) if shunHasFile(resp, targetUUID) { t.Fatal("unauthorized clone/pull disclosed content") } } } func shunHasFile(resp *xfer.Message, uuid string) bool { for _, card := range resp.Cards { switch c := card.(type) { case *xfer.FileCard: if c.UUID == uuid { return true } case *xfer.CFileCard: if c.UUID == uuid { return true } } } return false }