2026-08-19 20:52:13 -07:00
|
|
|
package config_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-08-21 20:46:42 -07:00
|
|
|
"forgejo.riotpiao.com/rock/homelab-frontend/internal/config"
|
2026-08-19 20:52:13 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// TestLoadRoutesMissingAuthRequired tests that the auth-required flag is not a silent default:
|
|
|
|
|
// if it is absent from YAML, startup must fail with a message naming the offending route and field.
|
|
|
|
|
func TestLoadRoutesMissingAuthRequired(t *testing.T) {
|
|
|
|
|
routes, err := config.LoadRoutesFromFile("../../testdata/config/missing-authRequired.yaml")
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("expected error for missing authRequired, got nil")
|
|
|
|
|
}
|
|
|
|
|
if routes != nil {
|
|
|
|
|
t.Error("expected nil routes on error")
|
|
|
|
|
}
|
|
|
|
|
want := "route \"test-route\": field 'authRequired' is required"
|
|
|
|
|
got := err.Error()
|
|
|
|
|
if got != want {
|
|
|
|
|
t.Fatalf("error did not name the offending route and field; want %q, got %q", want, got)
|
|
|
|
|
}
|
|
|
|
|
}
|