mirror of
https://gh-proxy.org/https://github.com/klinsmaya/CLIProxyAPI.git
synced 2026-11-08 09:26:52 +08:00
fix(executor): identify Grok CLI OAuth requests
This commit is contained in:
@@ -1028,6 +1028,7 @@ func applyXAIChatHeaders(r *http.Request, auth *cliproxyauth.Auth, token string,
|
||||
if xaiIsCLIChatProxyBaseURL(xaiChatBaseURL(auth)) {
|
||||
r.Header.Set(xaiTokenAuthHeader, xaiTokenAuthValue)
|
||||
r.Header.Set(xaiClientVersionHeader, xaiClientVersionValue)
|
||||
r.Header.Set("User-Agent", "xai-grok-workspace/"+xaiClientVersionValue)
|
||||
}
|
||||
applyXAICustomHeaders(r, auth)
|
||||
}
|
||||
|
||||
@@ -1733,6 +1733,9 @@ func TestApplyXAIChatHeaders(t *testing.T) {
|
||||
if got := req.Header.Get(xaiClientVersionHeader); got != "" {
|
||||
t.Fatalf("%s = %q, want empty for official API", xaiClientVersionHeader, got)
|
||||
}
|
||||
if got := req.Header.Get("User-Agent"); got != "" {
|
||||
t.Fatalf("User-Agent = %q, want empty for official API", got)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("OAuth defaults to cli chat proxy headers", func(t *testing.T) {
|
||||
@@ -1757,6 +1760,9 @@ func TestApplyXAIChatHeaders(t *testing.T) {
|
||||
if got := req.Header.Get(xaiClientVersionHeader); got != xaiClientVersionValue {
|
||||
t.Fatalf("%s = %q, want %q", xaiClientVersionHeader, got, xaiClientVersionValue)
|
||||
}
|
||||
if got := req.Header.Get("User-Agent"); got != "xai-grok-workspace/"+xaiClientVersionValue {
|
||||
t.Fatalf("User-Agent = %q, want xai-grok-workspace/%s", got, xaiClientVersionValue)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("no cli headers on custom gateway with using_api false", func(t *testing.T) {
|
||||
@@ -1775,6 +1781,9 @@ func TestApplyXAIChatHeaders(t *testing.T) {
|
||||
if got := req.Header.Get(xaiClientVersionHeader); got != "" {
|
||||
t.Fatalf("%s = %q, want empty for custom gateway", xaiClientVersionHeader, got)
|
||||
}
|
||||
if got := req.Header.Get("User-Agent"); got != "" {
|
||||
t.Fatalf("User-Agent = %q, want empty for custom gateway", got)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("custom headers override cli chat proxy defaults", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user