The node seat node-engine served on the engine's link: its verbs with their proven caller, its acts kept in its own state, a hand-over or access act asked of the operator as node-engine-<node> and performed only on the warrant (issue 774, ADR 0563 §1-§3)
This commit is contained in:
@@ -57,4 +57,34 @@ func TestASetuidSearchAskIsBelievedOnlySignedForThisNodeAndOnce(t *testing.T) {
|
||||
if a := AnswerSetuidSearch(check, nil, body); a.Refused == "" {
|
||||
t.Fatalf("no handler: %+v", a)
|
||||
}
|
||||
// 774 (ADR 0563 §2): the node seat's setuid-search starts none while one runs, at most one in any hour, naming when the
|
||||
// next may start, and records who asked.
|
||||
t.Run("the node seat's search is bounded", func(t *testing.T) {
|
||||
at, running, started := now, false, 0
|
||||
h := &HandActs{Node: "n1", State: &FileState{Path: t.TempDir() + "/" + HandActsFile}, Now: func() time.Time { return at },
|
||||
Searching: func() bool { return running },
|
||||
SetuidSearch: func(by string) (string, error) { started++; return "a new search starts", nil }}
|
||||
for _, row := range []struct {
|
||||
name string
|
||||
after time.Duration
|
||||
running bool
|
||||
refused string
|
||||
started int
|
||||
}{
|
||||
{name: "one runs", running: true, refused: "runs on this machine now", started: 0},
|
||||
{name: "the first", started: 1},
|
||||
{name: "within the hour", after: 59 * time.Minute, refused: "the next may start at 2026-10-10T03:00:00Z", started: 1},
|
||||
{name: "after the hour", after: time.Hour + time.Second, started: 2},
|
||||
} {
|
||||
at, running = now.Add(row.after), row.running
|
||||
_, err := h.Call(EngineCall{Verb: ActSetuidSearch, Caller: "ace.node-tools"})
|
||||
if (row.refused == "") != (err == nil) || (err != nil && !strings.Contains(err.Error(), row.refused)) || started != row.started {
|
||||
t.Errorf("%s: %v, %d started", row.name, err, started)
|
||||
}
|
||||
}
|
||||
acts, _ := h.Acts(1)
|
||||
if got := acts.(map[string]any)["acts"].([]HandAct); len(got) != 1 || got[0].Caller != "ace.node-tools" || got[0].State != HandDone {
|
||||
t.Errorf("the last search is recorded as %+v", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user