Pass effective paths through configuration loading

This commit is contained in:
2026-10-17 05:33:03 +00:00
parent 5e58b6944b
commit 0cd833513c
5 changed files with 90 additions and 32 deletions

View File

@@ -0,0 +1,29 @@
package configuration
import (
"testing"
"gitea.maximumdirect.net/eric/ConfigKit"
)
func TestSecretProviderPathRecognizesResourceExtraParams(t *testing.T) {
tests := []struct {
name string
path configkit.Path
want bool
}{
{name: "backend nested secret", path: configkit.Keys("backends", "provider", "extra_params", "nested", "Token"), want: true},
{name: "profile nested secret", path: configkit.Keys("profiles", "assistant", "extra_params", "authorization"), want: true},
{name: "unrelated nested mapping", path: configkit.Keys("application", "backends", "provider", "extra_params", "token"), want: false},
{name: "extra params outside resource map", path: configkit.Keys("backends", "provider", "options", "extra_params", "token"), want: false},
{name: "missing resource key", path: configkit.Keys("backends", "", "extra_params", "token"), want: false},
{name: "ordinary provider value", path: configkit.Keys("profiles", "assistant", "extra_params", "provider", "mode"), want: false},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if got := secretProviderPath(test.path); got != test.want {
t.Fatalf("secretProviderPath(%q) = %t, want %t", test.path, got, test.want)
}
})
}
}