// Copyright (C) 2026 Dcntrlized // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . package config import "testing" func TestFromEnvRequiresTokenReposAndSecret(t *testing.T) { t.Setenv("GITEA_TOKEN", "") t.Setenv("REPOS", "") t.Setenv("WEBHOOK_SECRET", "") if _, err := FromEnv(); err == nil { t.Fatal("empty environment accepted") } t.Setenv("GITEA_TOKEN", "tok") if _, err := FromEnv(); err == nil { t.Fatal("missing REPOS accepted") } t.Setenv("REPOS", "Dcntrlized/Maestro") if _, err := FromEnv(); err == nil { t.Fatal("missing WEBHOOK_SECRET accepted (webhooks are the only trigger)") } t.Setenv("WEBHOOK_SECRET", "s3cret") cfg, err := FromEnv() if err != nil { t.Fatalf("valid environment rejected: %v", err) } if cfg.StatusContext != "license-bot / addlicense" { t.Fatalf("StatusContext = %q", cfg.StatusContext) } if !cfg.Allows("dcntrlized/maestro") { t.Fatal("allowlist is not case-insensitive") } if cfg.Allows("Dcntrlized/Other") { t.Fatal("allowlist accepted a repository outside it") } }