fix(antigravity):

1. harden OpenAI compatibility forwarding
 2. reject usage-only non-stream responses
This commit is contained in:
chinnsenn
2026-07-26 20:23:50 +09:00
parent 2730c1c43b
commit 71d7f86883
11 changed files with 1810 additions and 28 deletions
+34
View File
@@ -146,6 +146,40 @@ func TestDeriveUpstreamEndpoint(t *testing.T) {
}
}
func TestShouldUseAntigravityCompat(t *testing.T) {
tests := []struct {
name string
account *service.Account
want bool
}{
{"oauth", &service.Account{Platform: service.PlatformAntigravity, Type: service.AccountTypeOAuth}, true},
{"setup token", &service.Account{Platform: service.PlatformAntigravity, Type: service.AccountTypeSetupToken}, false},
{"upstream", &service.Account{Platform: service.PlatformAntigravity, Type: service.AccountTypeUpstream}, false},
{"api key", &service.Account{Platform: service.PlatformAntigravity, Type: service.AccountTypeAPIKey}, false},
{"anthropic oauth", &service.Account{Platform: service.PlatformAnthropic, Type: service.AccountTypeOAuth}, false},
{"nil", nil, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.want, shouldUseAntigravityCompat(tt.account))
})
}
}
func TestGetUpstreamEndpointPrefersRuntimeOverride(t *testing.T) {
recorder := httptest.NewRecorder()
c, _ := gin.CreateTestContext(recorder)
c.Request = httptest.NewRequest(http.MethodPost, EndpointChatCompletions, nil)
c.Set(ctxKeyInboundEndpoint, EndpointChatCompletions)
setActualUpstreamEndpoint(c, EndpointAntigravityGenerateContent)
require.Equal(t, EndpointAntigravityGenerateContent, GetUpstreamEndpoint(c, service.PlatformAntigravity))
setActualUpstreamEndpoint(c, "")
require.Equal(t, EndpointMessages, GetUpstreamEndpoint(c, service.PlatformAntigravity))
}
func TestResolveOpenAIUpstreamEndpointPrefersForwardResult(t *testing.T) {
tests := []struct {
name string