Files
mesh-controller/internal/link/movesecret_test.go
T
jschoubben dd366f8a3f Pin the group's final mesh-sdk 206f794e with its captured conformance files, and read the engine's superseded word on a secret move (issue 774)
The captured SDK (testdata/beside, conformance/events) is taken again at the pinned commit, as CAPTURED
says. The controller's mirror of MoveSecretAnswer gains `superseded` (mesh-host b9c24a7): the vault holds
another value, the live one, and the machine's older value is not moved and not asked again. The field
test names it. A superseded row is still counted with the moved ones: counting it apart needs a field and
its words in nodeMove, more than the one line asked.
2026-10-30 18:37:56 +01:00

46 lines
1.7 KiB
Go

package link
import (
"encoding/json"
"sort"
"strings"
"testing"
"time"
"github.com/novox/mesh-controller/internal/broker"
)
// The move's ask and answer keep the engine's field names (mesh-host internal/link,
// TestTheMovesAskKeepsItsFieldNamesAndContext): the row's fields beside a hand-over's, under a context of its own.
func TestTheMovesAskAndAnswerKeepTheirFieldNames(t *testing.T) {
keys := func(v any) string {
raw, _ := json.Marshal(v)
var m map[string]any
_ = json.Unmarshal(raw, &m)
var out []string
for k := range m {
out = append(out, k)
}
sort.Strings(out)
return strings.Join(out, " ")
}
ask := MoveSecretAsk{Module: "m", Name: "n", Provider: "p", Provision: "q", Consumer: "c", ConsumerModule: "cm",
Local: "l", Origin: "made", Generation: "g", MadeAt: time.Unix(1, 0).UTC(), Sealed: "s", SealedTo: "k"}
if got := keys(ask); got != "consumer consumer_module generation local made_at module name origin provider "+
"provision sealed sealed_to" {
t.Fatalf("the ask's fields are %q", got)
}
answer := MoveSecretAnswer{Said: "s", Refused: "r", Secret: "own/a/b/c", Generation: 1, Unchanged: true,
Superseded: true}
if got := keys(answer); got != "generation refused said secret superseded unchanged" {
t.Fatalf("the answer's fields are %q", got)
}
if broker.AskMoveSecretSubject("laptop") != "mesh.node.laptop.ask.move-secret" ||
MoveSecretContext != "novox-mesh move-secret v1\n" {
t.Fatalf("the subject %q, the context %q", broker.AskMoveSecretSubject("laptop"), MoveSecretContext)
}
}
// A move is asked of the machine on its own subject, signed under its own context — never a hand-over's — naming
// no path and carrying the row beside the hand-over's fields; the engine's answer comes back whole.