two lists for the release of release 4: every reader of a host report in the hub (R-1396 gap 2); how --accept-small-disk reaches a public-image install (the bind form has no such field)
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
c3fa43a486
commit
b8cf6c2417
4 files changed
+118
-297
No files matched your search
+48
@@ -0,0 +1,48 @@
|
||||
# How `--accept-small-disk` reaches an install from the public image — read from source, not tried (2026-11-15)
|
||||
|
||||
For the release session of installer 1.38.0 (D83). The reviewer's reading was: the hub's bind form has an „extra
|
||||
args” field, the delivery carries it, the first-boot unit appends it. **Two of the three are true. The first is not.**
|
||||
|
||||
| Link | What the source says | Where |
|
||||
|---|---|---|
|
||||
| The first-boot unit appends extra arguments to the installer's command line | **TRUE.** `read -ra extra <<< "${FELHOM_EXTRA_ARGS:-}"`, then `bash "$SCRIPT_TMP" "${args[@]}" "${extra[@]}"` — the words are split on spaces and passed as they are | `scripts/iso/felhom-bootstrap.sh:412`–`415` |
|
||||
| The pairing answer carries them | **TRUE.** The hub's answer to the box's poll holds `extra_args`; the unit writes it into its env file as `FELHOM_EXTRA_ARGS` (shell-quoted), so every later retry has it too | `hub/internal/api/appliance.go:232`; `scripts/iso/felhom-bootstrap.sh:551` |
|
||||
| The hub's bind handler takes them | **TRUE.** `POST /appliances/<id>/bind` reads the form value `extra_args` and stores it with the bind | `hub/internal/web/appliances.go:140`, `:155`; `hub/internal/store/appliance.go:218` |
|
||||
| **The operator's bind FORM has the field** | **FALSE.** The form on the Hosts page has a household list and the hidden form token, and no input named `extra_args` (searched: no template holds the name) | `hub/internal/web/templates/hosts.html:92`–`97` |
|
||||
| The household's own bind page (the pairing code) | passes an EMPTY value, always | `hub/internal/web/selfbind.go:276` |
|
||||
|
||||
**So, today:** the flag can reach a public-image install only by a POST that the page does not offer — the operator's
|
||||
browser session with a hand-made form. CC cannot do it: a bind is a session-only act (no token).
|
||||
|
||||
**One more thing that follows from the unit's retry loop** (R-1398 part 1): without the flag, a small machine that was
|
||||
bound repeats the refusal every 30 seconds. With the flag in the bind, the first run goes on.
|
||||
|
||||
## The steps for the two small machines
|
||||
|
||||
**demo-hp (128 GB), a reinstall.** It is never installed from the public image in practice; it is installed by the
|
||||
installer run by hand (the direct shape, as every proof install was):
|
||||
|
||||
```
|
||||
./felhom-host-install.sh --customer-id demo-hp --mode appliance --hub-url https://hub.felhom.eu \
|
||||
--passphrase-file <file> --accept-small-disk
|
||||
```
|
||||
|
||||
Expected: the two „--accept-small-disk” lines with the cost; the install goes on; the install state holds
|
||||
`small_disk: true`; after the hub release the box's page shows „System disk: small — accepted below 200 GB”.
|
||||
The box that runs today is not touched by the rule: the check runs only inside an install.
|
||||
|
||||
**The fresh-install proof VM.** Two runs, both by hand in the direct shape (as on 2026-11-14 and 11-15):
|
||||
|
||||
1. *The household's path, no flag:* make the VM's first disk 200G (`qm set <id> --scsi0 nvme-scratch:200,format=raw`
|
||||
— on a `dir` storage the file is sparse and costs what is written). The install must pass the check with the line
|
||||
„system disk: /dev/sda, 214 GB (the minimum is 200 GB)”.
|
||||
2. *The refusal:* the same VM with a 64G disk, `--preflight-only --mode appliance`: it must stop with „This machine's
|
||||
system disk is 68 GB. Felhom needs 200 GB. Nothing was changed.” Before and after: `qm config`, `pvs`, `lvs`, the
|
||||
list of `/etc/felhom*` — equal.
|
||||
|
||||
**To prove the public-image path itself** (the unit, the pairing, the flag from the bind) a session needs the
|
||||
operator: he binds the appliance with a form that holds `extra_args=--accept-small-disk`. That needs the missing
|
||||
input on the Hosts page first — one line in a template and a render test; **not built** (it was not in the brief;
|
||||
it is on R-1398, dated line).
|
||||
|
||||
**What is not proven:** all of it. Nothing was run; no hub row was read.
|
||||
@@ -0,0 +1,70 @@
|
||||
# Every reader of a host report in the hub — and what a short report would do there (R-1396 gap 2)
|
||||
|
||||
Written 2026-11-15 evening, from source (`hub/` at `c3fa43a4`). **A list, no build.** The design it serves is
|
||||
`03-host-agent.md` §12a item 8: a box that cannot reach Proxmox sends a *short report* — its id, the times, the agent's
|
||||
version, the `proxmox_trust` stanza and one `proxmox_unreachable` stanza with the cause, and no other key.
|
||||
|
||||
The column „with a short report” is CC's reading of the code. **Nothing was run.** A row marked WRONG is a reader that
|
||||
would do harm if it got a short report as it gets a report today.
|
||||
|
||||
## A. The readers on the way in (`internal/api/handler.go`, `handleHostReport`, lines 957–1190)
|
||||
|
||||
| # | Reader | What it reads | With a short report, as the code is today | Needed |
|
||||
|---|---|---|---|---|
|
||||
| 1 | the login and the id check | the box's key; `host_id` | works: the id is in the short report | nothing |
|
||||
| 2 | `store.SaveHostReport` and its summary columns | the whole body, stored as the box's NEWEST report; agent version, CPU, memory, disk percent, guest count, tunnel state into the box's row | **WRONG:** the short report becomes „the newest report”, and the box's row reads disk 0 %, 0 guests, no tunnel. Every reader of part B then sees an empty box | **keep a short report OUT of the report table**: its own columns on the box's row (last seen, unreachable since, cause) |
|
||||
| 3 | `carryEscrow` (a box's first report) | nothing of the body | harmless | skip |
|
||||
| 4 | `checkTunnel` | `cloudflared.status` | **WRONG:** an empty state reads as „no tunnel” | skip |
|
||||
| 5 | `checkHostSwap` | two swap numbers | **WRONG:** zeros can end a real swap alarm | skip |
|
||||
| 6 | `checkWGTunnel` | the `wireguard` stanza | an absent stanza reads as „feature off” — can end a real alarm | skip |
|
||||
| 7 | `checkProxmoxTrust` | the `proxmox_trust` stanza | **wanted** — this is one of the two reasons for the short report | run |
|
||||
| 8 | `checkBoxClock` | `sent_at` | **wanted** | run |
|
||||
| 9 | `checkGuestPowerGaveUp` | the give-up stanza and the list of guests | **WRONG:** with no guests listed, every give-up mark starts its one-week count to be forgotten | skip |
|
||||
| 10 | `checkCrash` | the `system` stanza | absent: no change | skip |
|
||||
| 11 | `checkDeliberateOff` | the power-off stanza | **WRONG:** an absent stanza ends „switched off on purpose” | skip |
|
||||
| 12 | the guest rows (`UpsertGuestFromReport`) | each guest | no guest, no write: harmless | skip |
|
||||
| 13 | the storage, backup, restore-test and off-site-verify log lines and warnings | four lists | nothing listed, nothing said: harmless | skip |
|
||||
| 14 | `noteForeignKeyArchives` | its stanza | absent: no call | skip |
|
||||
| 15 | the agent's log tail | `log_tail` | absent: the request stays pending | skip |
|
||||
| 16 | `store.SaveDRRecipeHostHalf` | the recovery recipe's host half | **WRONG, the worst:** an empty recipe is written over the good one — the recipe is what a recovery after a lost box reads | skip |
|
||||
| 17 | the answer to the box (the control envelope) | nothing of the body: the box's generation, „signed jobs wait”, a pending log request, pending operator actions, „blocked” | **wanted:** a box that cannot reach Proxmox can still take a signed agent update — often the repair | run, and add `accepts_short_report` |
|
||||
| 18 | `ingestHostOperatorActionResults` | results of operator actions | absent: nothing | run (harmless) |
|
||||
|
||||
## B. The readers of a STORED host report (they read the newest row, or the rows of a time window)
|
||||
|
||||
| # | Reader | Where | What it reads | With a short report stored as the newest row |
|
||||
|---|---|---|---|---|
|
||||
| 19 | the OS-update service | `internal/osupdates/service.go:998`, `:1196` | the box's system facts | WRONG: „unknown” facts; a box may be judged „not ready” |
|
||||
| 20 | the kernel lane | `internal/osupdates/kernel.go:108` | the running and default kernel | WRONG: no kernel known |
|
||||
| 21 | the restore-test check | `internal/monitor/restoretest.go:195`, `:252`, `:260` | restore tests of the newest report and of a window | WRONG: the newest row shows none |
|
||||
| 22 | the backup-deadline check | `internal/monitor/deadline.go:356`, `:392`, `:498`, `:514`, `:529` | backups per report, the first report's time | WRONG: the newest row shows none |
|
||||
| 23 | the „escrow pending” check | `internal/monitor/offsite_escrow_pending.go:53` | the first report's time | harmless |
|
||||
| 24 | the controller-supervisor check | `internal/monitor/controller_supervisor.go:96` | the supervisor stanza of every box's newest report | WRONG: an absent stanza reads as „agent too old to tell” |
|
||||
| 25 | the box's page | `internal/web/hosts.go:636`, `:820` | everything shown | WRONG: an empty box |
|
||||
| 26 | the System page | `internal/web/system.go:547` | the system facts | WRONG: „unknown” cells |
|
||||
| 27 | the „host stale” check | `internal/monitor/host_staleness.go` (4 reads of the last-report time) | when the box last reported | wanted in part: the box is alive, so not stale — but it must not read as healthy |
|
||||
| 28 | the host-disk check | `internal/monitor/host_disk.go:77`, `:113` | the disk percent in the box's row | WRONG: 0 % ends a real „disk full” alarm |
|
||||
| 29 | the Hosts list and the dashboard | `internal/web/hosts.go` (10 reads of the last-report time), the summary columns | state, guests, versions | WRONG: 0 guests, „fine” |
|
||||
|
||||
## What the list changes in the design
|
||||
|
||||
**The short report must not be a report to the hub's store.** If it is kept out of the report table and out of the
|
||||
summary columns (row 2), then rows 19 to 26, 28 and the guest part of 29 need NO change: they go on reading the last
|
||||
full report, which is the truth about the box's content as far as anybody knows it.
|
||||
|
||||
What is then left to build, all of it small and in one place each:
|
||||
|
||||
1. `handleHostReport`: a branch at the top for a body that holds `proxmox_unreachable` — it runs rows 1, 7, 8, 17 and
|
||||
18, writes three columns on the box's row (last seen, unreachable since, cause), and returns. Nothing else runs.
|
||||
2. The „host stale” check (row 27) reads „last seen” (a full OR a short report) for liveness.
|
||||
3. One new operator-only alarm per (box, cause), cleared by the first full report.
|
||||
4. The box's page, the Hosts list and the System page (rows 25, 26, 29): one line „reports, cannot reach Proxmox since
|
||||
…; what is shown below is from <time of the last full report>”.
|
||||
5. The answer's new field, and the agent's half (it sends a short report only to a hub that said it understands it).
|
||||
|
||||
One test per row of part A that is marked „skip”: a short report changes nothing there. One test for part B as a
|
||||
whole: after a short report the newest row of the report table is still the last full report.
|
||||
|
||||
**Not read for this list:** the pages' templates field by field; the customer page's Host tab (it renders the same
|
||||
body as the box's page). **The test on a box that settles the design** is in `03` §12a item 8: `pveproxy` stopped for
|
||||
20 minutes on demo-hp.
|
||||
@@ -1,170 +0,0 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Review of 2026-11-15, finding 4: `offsite_end_scheduled` let a box mail its household without limit and with its
|
||||
// own words — 50 subjects gave 50 mails, and the subject and body were the box's sentence. A receipt is now built by
|
||||
// the HUB alone, from a checked app name and parsed dates; a household gets at most receiptsPerDay of them a day.
|
||||
// RED-PROOF: documentation/audits/build-release-4-2026-11-15/A/redproof-review-4.txt.
|
||||
|
||||
func receiptDet(app string, removed time.Time) string {
|
||||
return fmt.Sprintf(`{"stack_name":%q,"removed_at":%q,"ends_at":%q,"subject":"whatever the box says"}`,
|
||||
app, removed.UTC().Format(time.RFC3339), removed.Add(30*24*time.Hour).UTC().Format(time.RFC3339))
|
||||
}
|
||||
|
||||
// A box that posts free words under many subjects: no mail carries its words, and the household gets at most the
|
||||
// daily limit — whatever the subjects, the app names or the times it invents.
|
||||
func TestD84_Receipt_ABoxCannotFloodOrWordTheHouseholdsMail(t *testing.T) {
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", []string{})
|
||||
evil := "ANY WORDS THE BOX CHOOSES: pay at http://evil.example"
|
||||
now := time.Now().UTC()
|
||||
// 50 subjects with no app at all (the review's reproduction): not one mail
|
||||
for i := 0; i < 50; i++ {
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", evil, evil, fmt.Sprintf(`{"subject":"x%d"}`, i), "controller")
|
||||
}
|
||||
if len(*mails) != 0 {
|
||||
t.Fatalf("%d mail(s) for receipts that name no app; subject=%q", len(*mails), (*mails)[0].subject)
|
||||
}
|
||||
// 50 valid-looking presses, each another app and another time, each with the box's own words
|
||||
for i := 0; i < 50; i++ {
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", evil, evil, receiptDet(fmt.Sprintf("app-%d", i), now.Add(-time.Duration(i)*time.Minute)), "controller")
|
||||
}
|
||||
if len(*mails) != receiptsPerDay {
|
||||
t.Fatalf("50 presses in one burst gave %d mails, want the daily limit %d", len(*mails), receiptsPerDay)
|
||||
}
|
||||
for _, m := range *mails {
|
||||
if strings.Contains(m.subject, "evil") || strings.Contains(m.body, "evil") || strings.Contains(m.body, "ANY WORDS") {
|
||||
t.Fatalf("the box's own words reached the household:\n%s\n%s", m.subject, m.body)
|
||||
}
|
||||
if !strings.Contains(m.subject, "a távoli másolatok törlésre kijelölve") || !strings.Contains(m.body, "Mégis megtartom") {
|
||||
t.Fatalf("not the hub's own receipt:\n%s\n%s", m.subject, m.body)
|
||||
}
|
||||
}
|
||||
// the cooldown map did not grow with the box's inventions
|
||||
d.mu.Lock()
|
||||
n := 0
|
||||
for k := range d.custCooldowns {
|
||||
if strings.HasPrefix(k, "c1:offsite_end_scheduled") {
|
||||
n++
|
||||
}
|
||||
}
|
||||
d.mu.Unlock()
|
||||
if n > receiptsPerDay {
|
||||
t.Fatalf("the cooldown map holds %d receipt keys for one household, want at most %d", n, receiptsPerDay)
|
||||
}
|
||||
}
|
||||
|
||||
// What the mail says comes from the details the hub CHECKED: the app name's shape, the dates as times.
|
||||
func TestD84_Receipt_IsBuiltFromCheckedDetailsOnly(t *testing.T) {
|
||||
now := time.Now().UTC()
|
||||
good := func(app string) string { return receiptDet(app, now) }
|
||||
for name, det := range map[string]string{
|
||||
"no stack_name": `{"removed_at":"2026-11-15T10:00:00Z","ends_at":"2026-12-15T10:00:00Z"}`,
|
||||
"a sentence as the app name": strings.Replace(good("x"), `"x"`, `"pay now at evil.example"`, 1),
|
||||
"markup as the app name": strings.Replace(good("x"), `"x"`, `"<b>x</b>"`, 1),
|
||||
"a reserved name": good("traefik"),
|
||||
"the shares": good("_shares"),
|
||||
"removed_at is not a time": `{"stack_name":"vikunja","removed_at":"yesterday","ends_at":"2026-12-15T10:00:00Z"}`,
|
||||
"ends_at is not a time": `{"stack_name":"vikunja","removed_at":"2026-11-15T10:00:00Z","ends_at":"soon; click evil.example"}`,
|
||||
"ends before it was removed": `{"stack_name":"vikunja","removed_at":"2026-11-15T10:00:00Z","ends_at":"2026-11-01T10:00:00Z"}`,
|
||||
"details are not JSON": `not json`,
|
||||
"no details": ``,
|
||||
} {
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", nil)
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", "box words", "box words", det, "controller")
|
||||
if len(*mails) != 0 {
|
||||
t.Errorf("%s: a mail went out: %q", name, (*mails)[0].subject)
|
||||
}
|
||||
}
|
||||
// the date in the mail is the PARSED ends_at, in the household's date form — not text from the box
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", nil)
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", "Törlésük napja: 1999. 01. 01.", "",
|
||||
`{"stack_name":"vikunja","removed_at":"2026-11-15T10:00:00Z","ends_at":"2026-12-15T10:00:00Z"}`, "controller")
|
||||
if len(*mails) != 1 || !strings.Contains((*mails)[0].body, "2026. 12. 15.") || strings.Contains((*mails)[0].body, "1999") {
|
||||
t.Fatalf("the mail must carry the parsed end date and none of the box's text: %+v", *mails)
|
||||
}
|
||||
// the press's key is the checked app + the parsed time: the same press again, with another `subject` and the time
|
||||
// written in another zone, is NOT a second mail
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", "x", "",
|
||||
`{"stack_name":"vikunja","removed_at":"2026-11-15T11:00:00+01:00","ends_at":"2026-12-15T10:00:00Z","subject":"another"}`, "controller")
|
||||
if len(*mails) != 1 {
|
||||
t.Fatalf("one press sent twice with a changed subject gave %d mails", len(*mails))
|
||||
}
|
||||
}
|
||||
|
||||
// A blocked household gets no receipt.
|
||||
func TestD84_Receipt_ABlockedHouseholdGetsNone(t *testing.T) {
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", nil)
|
||||
if err := d.store.SetCustomerConfigStatus("c1", "blocked"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", "x", "", receiptDet("vikunja", time.Now()), "controller")
|
||||
if len(*mails) != 0 {
|
||||
t.Fatalf("a blocked household was mailed: %+v", *mails)
|
||||
}
|
||||
if err := d.store.SetCustomerConfigStatus("c1", "active"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", "x", "", receiptDet("vikunja", time.Now()), "controller")
|
||||
if len(*mails) != 1 {
|
||||
t.Fatalf("positive control: an unblocked household must get the receipt, got %d", len(*mails))
|
||||
}
|
||||
}
|
||||
|
||||
// The map of mailed presses does not grow for ever: a household's receipt keys older than a day go at its next
|
||||
// receipt; another household's keys and other event types' keys are not touched.
|
||||
func TestD84_Receipt_OldPressesLeaveTheCooldownMap(t *testing.T) {
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", nil)
|
||||
old := time.Now().Add(-25 * time.Hour)
|
||||
d.mu.Lock()
|
||||
for i := 0; i < 30; i++ {
|
||||
d.custCooldowns[fmt.Sprintf("c1:offsite_end_scheduled:old-%d|x", i)] = old
|
||||
}
|
||||
d.custCooldowns["c2:offsite_end_scheduled:other|x"] = old
|
||||
d.custCooldowns["c1:app_update_undone:vikunja"] = old
|
||||
d.mu.Unlock()
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", "x", "", receiptDet("vikunja", time.Now()), "controller")
|
||||
if len(*mails) != 1 {
|
||||
t.Fatalf("30 presses of yesterday must not count against today's limit: %d mail(s)", len(*mails))
|
||||
}
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
n := 0
|
||||
for k := range d.custCooldowns {
|
||||
if strings.HasPrefix(k, "c1:offsite_end_scheduled:") {
|
||||
n++
|
||||
}
|
||||
}
|
||||
if n != 1 {
|
||||
t.Fatalf("the household's receipt keys: %d, want only today's one", n)
|
||||
}
|
||||
if _, ok := d.custCooldowns["c2:offsite_end_scheduled:other|x"]; !ok {
|
||||
t.Fatal("another household's key was removed")
|
||||
}
|
||||
if _, ok := d.custCooldowns["c1:app_update_undone:vikunja"]; !ok {
|
||||
t.Fatal("another event type's key was removed")
|
||||
}
|
||||
}
|
||||
|
||||
// The daily limit is the hub's own SENT LOG, so a hub restart (an empty map) does not give a box five more.
|
||||
func TestD84_Receipt_TheDailyLimitSurvivesARestart(t *testing.T) {
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", nil)
|
||||
for i := 0; i < receiptsPerDay; i++ {
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", "x", "", receiptDet(fmt.Sprintf("app-%d", i), time.Now()), "controller")
|
||||
}
|
||||
if len(*mails) != receiptsPerDay {
|
||||
t.Fatalf("fixture: %d mails", len(*mails))
|
||||
}
|
||||
d.mu.Lock()
|
||||
d.custCooldowns = map[string]time.Time{} // the restart
|
||||
d.mu.Unlock()
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", "x", "", receiptDet("one-more", time.Now()), "controller")
|
||||
if len(*mails) != receiptsPerDay {
|
||||
t.Fatalf("after a restart the household got mail number %d of the day (limit %d)", len(*mails), receiptsPerDay)
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// D84 (`09` §3 decision 309; `07-backup-architecture.md` §8.2f): the household gets ONE mail at the moment it presses
|
||||
// „delete backup data”, naming the app, the end date and how to take it back.
|
||||
// RED-PROOFS: documentation/audits/build-release-4-2026-11-15/A/redproof-hub-mail.txt.
|
||||
|
||||
type receiptMail struct{ to, subject, body string }
|
||||
|
||||
func receiptDispatcher(t *testing.T, prefsEmail string, enabled []string) (*Dispatcher, *[]receiptMail) {
|
||||
t.Helper()
|
||||
st := opOnlyStore(t)
|
||||
if prefsEmail != "" || enabled != nil {
|
||||
if err := st.SaveNotificationPrefs("c1", prefsEmail, enabled, 6); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
d := opOnlyDispatcher(t, st, &sentTo{})
|
||||
var mails []receiptMail
|
||||
d.sendEmailFn = func(to, subject, body string, _ map[string]string) error {
|
||||
mails = append(mails, receiptMail{to, subject, body})
|
||||
return nil
|
||||
}
|
||||
return d, &mails
|
||||
}
|
||||
|
||||
const (
|
||||
receiptHU = "vikunja: az alkalmazás távoli másolatai törlésre vannak kijelölve. Törlésük napja: 2026. 12. 15. Addig a Mentések oldalon a „Mégis megtartom” gombbal visszavonhatod."
|
||||
receiptEN = "vikunja: the off-site copies of this app are marked for deletion. They are deleted on: 2026-12-15. Until then you can take this back on the Backups page with the “Keep it after all” button."
|
||||
receiptDetails = `{"stack_name":"vikunja","removed_at":"2026-11-15T10:00:00Z","ends_at":"2026-12-15T10:00:00Z","subject":"vikunja|2026-11-15T10:00:00Z"}`
|
||||
)
|
||||
|
||||
// The mail reaches the household's own address although EVERY group switch is off, names the app in the subject, and
|
||||
// carries the box's sentence (the day, the way back). The operator is not mailed.
|
||||
func TestD84_Receipt_ReachesTheHouseholdWhateverItsSwitches(t *testing.T) {
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", []string{})
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", receiptHU, "", receiptDetails, "controller")
|
||||
if len(*mails) != 1 {
|
||||
t.Fatalf("mails = %d, want exactly one (to the household): %+v", len(*mails), *mails)
|
||||
}
|
||||
m := (*mails)[0]
|
||||
if m.to != "customer@example.com" {
|
||||
t.Fatalf("the receipt went to %q, not to the household's own address", m.to)
|
||||
}
|
||||
if !strings.Contains(m.subject, "vikunja: a távoli másolatok törlésre kijelölve") {
|
||||
t.Fatalf("the subject does not name the app: %q", m.subject)
|
||||
}
|
||||
for _, want := range []string{"2026. 12. 15.", "Mégis megtartom", "Mentések oldalon"} {
|
||||
if !strings.Contains(m.body, want) {
|
||||
t.Fatalf("the body lacks %q:\n%s", want, m.body)
|
||||
}
|
||||
}
|
||||
if strings.Contains(m.body, "removed_at") || strings.Contains(m.body, "{") {
|
||||
t.Fatalf("the body carries the raw details:\n%s", m.body)
|
||||
}
|
||||
}
|
||||
|
||||
// An English household reads it in English (the box's own second sentence, R-558).
|
||||
func TestD84_Receipt_FollowsTheHouseholdsLanguage(t *testing.T) {
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", nil)
|
||||
if err := d.store.SaveReport("c1", []byte(`{"customer_id":"c1","language":"en"}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", receiptHU, receiptEN, receiptDetails, "controller")
|
||||
if len(*mails) != 1 {
|
||||
t.Fatalf("mails = %d: %+v", len(*mails), *mails)
|
||||
}
|
||||
m := (*mails)[0]
|
||||
if !strings.Contains(m.subject, "vikunja: the off-site copies are marked for deletion") || !strings.Contains(m.body, "Keep it after all") || !strings.Contains(m.body, "2026-12-15") {
|
||||
t.Fatalf("not the English receipt:\n%s\n%s", m.subject, m.body)
|
||||
}
|
||||
if strings.Contains(m.body, "Mégis megtartom") {
|
||||
t.Fatalf("Hungarian in an English household's mail:\n%s", m.body)
|
||||
}
|
||||
}
|
||||
|
||||
// Once per press: the same press delivered twice is one mail; a second app, or the same app removed again later, is
|
||||
// its own mail — also inside the household's cooldown.
|
||||
func TestD84_Receipt_OncePerPress(t *testing.T) {
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", nil)
|
||||
send := func(app, removedAt string) {
|
||||
det := `{"stack_name":"` + app + `","removed_at":"` + removedAt + `","ends_at":"2026-12-15T10:00:00Z","subject":"` + app + `|` + removedAt + `"}`
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", "x "+app, "", det, "controller")
|
||||
}
|
||||
send("vikunja", "2026-11-15T10:00:00Z")
|
||||
send("vikunja", "2026-11-15T10:00:00Z") // the same press, delivered again
|
||||
if len(*mails) != 1 {
|
||||
t.Fatalf("one press gave %d mails", len(*mails))
|
||||
}
|
||||
send("immich", "2026-11-15T10:05:00Z") // another app, five minutes later
|
||||
send("vikunja", "2026-11-15T11:00:00Z") // installed again, removed again
|
||||
if len(*mails) != 3 {
|
||||
t.Fatalf("three presses gave %d mails, want 3: %+v", len(*mails), *mails)
|
||||
}
|
||||
}
|
||||
|
||||
// A household with no address gets no mail (the page is all it has), and nobody else is mailed in its place.
|
||||
func TestD84_Receipt_NoAddressNoMail(t *testing.T) {
|
||||
d, mails := receiptDispatcher(t, "", nil)
|
||||
d.ProcessBoxEvent("c1", "offsite_end_scheduled", "info", receiptHU, "", receiptDetails, "controller")
|
||||
if len(*mails) != 0 {
|
||||
t.Fatalf("a household with no address: %d mail(s) went out: %+v", len(*mails), *mails)
|
||||
}
|
||||
}
|
||||
|
||||
// The receipt register does not open any other type: an ordinary info event still mails nobody, and a type the
|
||||
// household switched off still stays off.
|
||||
func TestD84_Receipt_OpensNothingElse(t *testing.T) {
|
||||
d, mails := receiptDispatcher(t, "customer@example.com", []string{})
|
||||
d.ProcessBoxEvent("c1", "app_removed", "info", "Alkalmazás eltávolítva.", "", `{"stack_name":"vikunja"}`, "controller")
|
||||
d.ProcessBoxEvent("c1", "app_stopped_unhealthy", "error", "x", "", `{"stack_name":"vikunja"}`, "controller")
|
||||
for _, m := range *mails {
|
||||
if m.to == "customer@example.com" {
|
||||
t.Fatalf("the household was mailed a type it switched off / an info event: %+v", m)
|
||||
}
|
||||
}
|
||||
if len(householdReceiptEvents) != 1 || !householdReceiptEvents["offsite_end_scheduled"] {
|
||||
t.Fatalf("the receipt register changed: %v — every entry bypasses the household's switches and needs its own ruling", householdReceiptEvents)
|
||||
}
|
||||
if operatorOnlyEvents["offsite_end_scheduled"] {
|
||||
t.Fatal("a receipt cannot be operator-only")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user