This commit is contained in:
2026-10-20 02:43:27 +01:00
commit 545a9b6b88
21 changed files with 3654 additions and 0 deletions
@@ -0,0 +1,52 @@
// 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 <https://www.gnu.org/licenses/>.
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")
}
}