The off-site copies of a removed app end 30 days after „delete backup data” — the box's half (felhom.eu R-1374 part 1; D72, D84)
gates / gates (push) Successful in 41s

Built, not released; no box has run it. felhom.eu `07-backup-architecture.md` §8.2f.
It does nothing without a hub that knows it: an older hub agrees to no id.

- The record: settings `offsite_ends` {app, removed_at, ends_at}. One writer
  (backup.StartOffsiteEnd), called by a removal only with „delete backup data”
  and by „Törlés 30 nap múlva” on the restore page. A second press changes
  nothing. No record, no deletion. Only on the hub-provisioned tier.
- The date is on the remove dialog before the press; the restore page shows
  „Törlésre kijelölve …” with „Mégis megtartom”, and one history line per
  carried-out end. An install of the same app deletes the record.
- The weekly window: after the guard has passed the policy's plan under the cap
  as before, it adds the snapshots whose app tags are ALL due records, that the
  hub agreed to and the box named in the same request; the result names them
  apart (removed_for_ended_apps). `_shares`, the box's own stacks and an
  installed app are never due.
- The report carries the pending records; the household gets one mail per
  press (offsite_end_scheduled), in both languages.

MinAgent unchanged (0.158.1). 143 parity fixtures gained the dialog's one new
script line (patched, not regenerated); one new parity case.
Tests TestD72_*, TestD84_*; 56 mutations seen red
(felhom.eu documentation/audits/build-release-4-2026-11-15/A/redproof-ctrl-*.txt).

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-11-15 14:09:47 +01:00
1 parent 591195fadd
commit f628cb5082
177 files changed
+3705 -164

No files matched your search

@@ -0,0 +1,71 @@
package notify
import (
"encoding/json"
"io"
"log"
"path/filepath"
"strings"
"testing"
"time"
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
)
// D84 (`09` §3 decision 309; `07-backup-architecture.md` §8.2f): the household's ONE mail at the press names the app,
// the end date and how to take it back — in the household's language, with the date in that language's form.
// RED-PROOF: felhom.eu/documentation/audits/build-release-4-2026-11-15/A/redproof-ctrl-press.txt.
func TestD84_OffsiteEndScheduledEvent(t *testing.T) {
ends := time.Date(2026, 12, 15, 10, 30, 0, 0, time.UTC)
for _, lang := range []string{"hu", "en"} {
sett, err := settings.Load(filepath.Join(t.TempDir(), "settings.json"), log.New(io.Discard, "", 0))
if err != nil {
t.Fatal(err)
}
if err := sett.SetLanguage(lang); err != nil {
t.Fatal(err)
}
n := &Notifier{settings: sett, logger: log.New(io.Discard, "", 0)}
var et, sev, msg, cust string
var det []byte
calls := 0
n.pushFn = func(eventType, severity, message, customer string, details interface{}) {
calls++
et, sev, msg, cust = eventType, severity, message, customer
det, _ = json.Marshal(details)
}
n.NotifyOffsiteEndScheduled("vikunja", "2026-11-15T10:30:00Z", "2026-12-15T10:30:00Z", ends)
if calls != 1 || et != "offsite_end_scheduled" || sev != "info" {
t.Fatalf("%s: calls=%d type=%q severity=%q", lang, calls, et, sev)
}
// the wire sentence is always Hungarian: the app, the day, the way back
for _, want := range []string{"vikunja", "2026. 12. 15.", "Mentések oldalon", "„Mégis megtartom”"} {
if !strings.Contains(msg, want) {
t.Errorf("%s: the Hungarian sentence %q lacks %q", lang, msg, want)
}
}
if strings.Contains(msg, "15..") || strings.Contains(msg, "%") {
t.Errorf("%s: the Hungarian sentence is malformed: %q", lang, msg)
}
if lang == "hu" {
if cust != "" {
t.Errorf("a Hungarian household sends nothing extra, got %q", cust)
}
} else {
for _, want := range []string{"vikunja", "2026-12-15", "Backups page", "“Keep it after all”"} {
if !strings.Contains(cust, want) {
t.Errorf("the English sentence %q lacks %q", cust, want)
}
}
if strings.Contains(cust, "2026. 12.") || strings.Contains(cust, "%") {
t.Errorf("the English sentence carries the Hungarian date form or a verb: %q", cust)
}
}
// the details: stack_name (the hub's headline names the app from it) and the press's own key
for _, want := range []string{`"stack_name":"vikunja"`, `"removed_at":"2026-11-15T10:30:00Z"`, `"ends_at":"2026-12-15T10:30:00Z"`, `"subject":"vikunja|2026-11-15T10:30:00Z"`} {
if !strings.Contains(string(det), want) {
t.Errorf("%s: details %s lack %s", lang, det, want)
}
}
}
}