mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-20 21:30:50 +08:00
- Introduced unit tests for request logging middleware to enhance coverage. - Added WebSocket-based Codex executor to support Responses API upgrade. - Updated middleware logic to selectively capture request bodies for memory efficiency. - Enhanced Codex configuration handling with new WebSocket attributes.
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package cliproxy
|
|
|
|
import (
|
|
"testing"
|
|
|
|
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
|
)
|
|
|
|
func TestEnsureExecutorsForAuth_CodexDoesNotReplaceInNormalMode(t *testing.T) {
|
|
service := &Service{
|
|
cfg: &config.Config{},
|
|
coreManager: coreauth.NewManager(nil, nil, nil),
|
|
}
|
|
auth := &coreauth.Auth{
|
|
ID: "codex-auth-1",
|
|
Provider: "codex",
|
|
Status: coreauth.StatusActive,
|
|
}
|
|
|
|
service.ensureExecutorsForAuth(auth)
|
|
firstExecutor, okFirst := service.coreManager.Executor("codex")
|
|
if !okFirst || firstExecutor == nil {
|
|
t.Fatal("expected codex executor after first bind")
|
|
}
|
|
|
|
service.ensureExecutorsForAuth(auth)
|
|
secondExecutor, okSecond := service.coreManager.Executor("codex")
|
|
if !okSecond || secondExecutor == nil {
|
|
t.Fatal("expected codex executor after second bind")
|
|
}
|
|
|
|
if firstExecutor != secondExecutor {
|
|
t.Fatal("expected codex executor to stay unchanged in normal mode")
|
|
}
|
|
}
|
|
|
|
func TestEnsureExecutorsForAuthWithMode_CodexForceReplace(t *testing.T) {
|
|
service := &Service{
|
|
cfg: &config.Config{},
|
|
coreManager: coreauth.NewManager(nil, nil, nil),
|
|
}
|
|
auth := &coreauth.Auth{
|
|
ID: "codex-auth-2",
|
|
Provider: "codex",
|
|
Status: coreauth.StatusActive,
|
|
}
|
|
|
|
service.ensureExecutorsForAuth(auth)
|
|
firstExecutor, okFirst := service.coreManager.Executor("codex")
|
|
if !okFirst || firstExecutor == nil {
|
|
t.Fatal("expected codex executor after first bind")
|
|
}
|
|
|
|
service.ensureExecutorsForAuthWithMode(auth, true)
|
|
secondExecutor, okSecond := service.coreManager.Executor("codex")
|
|
if !okSecond || secondExecutor == nil {
|
|
t.Fatal("expected codex executor after forced rebind")
|
|
}
|
|
|
|
if firstExecutor == secondExecutor {
|
|
t.Fatal("expected codex executor replacement in force mode")
|
|
}
|
|
}
|