e66d4669d6
gates / gates (push) Failing after 47s
An app was six pages — details, install/settings, logs, export, the per-app backup panel and a
details card for moving data — and every "Vissza" on them went to the app LIST, so there was no way
back to the app you were looking at. It is now ONE page with four tab URLs under /apps/{slug}/,
one shared header and one set of banners.
settings Mukodes (Start/Restart/Stop, Stop confirms) + the cards that want something from the
household + the install-time and optional settings. The default for an installed app,
RENDERED at the bare URL and never redirected to.
data the data folders, move to another drive, the nightly copy, the 2nd-copy setting, export
guide tagline, screenshots, use cases, first steps, the catalog's guide, the FAQ, the docs
link — and the WHOLE page for an app that is not installed
logs the log, and the only tab whose poller runs
The tabs are links, not panels: a link in an alert has to land ON a tab, and the log poller must not
run on the other three. Start/Restart/Stop left the page header, where they read as menu buttons.
The old /stacks/{name}/{deploy,logs,export,backup} GETs answer 302 — never 301, which a browser
caches beyond anyone's reach — to the tab that now holds them, query string carried through, with
name->slug resolved through the stack list rather than assumed equal. Every POST on those paths is
untouched: the backup form, the app-email toggle and the reveal endpoints keep their URLs.
A value asked AFTER the app starts is now generic (D2). The catalog marks a field `after_start: true`
and supplies its label; the ACTION is Go, in a registry keyed by slug + env var. The catalog can
never declare what runs — a declared field with no registered action renders nothing, POSTs 404 and
logs one WARN with the env var KEY, never the value. A red-proof found the second half of that guard
unpinned: deleting the "the catalog must have DECLARED this field" check left the suite green, and a
POST for an undeclared field then reached Plex and opened the setup gate.
TestAfterStart_RegistryAloneIsNotAnInvitation pins it.
New catalog block app_info.guide (sections + faq + checked_version), parsed, localised field by
field and rendered with the household's own address filled in. It renders only when checked_version
names the image tag its author clicked through. No template carries one yet.
The Pi and "csak x86" badges are gone; PiCompatible and the catalog key stay this release, or a box
on 0.314.0 would read "csak x86" on every app (R-1067).
template_id_gate.py now follows {{template}} includes, with a scope decoy proving the walk did not
become vacuous.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117kRTSgs3rJWUFGxyoWN6Y
110 lines
4.4 KiB
Go
110 lines
4.4 KiB
Go
package web
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"io"
|
|
"log"
|
|
"net/http/httptest"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/agentapi"
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/backup"
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/config"
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/stacks"
|
|
)
|
|
|
|
// R-499 — an app on the system disk was told „már szerepelnek a teljes rendszermentésben (PBS)" and
|
|
// „nincs külön teendő" on every box, including one whose only whole-system copy sat on the SAME disk
|
|
// (measured 2026-09-14). The page must now say what is true for THIS box.
|
|
|
|
// tier2PageServer builds a real Server with one deployed, driveless app ("privatebin") and the
|
|
// agent's tier/disk answers injected through the production seams, then renders the real handler.
|
|
func tier2PageServer(t *testing.T, tiers func(context.Context) (agentapi.TiersResponse, error), disks []agentapi.DiskInfo) string {
|
|
t.Helper()
|
|
lg := log.New(io.Discard, "", 0)
|
|
dir := t.TempDir()
|
|
cfg := &config.Config{}
|
|
cfg.Paths.StacksDir = filepath.Join(dir, "stacks")
|
|
cfg.Paths.DataDir = filepath.Join(dir, "data")
|
|
cfg.Paths.SystemDataPath = filepath.Join(dir, "system")
|
|
cfg.Stacks.ComposeCommand = "docker compose"
|
|
cfg.Backup.Enabled = true
|
|
app := filepath.Join(cfg.Paths.StacksDir, "privatebin")
|
|
if err := os.MkdirAll(app, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
os.WriteFile(filepath.Join(app, "docker-compose.yml"), []byte("services:\n privatebin:\n image: privatebin/pdo:2.0.6\n"), 0o644)
|
|
os.WriteFile(filepath.Join(app, "app.yaml"), []byte("deployed: true\n"), 0o600)
|
|
sett, err := settings.Load(filepath.Join(dir, "settings.json"), lg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
sm, err := stacks.NewManager(cfg, lg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := sm.ScanStacks(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
bm := backup.NewManager(cfg, sett, lg)
|
|
bm.SetStackProvider(&blockProvider{hdd: ""}) // driveless: IsHDDApp false
|
|
s := &Server{cfg: cfg, settings: sett, stackMgr: sm, backupMgr: bm, logger: lg, version: "test"}
|
|
s.tiersFn = tiers
|
|
s.disksFn = func(context.Context) (agentapi.DisksResponse, error) {
|
|
return agentapi.DisksResponse{Disks: disks}, nil
|
|
}
|
|
s.loadTemplates()
|
|
w := httptest.NewRecorder()
|
|
s.appPageHandler(w, httptest.NewRequest("GET", "/apps/privatebin/data", nil), "privatebin", appTabData)
|
|
if w.Code != 200 {
|
|
t.Fatalf("page answered %d", w.Code)
|
|
}
|
|
return w.Body.String()
|
|
}
|
|
|
|
func primaryTier(target string) func(context.Context) (agentapi.TiersResponse, error) {
|
|
return func(context.Context) (agentapi.TiersResponse, error) {
|
|
return agentapi.TiersResponse{Tiers: []agentapi.BackupTierInfo{{Target: target, Primary: true}}}, nil
|
|
}
|
|
}
|
|
|
|
// COMPANION RED-PROOF: rendering the old sentence for every branch (the pre-fix template) makes the
|
|
// same_disk case fail on `promises the backup protects this app`.
|
|
func TestR499_Tier2PageSaysWhatIsTrueForThisBox(t *testing.T) {
|
|
ownDrive := agentapi.DiskInfo{Name: "mentes", MountPath: "/mnt/mentes", GuestPath: "/mnt/felhom-drives/mentes", Role: "user-data", BackupTarget: true}
|
|
cases := []struct {
|
|
name, want string
|
|
tiers func(context.Context) (agentapi.TiersResponse, error)
|
|
disks []agentapi.DiskInfo
|
|
}{
|
|
{"same disk (the measured box)", "same_disk", primaryTier("local"), nil},
|
|
{"own drive", "protected", primaryTier("felhom-backup"), []agentapi.DiskInfo{ownDrive}},
|
|
{"configured drive gone", "absent", primaryTier("felhom-backup"), nil},
|
|
{"agent not askable", "unknown", func(context.Context) (agentapi.TiersResponse, error) {
|
|
return agentapi.TiersResponse{}, errors.New("down")
|
|
}, nil},
|
|
}
|
|
for _, c := range cases {
|
|
body := tier2PageServer(t, c.tiers, c.disks)
|
|
if !strings.Contains(body, `data-system-backup="`+c.want+`"`) {
|
|
t.Errorf("%s: want branch %q on the page", c.name, c.want)
|
|
}
|
|
// ASCII fragments (ui-hungarian rule): "(PBS)" and "nincs k" of „nincs külön teendő".
|
|
if strings.Contains(body, "(PBS)") {
|
|
t.Errorf("%s: the page still names PBS, which this box may not have", c.name)
|
|
}
|
|
promises := strings.Contains(body, "nincs k")
|
|
if c.want == "protected" && !promises {
|
|
t.Errorf("%s: control — the protected branch must still say there is nothing to do", c.name)
|
|
}
|
|
if c.want != "protected" && promises {
|
|
t.Errorf("%s: promises the backup protects this app (\"nothing to do\") on a box where it may not", c.name)
|
|
}
|
|
}
|
|
}
|