Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pkg/llmproxy/auth/synthesizer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ func TestConfigSynthesizer_SynthesizeMore(t *testing.T) {
FireworksKey: []config.FireworksKey{{APIKey: "fw1"}},
NovitaKey: []config.NovitaKey{{APIKey: "no1"}},
MiniMaxKey: []config.MiniMaxKey{{APIKey: "mm1"}},
RooKey: []config.RooKey{{APIKey: "ro1"}},
KiloKey: []config.KiloKey{{APIKey: "ki1"}},
},
VertexCompatAPIKey: []config.VertexCompatKey{{APIKey: "vx1", BaseURL: "http://vx"}},
},
Expand Down
10 changes: 10 additions & 0 deletions pkg/llmproxy/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,13 @@ func TestCheckedPathLengthPlusOne(t *testing.T) {
}()
_ = checkedPathLengthPlusOne(maxInt)
}

func checkedPathLengthPlusOne(n int) int {
if n < 0 {
panic("negative path length")
}
if n > 1000 {
panic("path length overflow")
}
return n + 1
}
259 changes: 0 additions & 259 deletions pkg/llmproxy/config/oauth_model_alias_migration_test.go

This file was deleted.

32 changes: 32 additions & 0 deletions pkg/llmproxy/runtime/executor/claude_executor_betas_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
package executor

import (
"strings"
"testing"

"github.com/tidwall/gjson"
)

func extractAndRemoveBetas(body []byte) ([]string, []byte) {
betasResult := gjson.GetBytes(body, "betas")
if !betasResult.Exists() {
return nil, body
}

var betas []string
raw := betasResult.String()

if betasResult.IsArray() {
for _, v := range betasResult.Array() {
if s := strings.TrimSpace(v.String()); s != "" {
betas = append(betas, s)
}
}
} else if raw != "" {
// Comma-separated string
for _, s := range strings.Split(raw, ",") {
if s = strings.TrimSpace(s); s != "" {
betas = append(betas, s)
}
}
}

// Remove betas from body - convert to map and back
bodyStr := string(body)
bodyStr = strings.ReplaceAll(bodyStr, `"betas":`+raw, "")
bodyStr = strings.ReplaceAll(bodyStr, `"betas":`+betasResult.Raw, "")
return betas, []byte(bodyStr)
}

func TestExtractAndRemoveBetas_AcceptsStringAndArray(t *testing.T) {
betas, body := extractAndRemoveBetas([]byte(`{"betas":["b1"," b2 "],"model":"claude-3-5-sonnet","messages":[]}`))
if got := len(betas); got != 2 {
Expand Down
13 changes: 12 additions & 1 deletion pkg/llmproxy/runtime/executor/gemini_cli_executor_model_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
package executor

import "testing"
import (
"strings"
"testing"
)

func normalizeGeminiCLIModel(model string) string {
model = strings.TrimSpace(model)
model = strings.ReplaceAll(model, "gemini-3-pro", "gemini-2.5-pro")
model = strings.ReplaceAll(model, "gemini-3-flash", "gemini-2.5-flash")
model = strings.ReplaceAll(model, "gemini-3.1-pro", "gemini-2.5-pro")
return model
}

func TestNormalizeGeminiCLIModel(t *testing.T) {
t.Parallel()
Expand Down
12 changes: 12 additions & 0 deletions pkg/llmproxy/runtime/executor/oauth_upstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ import (
"github.com/router-for-me/CLIProxyAPI/v6/pkg/llmproxy/config"
)

func resolveOAuthBaseURLWithOverride(cfg *config.Config, provider, defaultURL, authURL string) string {
if authURL != "" {
return authURL
}
if cfg != nil && cfg.OAuthUpstream != nil {
if u, ok := cfg.OAuthUpstream[provider]; ok {
return u
}
}
return defaultURL
}

func TestResolveOAuthBaseURLWithOverride_PreferenceOrder(t *testing.T) {
cfg := &config.Config{
OAuthUpstream: map[string]string{
Expand Down
Loading