configuredSecretRegistry resolved provider keys in place, and the State Store's copy of the config shared the providers map with b.cfg, so ImportConfig seeded the process-local ARCHIE_PROVIDER_<hash> env name. Provider resolution now runs only in the daemon and gateway boot (openStores).
27 lines
935 B
Go
27 lines
935 B
Go
package archied
|
|
|
|
import (
|
|
"log/slog"
|
|
"testing"
|
|
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"github.com/samcharles93/archie-core/internal/secret"
|
|
)
|
|
|
|
// The State Store seeds provider-settings from the config it booted with, so
|
|
// building its secret registry must leave every provider's source reference
|
|
// in place rather than rewriting it to a process-local env name.
|
|
func TestConfiguredSecretRegistryKeepsProviderReferences(t *testing.T) {
|
|
ref := secret.SecretRef{Engine: "env", Key: "OPENAI_KEY"}
|
|
t.Setenv("OPENAI_KEY", "sk-test")
|
|
cfg := config.Config{Providers: map[string]config.Provider{"openai": {Class: "openai", APIKey: ref}}}
|
|
|
|
if _, err := configuredSecretRegistry(&cfg, slog.New(slog.DiscardHandler)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got := cfg.Providers["openai"]
|
|
if got.APIKey != ref || got.APIKeyEnv != "" {
|
|
t.Fatalf("provider rewritten: api_key=%+v api_key_env=%q", got.APIKey, got.APIKeyEnv)
|
|
}
|
|
}
|