0c702f834a
gates / gates (push) Successful in 27s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
45 lines
2.2 KiB
Go
45 lines
2.2 KiB
Go
package web
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/stacks"
|
|
)
|
|
|
|
// v0.279.0 (decision 45) — when the default login is IN EFFECT, and the sentence the household reads.
|
|
// COMPANION RED-PROOF: make defaultLoginInEffect ignore after_install (the pre-0.279.0 page: the default
|
|
// card always shown) → the "replaced" rows fail — the page would send the household to a dead login.
|
|
func TestKnownLogin_InEffectOnlyUntilReplaced(t *testing.T) {
|
|
withCreds := &stacks.Metadata{AppInfo: stacks.AppInfo{DefaultCreds: "admin / admin"}}
|
|
withFix := &stacks.Metadata{AppInfo: stacks.AppInfo{DefaultCreds: "admin@claper.co / claper"},
|
|
AfterInstall: &stacks.AfterInstallCommand{Service: "claper", Command: []string{"x"}, Success: "OK"}}
|
|
ok := &stacks.AppConfig{AfterInstall: &stacks.AfterInstallRecord{OK: true}}
|
|
failed := &stacks.AppConfig{AfterInstall: &stacks.AfterInstallRecord{OK: false}}
|
|
for _, c := range []struct {
|
|
name string
|
|
meta *stacks.Metadata
|
|
cfg *stacks.AppConfig
|
|
installed bool
|
|
want bool
|
|
}{
|
|
{"no default login", &stacks.Metadata{}, nil, false, false},
|
|
{"default, nothing replaces it: before install", withCreds, nil, false, true},
|
|
{"default, nothing replaces it: installed", withCreds, &stacks.AppConfig{}, true, true},
|
|
{"after_install declared: before install", withFix, nil, false, false},
|
|
{"after_install succeeded", withFix, ok, true, false},
|
|
{"after_install not run yet", withFix, &stacks.AppConfig{}, true, false},
|
|
{"after_install FAILED", withFix, failed, true, true},
|
|
} {
|
|
if got := defaultLoginInEffect(c.meta, c.cfg, c.installed); got != c.want {
|
|
t.Errorf("%s: in effect = %v, want %v", c.name, got, c.want)
|
|
}
|
|
}
|
|
s := testServer(t)
|
|
if got, want := s.knownLoginLine("hu", withCreds, nil, false), "Ez az alkalmazás egy ismert, közös jelszóval indul: admin / admin. Telepítés után azonnal változtasd meg."; got != want {
|
|
t.Fatalf("hu sentence %q, want %q", got, want)
|
|
}
|
|
if got, want := s.knownLoginLine("en", withFix, failed, true), "This app starts with a known, shared password: admin@claper.co / claper. Change it right after the install."; got != want {
|
|
t.Fatalf("en sentence %q, want %q", got, want)
|
|
}
|
|
}
|