Found on demo-hp with 0.325.0-rc.1: the store (and so the conversion of an old family.json) opened only on the first family request; a box nobody visits through a family gate kept the session values. OpenFamilyStore from main, one INFO line with the count. TestR1112_StartConvertsTheFamilyFile, TestR1112_MainOpensTheFamilyStore, red-proved. Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
94f44931dd
commit
6ed223886d
6 files changed
+82
-2
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
@@ -17,6 +18,7 @@ import (
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/config"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/family"
|
||||
)
|
||||
|
||||
@@ -308,3 +310,32 @@ func TestR1113_HouseholdPassesLeaveOneSession(t *testing.T) {
|
||||
t.Fatalf("after the older one expired: %d live household sessions, want 1", live)
|
||||
}
|
||||
}
|
||||
|
||||
// R-1112 at START: the conversion happens when the dashboard starts, not on the first family request (measured on demo-hp
|
||||
// 9201 with rc.1: up, family.json still in the old shape, because nobody had passed a family gate). OpenFamilyStore is
|
||||
// what main calls; the conversion is logged by count, never a value.
|
||||
// Red-proof: OpenFamilyStore with an empty body → the old values stay in the file and this fails.
|
||||
func TestR1112_StartConvertsTheFamilyFile(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
household := "0f1e2d3c4b5a69788796a5b4c3d2e1f00f1e2d3c4b5a6978"
|
||||
exp := time.Now().Add(20 * 24 * time.Hour).UTC().Format(time.RFC3339)
|
||||
path := filepath.Join(dir, "family.json")
|
||||
if err := os.WriteFile(path, []byte(`{"members":[],"sessions":[{"id":"`+household+`","member":"","gen":0,"exp":"`+exp+`"}]}`), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg := config.Default()
|
||||
cfg.Paths.DataDir = dir
|
||||
var logs strings.Builder
|
||||
s := &Server{cfg: cfg, logger: log.New(&logs, "", 0)}
|
||||
s.OpenFamilyStore()
|
||||
b, _ := os.ReadFile(path)
|
||||
if strings.Contains(string(b), household) {
|
||||
t.Fatalf("family.json still holds the session value after the start: %s", b)
|
||||
}
|
||||
if !strings.Contains(logs.String(), "1 session(s) stored the old way were rewritten as fingerprints") {
|
||||
t.Errorf("the conversion must be logged by count, got %q", logs.String())
|
||||
}
|
||||
if strings.Contains(logs.String(), household) {
|
||||
t.Error("the log line carries the session value")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user