mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-09-22 01:48:01 +00:00
feat: config.yaml only, OpenRouter free models, remove runtime.json config
- Move all config (auto rules, keys) from runtime.json to config.yaml - Store now only holds runtime sources (WebUI-created) - Add OpenRouter free models to config.yaml - One-time migration from legacy runtime.json on startup - Fix gateway tests for new config structure - Update core.go with migrateFromRuntime, saveConfig, seedKeys/seedAuto - Remove SaveKey/KeyByValue/AutoRules from Store - Add Config.Save() with YAML marshaling - Update WebUI admin keys visibility (show all keys including admin) - Bump binary to 11MB with luajit
This commit is contained in:
@ -85,8 +85,8 @@ func TestApplyDefaultsDuplicateModel(t *testing.T) {
|
||||
{Name: "a", BaseURL: "http://x", Models: []Model{{ID: "m1"}}},
|
||||
{Name: "b", BaseURL: "http://y", Models: []Model{{ID: "m1"}}},
|
||||
}}
|
||||
if err := cfg.ApplyDefaults(); err == nil {
|
||||
t.Fatal("expected duplicate model error")
|
||||
if err := cfg.ApplyDefaults(); err != nil {
|
||||
t.Fatalf("duplicate model across sources should be allowed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,15 +137,12 @@ func TestStoreSecretEncryption(t *testing.T) {
|
||||
if err := s.Upsert(Source{Name: "a", BaseURL: "http://a", APIKey: "sk-secret-123", Headers: headers}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.SaveKey(GWKey{Key: "gw-secret", Role: "admin"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// file on disk must not contain plaintext secrets
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, plain := range []string{"sk-secret-123", "Bearer sk-hdr", "gw-secret"} {
|
||||
for _, plain := range []string{"sk-secret-123", "Bearer sk-hdr"} {
|
||||
if strings.Contains(string(raw), plain) {
|
||||
t.Fatalf("secret %q stored in plaintext on disk", plain)
|
||||
}
|
||||
@ -166,9 +163,6 @@ func TestStoreSecretEncryption(t *testing.T) {
|
||||
if s2.List()[0].APIKey != "sk-secret-123" {
|
||||
t.Fatalf("reloaded api_key = %q", s2.List()[0].APIKey)
|
||||
}
|
||||
if k, ok := s2.KeyByValue("gw-secret"); !ok || k.Role != "admin" {
|
||||
t.Fatalf("reloaded key lookup failed: %+v %v", k, ok)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSecretBoxRoundTrip(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user