carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "github.com/carlosframework/platform/internal/moves"
5 "testing"
6)
7
8func TestPlan14RootSeedsFloorIndependent(t *testing.T) {
9 for _, family := range []string{"moves", "seeds"} {
10 t.Run(family, func(t *testing.T) {
11 f := rootMovesFloors{private: &rollbackMemory{files: map[string][]byte{}}, public: &rollbackMemory{files: map[string][]byte{}}, identity: rootFloorIdentity{"deploy", "box", "en"}}
12 a, b := moves.Floor{Min: 1, MinRelease: "v1.0.0"}, moves.Floor{Min: 2, MinRelease: "v2.0.0"}
13 if err := f.reconstruct(t.Context(), rootFloorReconstruction{Identity: f.identity, Floor: &a, Source: "root history", Digest: floorTestDigest, Authorization: floorTestAuthorization(t, f)}); err != nil {
14 t.Fatal(err)
15 }
16 if err := f.acceptHealthy(t.Context(), rootFloorBinary{Version: "v2.0.0", Protocol: 2, Digest: floorTestDigest}); err != nil {
17 t.Fatal(err)
18 }
19 if err := f.refresh(t.Context(), &a, []*moves.Floor{&b}, nil); err == nil {
20 t.Fatal("legacy ahead accepted")
21 }
22 if _, err := f.projection(); err == nil {
23 t.Fatal("deny-only floor advertised")
24 }
25 bound, err := f.localBound()
26 if err != nil || bound == nil || *bound != b {
27 t.Fatal("lost legacy deny", bound, err)
28 }
29 if err := f.refresh(t.Context(), nil, nil, nil); err == nil {
30 t.Fatal("remote deletion repaired refusal")
31 }
32 if err := f.refresh(t.Context(), &b, nil, nil); err != nil {
33 t.Fatal(err)
34 }
35 if p, err := f.projection(); err != nil || *p.Floor != b {
36 t.Fatal(p, err)
37 }
38 })
39 }
40 if rootSeedsFloorDir("/opt/carlos") == rootFloorDir("/opt/carlos") {
41 t.Fatal("floors share authority")
42 }
43 b := rootFloorBinary{Version: "v2.0.0", Digest: "signed", Protocol: 5, SeedsProtocol: 1}
44 if b.forSeeds().supports(&moves.Floor{Min: 2, MinRelease: "v1.0.0"}) {
45 t.Fatal("moves protocol authorized seeds")
46 }
47}
48