mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-20 13:20:52 +08:00
feat(logging, executor): add request logging tests and WebSocket-based Codex executor
- 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.
This commit is contained in:
64
sdk/cliproxy/service_codex_executor_binding_test.go
Normal file
64
sdk/cliproxy/service_codex_executor_binding_test.go
Normal file
@@ -0,0 +1,64 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user