package host import ( "github.com/carlosframework/platform/internal/moves" "testing" ) func TestPlan14RootSeedsFloorIndependent(t *testing.T) { for _, family := range []string{"moves", "seeds"} { t.Run(family, func(t *testing.T) { f := rootMovesFloors{private: &rollbackMemory{files: map[string][]byte{}}, public: &rollbackMemory{files: map[string][]byte{}}, identity: rootFloorIdentity{"deploy", "box", "en"}} a, b := moves.Floor{Min: 1, MinRelease: "v1.0.0"}, moves.Floor{Min: 2, MinRelease: "v2.0.0"} if err := f.reconstruct(t.Context(), rootFloorReconstruction{Identity: f.identity, Floor: &a, Source: "root history", Digest: floorTestDigest, Authorization: floorTestAuthorization(t, f)}); err != nil { t.Fatal(err) } if err := f.acceptHealthy(t.Context(), rootFloorBinary{Version: "v2.0.0", Protocol: 2, Digest: floorTestDigest}); err != nil { t.Fatal(err) } if err := f.refresh(t.Context(), &a, []*moves.Floor{&b}, nil); err == nil { t.Fatal("legacy ahead accepted") } if _, err := f.projection(); err == nil { t.Fatal("deny-only floor advertised") } bound, err := f.localBound() if err != nil || bound == nil || *bound != b { t.Fatal("lost legacy deny", bound, err) } if err := f.refresh(t.Context(), nil, nil, nil); err == nil { t.Fatal("remote deletion repaired refusal") } if err := f.refresh(t.Context(), &b, nil, nil); err != nil { t.Fatal(err) } if p, err := f.projection(); err != nil || *p.Floor != b { t.Fatal(p, err) } }) } if rootSeedsFloorDir("/opt/carlos") == rootFloorDir("/opt/carlos") { t.Fatal("floors share authority") } b := rootFloorBinary{Version: "v2.0.0", Digest: "signed", Protocol: 5, SeedsProtocol: 1} if b.forSeeds().supports(&moves.Floor{Min: 2, MinRelease: "v1.0.0"}) { t.Fatal("moves protocol authorized seeds") } }