Bind all canvas element identities to their snapshot owners
This commit is contained in:
@@ -46,6 +46,15 @@ func TestCanonicalModelStreamFramesAndSnapshot(t *testing.T) {
|
||||
if !uuidSlugPattern.MatchString(token) || records[0]["projectId"] != modelRootID || !modelEqual(records[0]["versions"], model.Versions) || !modelEqual(records[0]["tombstones"], model.Tombstones) {
|
||||
t.Fatal("stream header lost snapshot identity")
|
||||
}
|
||||
owners := records[0]["elementOwners"].(map[string]any)
|
||||
if len(owners) != len(model.Elements) {
|
||||
t.Fatal("identity manifest must cover unloaded elements too")
|
||||
}
|
||||
for id, element := range model.Elements {
|
||||
if owners[id] != element["ownerCanvasId"] {
|
||||
t.Fatal("identity manifest mixed owners", id)
|
||||
}
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for i, record := range records {
|
||||
if record["sequence"] != float64(i) || record["snapshotToken"] != token || record["streamVersion"] != float64(1) {
|
||||
@@ -114,3 +123,15 @@ func TestCanonicalModelStreamDeclaresDirectScopeCountsIncludingEmptyCanvases(t *
|
||||
t.Fatal("invalid owner must fail before publishing a scope certificate")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCanonicalModelStreamRejectsAmbiguousIdentityManifest(t *testing.T) {
|
||||
for _, id := range []string{"", "a"} {
|
||||
model := modelTestDocument()
|
||||
model.Elements["other"] = modelTestNode(id, modelRootID)
|
||||
writer := httptest.NewRecorder()
|
||||
writeCanvasModelStream(context.Background(), writer, model)
|
||||
if writer.Code != 500 || writer.Flushed {
|
||||
t.Fatal("ambiguous identity was published before rejection")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user