mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
a04b8fd564
- Rename `llm_providers` → `providers`, `llm_provider_oauth_tokens` → `provider_oauth_tokens` - Remove `tts_providers` and `tts_models` tables; speech models now live in the unified `models` table with `type = 'speech'` - Replace top-level `api_key`/`base_url` columns with a JSONB `config` field on `providers` - Rename `llm_provider_id` → `provider_id` across all references - Add `edge-speech` client type and `conf/providers/edge.yaml` default provider - Create new read-only speech endpoints (`/speech-providers`, `/speech-models`) backed by filtered views of the unified tables - Remove old TTS CRUD handlers; simplify speech page to read-only + test - Update registry loader to skip malformed YAML files instead of failing entirely - Fix YAML quoting for model names containing colons in openrouter.yaml - Regenerate sqlc, swagger, and TypeScript SDK
37 lines
853 B
Go
37 lines
853 B
Go
package providers
|
|
|
|
import "testing"
|
|
|
|
func TestMaskAPIKey(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
t.Run("short key is fully masked", func(t *testing.T) {
|
|
t.Parallel()
|
|
if got := maskAPIKey("sk-12"); got != "*****" {
|
|
t.Fatalf("expected fully masked, got %q", got)
|
|
}
|
|
})
|
|
|
|
t.Run("long key preserves prefix", func(t *testing.T) {
|
|
t.Parallel()
|
|
key := "sk-1234567890abcdef"
|
|
masked := maskAPIKey(key)
|
|
if masked == key {
|
|
t.Fatal("masked key should differ from original")
|
|
}
|
|
if len(masked) != len(key) {
|
|
t.Fatalf("masked length %d != original length %d", len(masked), len(key))
|
|
}
|
|
if masked[:8] != key[:8] {
|
|
t.Fatalf("prefix mismatch: %q vs %q", masked[:8], key[:8])
|
|
}
|
|
})
|
|
|
|
t.Run("empty key returns empty", func(t *testing.T) {
|
|
t.Parallel()
|
|
if got := maskAPIKey(""); got != "" {
|
|
t.Fatalf("expected empty, got %q", got)
|
|
}
|
|
})
|
|
}
|