Download this file
| 1 | package chat |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | "time" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/wire" |
| 8 | ) |
| 9 | |
| 10 | func TestNotebookReportRequiresCurrentProvenance(t *testing.T) { |
| 11 | for _, protocol := range []int{wire.ProtocolInjectionDefences - 1, wire.ProtocolInjectionDefences} { |
| 12 | t.Run(itoa64(int64(protocol)), func(t *testing.T) { |
| 13 | r := newHKRig(t) |
| 14 | entry := wire.NotebookEntry{ID: "n42", Source: wire.NotePerson, Text: "Do not publish.", At: time.Unix(1700000000, 0).UTC()} |
| 15 | r.must(r.tx(func(tx *txn) error { |
| 16 | return tx.notebookReport(Lease{Runner: RunnerPrincipal{Person: hkOwner, RunnerID: "RUNNER1"}, Protocol: protocol}, &wire.NotebookReport{Person: hkOwner, Entries: []wire.NotebookEntry{entry}}) |
| 17 | })) |
| 18 | got, err := r.s.Notebook(r.ctx, hkOwner) |
| 19 | r.must(err) |
| 20 | if protocol < wire.ProtocolInjectionDefences { |
| 21 | entry.Source = wire.NoteOwn |
| 22 | } |
| 23 | if len(got.Entries) != 1 || got.Entries[0] != entry { |
| 24 | t.Fatalf("notebook lost text or trusted old provenance: %+v", got.Entries) |
| 25 | } |
| 26 | }) |
| 27 | } |
| 28 | } |
| 29 | |