package api import ( "strings" "testing" "gitea.dooplex.hu/admin/felhom-hub/internal/notify" ) // R-539 — controller_slow_crashloop joins its fast sibling: allowlisted AND operator-only. // RED-PROOF: remove it from operatorOnlyEvents → "must be operator-only". func TestControllerSlowCrashloopIsAllowlistedAndOperatorOnly(t *testing.T) { et := "controller_slow_crashloop" if !allowedEventTypes[et] { t.Fatalf("%s must be in allowedEventTypes (R-77)", et) } if !notify.IsOperatorOnly(et) { t.Fatalf("%s must be operator-only — host ids and vmids are not a household's business", et) } } // R-550 — restore_interrupted is pushed by controller v0.246.0 and IS for the household: they started // the restore and can run it again. So it must be allowlisted (or POST /event 400s — R-77), must NOT be // operator-only, and must carry a Hungarian customer message (a missing entry falls back to the raw // English message — the v0.78.0 defect). // RED-PROOF: drop the customerMessages entry → the subject/body carry the raw message. func TestRestoreInterruptedReachesTheHouseholdInHungarian(t *testing.T) { et := "restore_interrupted" if !allowedEventTypes[et] { t.Fatalf("%s must be in allowedEventTypes — the controller's push would 400", et) } if notify.IsOperatorOnly(et) { t.Fatalf("%s must reach the household, not only the operator", et) } const raw = "RAW-ENGLISH-SENTINEL restore interrupted" // The SUBJECT is built from the Hungarian message alone; the body legitimately repeats the raw // message as a detail line ("Üzenet: …"), so the body cannot be the witness — the subject is. subject, body := notify.FormatCustomerEmail("hu", "c1", et, "warning", raw, "", "{}") if strings.Contains(subject, "RAW-ENGLISH-SENTINEL") { t.Fatalf("customer mail subject for %s is the raw message — customerMessages entry missing: %q", et, subject) } // ASCII fragment of the Hungarian text („megszakadt"), with a negative control. if !strings.Contains(body, "megszakadt") { t.Fatalf("customer mail for %s lacks the Hungarian sentence (fragment \"megszakadt\")", et) } if strings.Contains(body, "zzzz-not-present") { t.Fatalf("negative control matched — the fragment search is broken") } }