| index bad8924..69478ee 100644 |
| --- a/internal/docs/suite_test.go |
| +++ b/internal/docs/suite_test.go |
| @@ -13,16 +13,22 @@ import ( |
| "strconv" |
| "strings" |
| "testing" |
| + "testing/fstest" |
| "time" |
| |
| "amadan.net/oficina/home/connect" |
| connectlinks "amadan.net/oficina/home/connect/linkstore" |
| + "amadan.net/oficina/home/dashboard" |
| + "amadan.net/oficina/home/handoff" |
| "amadan.net/oficina/home/roster" |
| "amadan.net/oficina/suite" |
| "amadan.net/oficina/suite/conformance" |
| "amadan.net/oficina/suite/server" |
| "amadan.net/rastrillo/rastrillo" |
| + "amadan.net/rastrillo/rastrillo/db" |
| "amadan.net/rastrillo/rastrillo/migrate" |
| + "amadan.net/rastrillo/rastrillo/sessions" |
| + "github.com/carlosframework/docs/internal/docs/linkstore" |
| "gorm.io/gorm" |
| ) |
| |
| @@ -37,18 +43,26 @@ func suiteVector(t *testing.T, id string) []byte { |
| return b |
| } |
| |
| -// setRevision puts a document at the fixture's revision and announces it, |
| -// as a bump would. The fixture numbers its revisions 2 to 11, and real bumps |
| -// jump to the clock (bumpRevision), so the world is seeded at the fixture's |
| -// numbers directly: the producer reads documents.revision and suite_feed and |
| -// does not care how they got there. |
| +// setRevision puts a document at the fixture's revision, with the revision |
| +// before it in its history: both are announced, as two bumps would be. The |
| +// fixture numbers its revisions 2 to 11 and real bumps are random |
| +// (newRevision), so the world is seeded at the fixture's numbers directly; |
| +// the producer reads documents.revision and suite_feed and does not care how |
| +// they got there. revision - 1 being in the log is what makes the harness's |
| +// "one behind" STALE (Docs decides STALE from its log), and revision + 1 |
| +// never being announced is what makes "one ahead" UNKNOWN. |
| func setRevision(t *testing.T, s *Store, docID, revision int64) { |
| t.Helper() |
| err := s.db.Transaction(func(tx *gorm.DB) error { |
| - if err := tx.Model(&Document{}).Where("id = ?", docID).UpdateColumn("revision", revision).Error; err != nil { |
| - return err |
| + for _, r := range []int64{revision - 1, revision} { |
| + if err := tx.Model(&Document{}).Where("id = ?", docID).UpdateColumn("revision", r).Error; err != nil { |
| + return err |
| + } |
| + if err := announce(tx, docID, r, false); err != nil { |
| + return err |
| + } |
| } |
| - return announce(tx, docID, revision, false, time.Now().UTC()) |
| + return nil |
| }) |
| if err != nil { |
| t.Fatal(err) |
| @@ -136,8 +150,8 @@ func seedCustody(t *testing.T, s *Store, asker, other custodyParty) { |
| } |
| } |
| if c.Rung == suite.RungDeleted { |
| - // Deleted through the real path; its last revision is the |
| - // clock's, which nothing asks about: a deleted item is |
| + // Deleted through the real path; its last revision is a |
| + // random one, which nothing asks about: a deleted item is |
| // NOT_VISIBLE and refused at every revision. |
| setRevision(t, s, doc.ID, c.Revision-1) |
| if err := s.deleteDocument(ctx, doc.ID); err != nil { |
| @@ -277,8 +291,8 @@ func TestSuiteNewDocumentsAreTeamAndExistingArePrivate(t *testing.T) { |
| if err := app.store.db.Where("sqid = ?", strings.TrimPrefix(rec.Header().Get("Location"), "/d/")).First(&doc).Error; err != nil { |
| t.Fatal(err) |
| } |
| - if doc.Visibility != VisibilityTeam || doc.Revision < time.Now().Add(-time.Minute).UnixMicro() { |
| - t.Errorf("a new document: %q at revision %d, want team at the clock", doc.Visibility, doc.Revision) |
| + if doc.Visibility != VisibilityTeam || doc.Revision < 1 { |
| + t.Errorf("a new document: %q at revision %d, want team at a positive revision", doc.Visibility, doc.Revision) |
| } |
| |
| samples := newSampleDocumentsInternalTestApp(t, "1") |
| @@ -336,11 +350,17 @@ func TestSuiteNewDocumentsAreTeamAndExistingArePrivate(t *testing.T) { |
| } |
| } |
| exec("0009_suite.sql") |
| - var private, atOne int |
| + var private, distinct, low int |
| db.QueryRow(`SELECT COUNT(*) FROM documents WHERE visibility = 'private'`).Scan(&private) |
| - db.QueryRow(`SELECT COUNT(*) FROM documents WHERE revision = 1`).Scan(&atOne) |
| - if private != 4 || atOne != 4 { |
| - t.Errorf("an existing document: %d of 4 private, %d of 4 at revision 1", private, atOne) |
| + db.QueryRow(`SELECT COUNT(DISTINCT revision) FROM documents`).Scan(&distinct) |
| + db.QueryRow(`SELECT COUNT(*) FROM documents WHERE revision < 1000000`).Scan(&low) |
| + if private != 4 || distinct != 4 || low != 0 { |
| + t.Errorf("an existing document: %d of 4 private, %d distinct revisions, %d small ones; want 4, 4 random, 0", private, distinct, low) |
| + } |
| + var unmatched int |
| + db.QueryRow(`SELECT COUNT(*) FROM suite_feed f JOIN documents d ON d.id = f.document_id WHERE f.revision != d.revision`).Scan(&unmatched) |
| + if unmatched != 0 { |
| + t.Errorf("%d backfilled rows announce a revision their document does not have", unmatched) |
| } |
| rows, err := db.Query(`SELECT document_id, stamp FROM suite_feed ORDER BY id`) |
| if err != nil { |
| @@ -352,8 +372,8 @@ func TestSuiteNewDocumentsAreTeamAndExistingArePrivate(t *testing.T) { |
| var id, stamp int64 |
| rows.Scan(&id, &stamp) |
| fed = append(fed, id) |
| - if stamp < time.Now().Add(-time.Minute).UnixNano() || stamps[stamp] { |
| - t.Errorf("a backfilled stamp that is not the migration's own, distinct time: %d", stamp) |
| + if stamp < 1 || stamps[stamp] { |
| + t.Errorf("a backfilled stamp that is not a distinct positive nonce: %d", stamp) |
| } |
| stamps[stamp] = true |
| } |
| @@ -486,8 +506,8 @@ func TestSuiteTeamRungTeamMode(t *testing.T) { |
| // S1 as Docs serves it: pages in id order, a cursor "<id>.<stamp>", the tip |
| // returning the cursor given with no rows, any cursor Docs did not issue an |
| // error, a row per bump (update, rename, visibility change, deletion) at a |
| -// revision that is the clock's or later and strictly increasing, nothing |
| -// for a grant or an unchanged rung, gone only on deletion. |
| +// fresh positive revision, nothing for a grant or an unchanged rung, gone |
| +// only on deletion. |
| // |
| // MUTATION-TESTED 2026-11-01, each reverted: Rename without bumpRevision, |
| // ApplyUpdate without it, SetVisibility without it, and creation without |
| @@ -513,7 +533,6 @@ func TestSuiteFeed(t *testing.T) { |
| |
| alice := app.TestPerson(t, "alice@example.com") |
| actor := app.TestActorForPerson(t, alice) |
| - before := revisionClock() |
| doc, _ := app.store.Create(ctx, alice, "One") |
| two, _ := app.store.Create(ctx, alice, "Two") |
| revs := []int64{revisionOf(t, app.store, doc.ID)} |
| @@ -539,18 +558,13 @@ func TestSuiteFeed(t *testing.T) { |
| app.TestSoftDelete(t, two.Sqid) |
| twoGone := revisionOf(t, app.store, two.ID) |
| |
| - // Every revision is the clock's or later, and strictly increasing: a |
| - // restore can never hand one out again (bumpRevision). |
| - if revs[0] < before || twoBefore < before { |
| - t.Errorf("a first revision below the clock: %v, %d < %d", revs, twoBefore, before) |
| - } |
| - for k := 1; k < len(revs); k++ { |
| - if revs[k] <= revs[k-1] { |
| - t.Errorf("revisions not strictly increasing: %v", revs) |
| + // Every revision is new: no two the same, none below 1 (newRevision). |
| + seen := map[int64]bool{} |
| + for _, r := range append(revs, twoBefore, twoGone) { |
| + if r < 1 || seen[r] { |
| + t.Errorf("revisions not fresh and positive: %v, %d, %d", revs, twoBefore, twoGone) |
| } |
| - } |
| - if twoGone <= twoBefore { |
| - t.Errorf("deletion did not move the revision: %d then %d", twoBefore, twoGone) |
| + seen[r] = true |
| } |
| |
| type step struct { |
| @@ -919,58 +933,208 @@ func TestSuiteConsumersMalformedRefusesBoot(t *testing.T) { |
| } |
| } |
| |
| -// Astra's restore sequence (oficina/docs feat/suite-producer, 2026-11-01), |
| -// with a real SQLite backup: a private draft is backed up; it is renamed to |
| -// confidential text, and memoria holds that revision and the feed cursor |
| -// after it; the backup is restored and the harmless draft is shared with the |
| -// team. With revisions that counted up from the restored value, the team |
| -// share reissued the held revision, so S2 answered VISIBLE for a teammate |
| -// against the confidential copy, and S1 answered the held cursor with no |
| -// rows and the same cursor — silence for ever. Now the revision is later |
| -// than anything issued before the restore, and the old cursor is an error. |
| +// Astra's restore sequences (oficina/docs feat/suite-producer, two rounds, |
| +// 2026-11-01), with a real SQLite backup: a private draft is backed up; it |
| +// is renamed to confidential text, and memoria holds that revision and the |
| +// feed cursor after it; the backup is restored and the harmless draft is |
| +// shared with the team. With revisions counted up from the restored value |
| +// the share reissued the held revision, so S2 answered VISIBLE for a |
| +// teammate against the confidential copy, and S1 answered the held cursor |
| +// with no rows and the same cursor for ever. With revisions and nonces read |
| +// from a clock, the same happened when the restore landed on a clock set |
| +// back to the confidential edit's time ("clock set back"). Revisions and |
| +// nonces are random now, so neither repeats. |
| // |
| -// MUTATION-TESTED 2026-11-01, each reverted: bumpRevision as revision + 1 |
| -// with creation at revision 1 → "VISIBLE against the confidential copy"; |
| -// Feed without the stamp check (a bare id) → "the cursor from before the |
| -// restore". |
| +// MUTATION-TESTED 2026-11-01, each reverted: sequential revisions |
| +// (newRevision returning current + 1, creation at 1) → both subtests |
| +// VISIBLE against the confidential copy; time-based revisions and nonces |
| +// (newRevision and randomPositive reading suiteClock) → "clock set back" |
| +// VISIBLE and its old cursor answered a page, while "real clock" stayed |
| +// green, which is why both subtests exist; Feed without the nonce check → |
| +// both subtests' old cursor answered a page. |
| func TestSuiteRestoreNeverReissuesARevisionOrACursor(t *testing.T) { |
| + for _, tc := range []struct { |
| + name string |
| + // clock is suiteClock at each step, or nil for the real clock. |
| + clock map[string]time.Time |
| + }{ |
| + {"real clock", nil}, |
| + {"clock set back", map[string]time.Time{ |
| + "backup": time.Date(2026, 11, 1, 10, 0, 0, 0, time.UTC), |
| + "confidential": time.Date(2026, 11, 1, 10, 10, 0, 0, time.UTC), |
| + // The restore happens at 10:20 on a clock that reads 10:10. |
| + "restored": time.Date(2026, 11, 1, 10, 10, 0, 0, time.UTC), |
| + }}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + at := func(step string) { |
| + if when, ok := tc.clock[step]; ok { |
| + suiteClock = func() time.Time { return when } |
| + } |
| + } |
| + t.Cleanup(func() { suiteClock = time.Now }) |
| + at("backup") |
| + dir := t.TempDir() |
| + path, backup := filepath.Join(dir, "docs.db"), filepath.Join(dir, "backup.db") |
| + cfg := Config{DBPath: path, Env: "development", AllowedAddresses: "alice@example.com,bob@example.com"} |
| + app, err := New(cfg) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + ctx := context.Background() |
| + alice := app.TestPerson(t, "alice@example.com") |
| + app.TestPerson(t, "bob@example.com") |
| + doc := app.TestCreatePrivate(t, alice, "Draft") |
| + if _, err := app.db.Writer().Exec("VACUUM INTO ?", backup); err != nil { |
| + t.Fatal(err) |
| + } |
| + at("confidential") |
| + if err := app.store.Rename(ctx, app.TestActorForPerson(t, alice), doc, "Confidential: the acquisition"); err != nil { |
| + t.Fatal(err) |
| + } |
| + held := revisionOf(t, app.store, doc.ID) |
| + if body, err := app.suite.Content(ctx, doc.Sqid, held); err != nil || !strings.Contains(string(body), "Confidential") { |
| + t.Fatalf("memoria's copy: %q %v", body, err) |
| + } |
| + cursor := feedTip(t, app.suite) |
| + if err := app.Close(); err != nil { |
| + t.Fatal(err) |
| + } |
| + |
| + restoreFile(t, backup, path) |
| + at("restored") |
| + restored, err := NewForTestWith(t, cfg) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := restored.store.SetVisibility(ctx, alice, doc.Sqid, VisibilityTeam); err != nil { |
| + t.Fatal(err) |
| + } |
| + got, err := restored.suite.Rule(ctx, suite.Subject{Kind: suite.SubjectAddress, Value: "bob@example.com"}, []suite.ItemRevision{{ItemID: doc.Sqid, Revision: held}}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if got[0] != suite.UNKNOWN { |
| + t.Errorf("S2 for a teammate at the confidential copy's revision after the restore: %s, want UNKNOWN (not in the restored log)", got[0]) |
| + } |
| + if current := revisionOf(t, restored.store, doc.ID); current == held { |
| + t.Errorf("the restore reissued revision %d", held) |
| + } |
| + if f, err := restored.suite.Feed(ctx, cursor, 100); err == nil { |
| + t.Errorf("the cursor from before the restore (%q) answered a page: cursor %q, %d rows; want an error", cursor, f.Cursor, len(f.Rows)) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// Astra's second-round sequence: a backup taken BEFORE migration 0009. A |
| +// harmless document is granted to Bob and backed up; Bob is revoked and the |
| +// document renamed to confidential text; the suite is deployed (0009 runs) |
| +// and memoria holds the confidential revision; the pre-0009 backup is |
| +// restored and the new build boots, running 0009 again over the harmless, |
| +// Bob-granted document. A constant there gave it the same revision as the |
| +// confidential copy, and S2 answered VISIBLE for Bob. No clock involved. |
| +// |
| +// MUTATION-TESTED 2026-11-01, reverted: 0009 without its random UPDATE (every |
| +// existing document at revision 1, as before) → Bob VISIBLE. |
| +func TestSuiteRestoreOfAPre0009BackupIssuesNewRevisions(t *testing.T) { |
| dir := t.TempDir() |
| path, backup := filepath.Join(dir, "docs.db"), filepath.Join(dir, "backup.db") |
| + |
| + // A database at 0008: the boot schema with Docs' own set cut before 0009. |
| + old := fstest.MapFS{} |
| + entries, err := fs.ReadDir(migrationFS, "migrations") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, e := range entries { |
| + if e.Name() < "0009" { |
| + b, _ := fs.ReadFile(migrationFS, "migrations/"+e.Name()) |
| + old["migrations/"+e.Name()] = &fstest.MapFile{Data: b} |
| + } |
| + } |
| + pre := migrate.Merge(migrate.MustFromFS(dashboard.Migrations, "oficina_dashboard"), sessions.Schema, authSchema, migrate.MustFromFS(old, "docs"), linkstore.Schema, migrate.MustFromFS(handoff.Migrations, "oficina_handoff"), migrate.MustFromFS(connectlinks.Migrations, connectlinks.SchemaNamespace)) |
| + d, err := db.Open(path, nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := migrate.Apply(context.Background(), d, pre); err != nil { |
| + t.Fatal(err) |
| + } |
| + now := time.Now().UTC() |
| + for _, q := range []struct { |
| + sql string |
| + args []any |
| + }{ |
| + {`INSERT INTO people (id, email, created_at) VALUES (1, 'alice@example.com', ?), (2, 'bob@example.com', ?)`, []any{now, now}}, |
| + {`INSERT INTO documents (id, sqid, title, guid, client_id, created_at, updated_at, owner_id) VALUES (1, 'harmless01', 'Harmless', 'g', 1, ?, ?, 1)`, []any{now, now}}, |
| + {`INSERT INTO grants (doc_id, subject, role, created_by, created_at) VALUES (1, 'bob@example.com', 'reader', 1, ?)`, []any{now}}, |
| + } { |
| + if _, err := d.Writer().Exec(q.sql, q.args...); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if _, err := d.Writer().Exec("VACUUM INTO ?", backup); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := d.Writer().Exec(`DELETE FROM grants`); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := d.Writer().Exec(`UPDATE documents SET title = 'Confidential: the acquisition' WHERE id = 1`); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := d.Close(); err != nil { |
| + t.Fatal(err) |
| + } |
| + |
| cfg := Config{DBPath: path, Env: "development", AllowedAddresses: "alice@example.com,bob@example.com"} |
| - app, err := New(cfg) |
| + deployed, err := New(cfg) |
| if err != nil { |
| t.Fatal(err) |
| } |
| ctx := context.Background() |
| - alice := app.TestPerson(t, "alice@example.com") |
| - app.TestPerson(t, "bob@example.com") |
| - doc := app.TestCreatePrivate(t, alice, "Draft") |
| - if _, err := app.db.Writer().Exec("VACUUM INTO ?", backup); err != nil { |
| + held := revisionOf(t, deployed.store, 1) |
| + if body, err := deployed.suite.Content(ctx, "harmless01", held); err != nil || !strings.Contains(string(body), "Confidential") { |
| + t.Fatalf("memoria's copy: %q %v", body, err) |
| + } |
| + if err := deployed.Close(); err != nil { |
| t.Fatal(err) |
| } |
| - if err := app.store.Rename(ctx, app.TestActorForPerson(t, alice), doc, "Confidential: the acquisition"); err != nil { |
| + |
| + restoreFile(t, backup, path) |
| + restored, err := NewForTestWith(t, cfg) |
| + if err != nil { |
| t.Fatal(err) |
| } |
| - held := revisionOf(t, app.store, doc.ID) |
| - if body, err := app.suite.Content(ctx, doc.Sqid, held); err != nil || !strings.Contains(string(body), "Confidential") { |
| - t.Fatalf("memoria's copy: %q %v", body, err) |
| + got, err := restored.suite.Rule(ctx, suite.Subject{Kind: suite.SubjectAddress, Value: "bob@example.com"}, []suite.ItemRevision{{ItemID: "harmless01", Revision: held}}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if got[0] != suite.UNKNOWN { |
| + t.Errorf("S2 for Bob at the confidential copy's revision after restoring a pre-0009 backup: %s, want UNKNOWN", got[0]) |
| } |
| +} |
| + |
| +// feedTip follows the feed to its tip and returns the cursor there. |
| +func feedTip(t *testing.T, p *suiteProducer) string { |
| + t.Helper() |
| cursor := "" |
| for { |
| - f, err := app.suite.Feed(ctx, cursor, 100) |
| + f, err := p.Feed(context.Background(), cursor, 100) |
| if err != nil { |
| t.Fatal(err) |
| } |
| if f.Cursor == cursor { |
| - break |
| + return cursor |
| } |
| cursor = f.Cursor |
| } |
| - if err := app.Close(); err != nil { |
| - t.Fatal(err) |
| - } |
| +} |
| |
| - // The restore: the backup over the live file, its journal gone. |
| +// restoreFile puts a backup over a closed database file, its journal gone, |
| +// as an operator restoring from a snapshot does. |
| +func restoreFile(t *testing.T, backup, path string) { |
| + t.Helper() |
| for _, f := range []string{path + "-wal", path + "-shm"} { |
| os.Remove(f) |
| } |
| @@ -981,27 +1145,6 @@ func TestSuiteRestoreNeverReissuesARevisionOrACursor(t *testing.T) { |
| if err := os.WriteFile(path, b, 0o600); err != nil { |
| t.Fatal(err) |
| } |
| - restored, err := NewForTestWith(t, cfg) |
| - if err != nil { |
| - t.Fatal(err) |
| - } |
| - if err := restored.store.SetVisibility(ctx, alice, doc.Sqid, VisibilityTeam); err != nil { |
| - t.Fatal(err) |
| - } |
| - |
| - got, err := restored.suite.Rule(ctx, suite.Subject{Kind: suite.SubjectAddress, Value: "bob@example.com"}, []suite.ItemRevision{{ItemID: doc.Sqid, Revision: held}}) |
| - if err != nil { |
| - t.Fatal(err) |
| - } |
| - if got[0] == suite.VISIBLE { |
| - t.Errorf("S2 for a teammate answered VISIBLE against the confidential copy (revision %d) after the restore", held) |
| - } |
| - if current := revisionOf(t, restored.store, doc.ID); current == held { |
| - t.Errorf("the restore reissued revision %d", held) |
| - } |
| - if f, err := restored.suite.Feed(ctx, cursor, 100); err == nil { |
| - t.Errorf("the cursor from before the restore (%q) answered a page: cursor %q, %d rows; want an error", cursor, f.Cursor, len(f.Rows)) |
| - } |
| } |
| |
| // A roster lease that runs out during an S2 call (Astra, 2026-11-01): before |
| @@ -1097,3 +1240,54 @@ func TestSuiteAChangeWithoutItsFeedRowDoesNotCommit(t *testing.T) { |
| t.Errorf("rows committed without their feed rows: updates %d→%d, documents %d→%d", updates, updatesAfter, docs, docsAfter) |
| } |
| } |
| + |
| +// STALE is decided by Docs' own log, not by comparing numbers (doctrine |
| +// §4.3): revisions are random, so a revision from this document's history |
| +// is STALE, one it never had — never issued, or another document's — is |
| +// UNKNOWN, whatever its size. |
| +// |
| +// MUTATION-TESTED 2026-11-01, each reverted: Rule answering STALE for any |
| +// non-current revision without consulting the log → both "never issued" |
| +// cases and "another document's" STALE (and conformance's "one revision |
| +// ahead" STALE in both shapes); the log lookup not keyed on the document → |
| +// "another document's" STALE. (A first try at the second dropped the |
| +// document from the SQL in a way SQLite refused — red for a syntax error, |
| +// not the rule — and was redone as a valid query.) |
| +func TestSuiteStaleIsDecidedByTheLog(t *testing.T) { |
| + app, err := NewForTestWith(t, Config{AllowedAddresses: "alice@example.com"}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + ctx := context.Background() |
| + alice := app.TestPerson(t, "alice@example.com") |
| + actor := app.TestActorForPerson(t, alice) |
| + doc, _ := app.store.Create(ctx, alice, "One") |
| + other, _ := app.store.Create(ctx, alice, "Two") |
| + history := []int64{revisionOf(t, app.store, doc.ID)} |
| + for _, title := range []string{"One, again", "One, once more"} { |
| + if err := app.store.Rename(ctx, actor, doc, title); err != nil { |
| + t.Fatal(err) |
| + } |
| + history = append(history, revisionOf(t, app.store, doc.ID)) |
| + } |
| + current := history[len(history)-1] |
| + ask := []suite.ItemRevision{ |
| + {ItemID: doc.Sqid, Revision: history[0]}, |
| + {ItemID: doc.Sqid, Revision: history[1]}, |
| + {ItemID: doc.Sqid, Revision: current}, |
| + {ItemID: doc.Sqid, Revision: current - 1}, |
| + {ItemID: doc.Sqid, Revision: 1}, |
| + {ItemID: doc.Sqid, Revision: revisionOf(t, app.store, other.ID)}, |
| + } |
| + got, err := app.suite.Rule(ctx, suite.Subject{Kind: suite.SubjectAddress, Value: "alice@example.com"}, ask) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + want := []suite.Authorization{suite.STALE, suite.STALE, suite.VISIBLE, suite.UNKNOWN, suite.UNKNOWN, suite.UNKNOWN} |
| + names := []string{"first", "second", "current", "never issued (current - 1)", "never issued (1)", "another document's"} |
| + for i := range want { |
| + if got[i] != want[i] { |
| + t.Errorf("%s: %s, want %s", names[i], got[i], want[i]) |
| + } |
| + } |
| +} |