Files
felhom-controller/controller/internal/web/kept_fb_test.go
T
admin 43e99d160c
gates / gates (push) Successful in 26s
kept data: the choice at reinstall, the list, the read-only view, the load (09 decision 36); R-690 fixed
An install over an app's kept drive folder (appdata/<app> non-empty) asks the household:
"use my kept data" (a load from the newest copy of THIS drive's install, own unit or
second-drive mirror, then the template's after_load) or "start fresh" (the folder is
renamed into <drive>/kept/<app>/<date>/ with the removed app's unit; nothing deleted).
The install API answers 409 kept_data_choice until one is chosen; DeployStack refuses
too. New page Megorzott adatok / Kept data (/kept-data): Load / Look / Delete (typed
confirmation, the only deletion of kept data). FileBrowser gets a read-only source.
The drive-full warning names the kept folders. <drive>/kept is protected and outside
every backup leg.

R-690: the removed-app restore (R-487) never found a unit on a DATA drive — it asked
GetStackComposePath (true for every catalog app) and restored nextcloud with no env.
Now isStackDeployed; pinned with a production-shaped provider.

Red-proofs: audits/night-2026-09-26/E/redproofs/.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
2026-09-25 13:32:30 +02:00

32 lines
1.2 KiB
Go

package web
import (
"strings"
"testing"
"gitea.dooplex.hu/admin/felhom-controller/internal/stacks"
)
// `09` §3 decision 36 — the file browser's kept-data view is READ-ONLY: every bind ends in :ro, and
// two items never collide on one name.
// COMPANION RED-PROOF: drop the ":ro" suffix in keptBindLines → fails.
func TestKept_FileBrowserBindsAreReadOnly(t *testing.T) {
items := []stacks.KeptItem{
{Path: "/mnt/felhom-drives/hdd_1/kept/nextcloud/2026-09-25_130000", Drive: "/mnt/felhom-drives/hdd_1", Kind: stacks.KeptKindDated},
{Path: "/mnt/felhom-drives/hdd_1/kept/nextcloud/2026-09-26_090000", Drive: "/mnt/felhom-drives/hdd_1", Kind: stacks.KeptKindDated},
{Path: "/mnt/felhom-drives/hdd_1/appdata/nextcloud", Drive: "/mnt/felhom-drives/hdd_1", Kind: stacks.KeptKindLeftover},
}
lines := keptBindLines(items)
seen := map[string]bool{}
for i, l := range lines {
if !strings.HasSuffix(l, ":ro") || !strings.HasPrefix(l, " - "+items[i].Path+":/srv/megorzott/") {
t.Fatalf("bind %q is not a read-only bind of %s under /srv/megorzott", l, items[i].Path)
}
target := strings.Split(l, ":")[1]
if seen[target] {
t.Fatalf("two kept items share %s", target)
}
seen[target] = true
}
}