package monitor import ( "testing" "gitea.dooplex.hu/admin/felhom-controller/internal/config" ) func contains(ss []string, want string) bool { for _, s := range ss { if s == want { return true } } return false } // EffectiveProtected must drop cloudflared when no tunnel token is configured (LAN-only node), so the // health loop doesn't report it missing forever — but keep it when a token IS configured. func TestEffectiveProtectedDropsCloudflaredWithoutToken(t *testing.T) { base := config.StacksConfig{Protected: []string{"traefik", "cloudflared", "felhom-controller", "filebrowser"}} cfgNoTok := &config.Config{Stacks: base} got := EffectiveProtected(cfgNoTok) if contains(got, "cloudflared") { t.Errorf("cloudflared must be dropped when no tunnel token: %v", got) } for _, must := range []string{"traefik", "felhom-controller", "filebrowser"} { if !contains(got, must) { t.Errorf("%s must remain protected: %v", must, got) } } cfgTok := &config.Config{Stacks: base} cfgTok.Infrastructure.CFTunnelToken = "tok" if !contains(EffectiveProtected(cfgTok), "cloudflared") { t.Error("cloudflared must remain protected when a tunnel token is configured") } }