Resolve authentication diagnostics by provider
This commit is contained in:
30
internal/llm/provider_test.go
Normal file
30
internal/llm/provider_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package llm
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"go.maximumdirect.net/promptkit/internal/domain"
|
||||
)
|
||||
|
||||
func TestAuthenticationSelection(t *testing.T) {
|
||||
none, explicit, endpoint := "none", "openrouter_key", "https://diagnostics.example/probe"
|
||||
for _, tc := range []struct {
|
||||
name, provider, adapter, destination string
|
||||
metadata *domain.BackendSmokeTestConfig
|
||||
}{
|
||||
{name: "provider default", provider: "openrouter", adapter: "openrouter_key", destination: "https://example.test/v1/key"},
|
||||
{name: "cleared block", provider: "openrouter", metadata: &domain.BackendSmokeTestConfig{}, adapter: "openrouter_key", destination: "https://example.test/v1/key"},
|
||||
{name: "endpoint only", provider: "openrouter", metadata: &domain.BackendSmokeTestConfig{Authentication: &domain.AuthenticationProbeConfig{Endpoint: &endpoint}}, adapter: "openrouter_key", destination: endpoint},
|
||||
{name: "explicit adapter", metadata: &domain.BackendSmokeTestConfig{Authentication: &domain.AuthenticationProbeConfig{Kind: &explicit}}, adapter: "openrouter_key", destination: "https://example.test/v1/key"},
|
||||
{name: "disabled", provider: "openrouter", metadata: &domain.BackendSmokeTestConfig{Authentication: &domain.AuthenticationProbeConfig{Kind: &none}}, adapter: "none", destination: "https://example.test/v1"},
|
||||
{name: "generic unsupported", destination: "https://example.test/v1"},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
kind := AuthenticationAdapter(tc.provider, tc.metadata)
|
||||
destination, err := AuthenticationEndpoint(kind, "https://example.test/v1", tc.metadata)
|
||||
if err != nil || kind != tc.adapter || destination != tc.destination {
|
||||
t.Fatalf("selection=%q destination=%q error=%v", kind, destination, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user