Artifact 93cb5ea6a78e12f48018fc12156ebbe1c59b4052a96433942b5c0483db71cf40:
- File
internal/sync/uv_realfossil_test.go
— part of check-in
[b45ccf4351]
at
2026-10-12 22:52:57
on branch main
— fix(sync): take a uvfile on y alone, without a push card (#296) (#354)
fossil's page_xfer accepts a uvfile on the unversioned-write capability (WrUnver, y) alone; `fossil uv sync` sends uvfile cards with no push card. The handler refused each with "rejected: no push card", so pushing unversioned files from fossil to a go-libfossil server stored nothing.
This is an access change: a requester with y and no Write may now store unversioned files, as in fossil. A refusal (no y, or a HASH that does not match the content) now resets the reply, answers the error and breaks out of the card loop, as xfer_accept_unversioned_file's caller does. Tests pin both sides of the gate, and an interop test pushes with fossil uv sync. The real-fossil test helper now points HOME and XDG_CONFIG_HOME, not only FOSSIL_HOME, at the test's directory. (user: [email protected], size: 1965) [annotate] [blame] [check-ins using]
package sync_test import ( "context" "net/url" "os" "path/filepath" "testing" "github.com/danmestas/go-libfossil/internal/auth" "github.com/danmestas/go-libfossil/internal/repo" "github.com/danmestas/go-libfossil/internal/uv" "github.com/danmestas/go-libfossil/simio" "github.com/danmestas/go-libfossil/testutil" ) // TestRealFossilUVSyncPushesWithoutPushCard checks that `fossil uv sync`, // which sends uvfile cards with no push card, stores its file on the server // for a user who may write unversioned files (ยง7.3). func TestRealFossilUVSyncPushesWithoutPushCard(t *testing.T) { bin := testutil.RequireFossilBin(t) dir := t.TempDir() srv, err := repo.Create(filepath.Join(dir, "server.fossil"), "testuser", simio.CryptoRand{}, "") if err != nil { t.Fatalf("repo.Create: %v", err) } defer srv.Close() ctx, cancel := context.WithCancel(context.Background()) defer cancel() base := serveRepo(ctx, t, srv) clonePath := filepath.Join(dir, "clone.fossil") fossilOK(t, bin, dir, "clone", base, clonePath) var pc string if err := srv.DB().QueryRow( "SELECT value FROM config WHERE name='project-code'").Scan(&pc); err != nil { t.Fatalf("project-code: %v", err) } if err := auth.CreateUser(srv.DB(), pc, "alice", "pw123", "oiy"); err != nil { t.Fatalf("CreateUser: %v", err) } u, err := url.Parse(base) if err != nil { t.Fatalf("parse %s: %v", base, err) } u.User = url.UserPassword("alice", "pw123") file := filepath.Join(dir, "f.txt") if err := os.WriteFile(file, []byte("unversioned\n"), 0o644); err != nil { t.Fatal(err) } fossilOK(t, bin, dir, "uv", "add", file, "--as", "f.txt", "-R", clonePath) fossilOK(t, bin, dir, "uv", "sync", u.String(), "-R", clonePath) content, _, _, err := uv.Read(srv.DB(), "f.txt") if err != nil { t.Fatalf("uv.Read: %v", err) } if string(content) != "unversioned\n" { t.Fatalf("server holds f.txt as %q after fossil uv sync, want %q", content, "unversioned\n") } }