The restart line names no part of a value; the new rows join existing tests (issue 1966, review round 1)
mesh/delivery merged: source.main moved to novox/mesh-host@9d8647aa0f56
mesh/check checking aa649d85a065 on 9d8647aa0f56
mesh/delivery merged: source.main moved to novox/mesh-host@9d8647aa0f56
mesh/check checking aa649d85a065 on 9d8647aa0f56
Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -364,30 +364,27 @@ func TestAProcessAppliedAgainIsUnchangedAndNotRestarted(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if o := outcomeOf(fourth, "node-tools.runtime"); o.Action != "updated" || !strings.Contains(o.Detail, "its unit's Environment MESH_TOOL_MODULES (b)") {
|
||||
t.Errorf("fourth apply: %+v, want updated and the word and entry that changed named", o)
|
||||
if o := outcomeOf(fourth, "node-tools.runtime"); o.Action != "updated" || !strings.Contains(o.Detail, "its unit's Environment MESH_TOOL_MODULES") ||
|
||||
strings.Contains(o.Detail, "/y/") {
|
||||
t.Errorf("fourth apply: %+v, want updated and the word that changed named, no value", o)
|
||||
}
|
||||
}
|
||||
|
||||
// A restart nobody asked for names its cause (issue 1966): the unit's own words that differ, the key inside a word that
|
||||
// is a JSON object and the entry of a list, never a value.
|
||||
func TestAProcessRestartedForAnInputSaysWhichInputChanged(t *testing.T) {
|
||||
for _, row := range []struct {
|
||||
name, was, now, says string
|
||||
}{
|
||||
{"a word of a module inside a JSON word", `{"files":{"OWNED":"/a"},"mail":{"X":"1"}}`, `{"files":{"OWNED":"/b"},"mail":{"X":"1"}}`,
|
||||
"Environment TOOL_ENV (files (OWNED))"},
|
||||
{"an entry of a list", "a=/x/1,b=/y/2", "a=/x/1,b=/y/3", "Environment TOOL_MODULES (b)"},
|
||||
{"a secret-shaped value", "c2VjcmV0MQ==", "c2VjcmV0Mg==", "Environment TOOL_VALUE"},
|
||||
{"a URL with a password", "postgres://u:hunter1@h/db?sslmode=x", "postgres://u:hunter2@h/db?sslmode=x", "Environment TOOL_VALUE"},
|
||||
{"nothing changed", "a=/x/1", "a=/x/1", ""},
|
||||
} {
|
||||
t.Run(row.name, func(t *testing.T) {
|
||||
word := "TOOL_MODULES"
|
||||
word := "TOOL_VALUE"
|
||||
if strings.HasPrefix(row.was, "{") {
|
||||
word = "TOOL_ENV"
|
||||
}
|
||||
r := aProcess()
|
||||
mk := func(v string) string {
|
||||
r := aProcess()
|
||||
r.Env = map[string]string{word: v, "SECRET": "never-said-" + v}
|
||||
r.Env = map[string]string{word: v}
|
||||
return "sha256:" + strings.Repeat("a", 64) + " " + unitFor(r)
|
||||
}
|
||||
got := unitDifference(mk(row.was), mk(row.now))
|
||||
@@ -397,8 +394,13 @@ func TestAProcessRestartedForAnInputSaysWhichInputChanged(t *testing.T) {
|
||||
}
|
||||
return
|
||||
}
|
||||
if !strings.Contains(got, row.says) || strings.Contains(got, "never-said") || strings.Contains(got, "/b") {
|
||||
t.Fatalf("said %q, want it to name %q and no value", got, row.says)
|
||||
for _, leak := range []string{"c2VjcmV0", "hunter", "sslmode", "postgres", "/b"} {
|
||||
if strings.Contains(got, leak) {
|
||||
t.Fatalf("said %q, which holds part of a value (%s)", got, leak)
|
||||
}
|
||||
}
|
||||
if !strings.Contains(got, row.says) {
|
||||
t.Fatalf("said %q, want it to name %q", got, row.says)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user