Files
felhom.eu/hub/internal/configgen/configgen_debug_test.go
T
admin 6b40eb8619 hub: customer-claim password arc parts 1+2 — code engine, emails, ACK, configgen bake, UI (v0.50.0)
Closes DRILL-day0-vm F-4 hub-side: per-customer claim state (customer_claims,
bcrypt-only custody), the claim engine (issue at real config retrieve = Day-0
bake; first-report issue for live boxes; resend rotates generation; reset
rate-limited 3/day), three Hungarian emails via the dispatcher, report-ACK
claim object {code_hash, generation, issued_at} + set-only claimed ingest,
web.claim_code_* baked into generated controller.yaml, Setup-tab status chip
+ resend button, POST /api/v1/claim/reset-request (self-scoped), claim_lockout
event allowlisted. 13 new tests; full repo green.

Claude-Session: https://claude.ai/code/session_01NptTCFtu7dz2Ru89qHRagN
2026-07-12 18:12:48 +02:00

41 lines
1.6 KiB
Go

package configgen
import (
"strings"
"testing"
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
)
// The remote debug-mode toggle (hub v0.42.0) relies on this integration: a customer ConfigJSON carrying
// logging.level=debug must deep-merge OVER the template default into the generated controller.yaml, so the
// controller's isDebug() (Logging.Level=="debug") lights up the /debug menu + verbose log. Verified live on
// the demo box (2026-07-10): its controller.yaml carries `logging.level: info` — the exact merge target this
// pins. Without this leg the hub toggle would be a silent no-op.
func TestGenerate_DebugLevelOverride(t *testing.T) {
const tmpl = "logging:\n level: info\n"
// Override present → the generated YAML carries level: debug, and the info default is gone.
dbg, err := Generate(tmpl, &store.CustomerConfig{
CustomerID: "c1", ConfigJSON: `{"logging":{"level":"debug"}}`,
}, nil)
if err != nil {
t.Fatalf("generate (debug): %v", err)
}
if !strings.Contains(dbg, "level: debug") {
t.Fatalf("logging.level=debug override did not reach controller.yaml:\n%s", dbg)
}
if strings.Contains(dbg, "level: info") {
t.Fatalf("the info default should have been overridden by debug:\n%s", dbg)
}
// No override → the template default (info) stands, debug absent.
def, err := Generate(tmpl, &store.CustomerConfig{CustomerID: "c1", ConfigJSON: "{}"}, nil)
if err != nil {
t.Fatalf("generate (default): %v", err)
}
if !strings.Contains(def, "level: info") || strings.Contains(def, "level: debug") {
t.Fatalf("no override should leave level: info intact:\n%s", def)
}
}