mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-10-05 23:31:05 +08:00
- Add context helpers to manage execution-scoped proxy overrides - Prioritize request proxy over credential and global proxy settings across HTTP and uTLS clients - Propagate request proxy in conductor execution and plugin host adapters - Isolate Codex WebSocket connection reuse by proxy endpoint Closes: #6013
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
package executor
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gorilla/websocket"
|
|
)
|
|
|
|
func TestWebsocketSessionIsolatesReusableConnectionByProxy(t *testing.T) {
|
|
conn := &websocket.Conn{}
|
|
closer := newWebsocketConnectionCloser(conn)
|
|
sess := &codexWebsocketSession{
|
|
authID: "auth-1",
|
|
wsURL: "wss://upstream.example/v1",
|
|
proxyURL: "http://proxy-a.example:8081",
|
|
conn: conn,
|
|
connCloser: closer,
|
|
}
|
|
|
|
if got, _ := existingWebsocketSessionConn(sess, "auth-1", sess.wsURL, "http://proxy-b.example:8082"); got != nil {
|
|
t.Fatal("reused websocket after proxy_url changed")
|
|
}
|
|
if got, _ := existingWebsocketSessionConn(sess, "auth-1", sess.wsURL, ""); got != nil {
|
|
t.Fatal("reused proxied websocket after proxy override was removed")
|
|
}
|
|
if got, _ := existingWebsocketSessionConn(sess, "auth-1", sess.wsURL, sess.proxyURL); got == nil {
|
|
t.Fatal("did not reuse websocket for the same proxy")
|
|
}
|
|
if !websocketSessionTargetChanged(sess, "auth-1", sess.wsURL, "http://proxy-b.example:8082") {
|
|
t.Fatal("proxy change was not treated as a websocket target change")
|
|
}
|
|
|
|
detached, detachedCloser, _, _, _ := detachMismatchedWebsocketSessionConn(sess, "auth-1", sess.wsURL, "")
|
|
if detached == nil || detachedCloser == nil {
|
|
t.Fatal("removing the proxy override did not detach the websocket")
|
|
}
|
|
if sess.conn != nil {
|
|
t.Fatal("detached websocket remained attached")
|
|
}
|
|
}
|