Files
CLIProxyAPI/sdk/auth/refresh_registry_test.go
Luis Pater feb6398456 feat(auth): increase Codex proactive refresh lead to 96 hours and improve rejected token handling
- Update Codex outer refresh lead time to 96 hours to prevent upstream token invalidation.
- Ensure proper token refreshing and background recovery for rejected unexpired JWTs and in-stream 401 errors.

Closes: #6742
2026-10-19 01:41:19 +08:00

44 lines
1.4 KiB
Go

package auth
import (
"testing"
"time"
)
func TestProviderRefreshLeads(t *testing.T) {
tests := []struct {
name string
authenticator Authenticator
want time.Duration
wantNil bool
}{
{name: "codex", authenticator: NewCodexAuthenticator(), want: 96 * time.Hour},
{name: "claude", authenticator: NewClaudeAuthenticator(), want: 4 * time.Hour},
{name: "antigravity", authenticator: NewAntigravityAuthenticator(), want: 30 * time.Minute},
{name: "kimi", authenticator: NewKimiAuthenticator(), want: 5 * time.Minute},
{name: "kimi-ai", authenticator: NewKimiAIAuthenticator(), want: 5 * time.Minute},
{name: "kimi.ai", authenticator: NewKimiAIDotAuthenticator(), want: 5 * time.Minute},
{name: "xai", authenticator: NewXAIAuthenticator(), want: 5 * time.Minute},
{name: "devin", authenticator: NewDevinAuthenticator(), wantNil: true},
{name: "meta", authenticator: NewMetaAuthenticator(), wantNil: true},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if got := test.authenticator.Provider(); got != test.name {
t.Fatalf("Provider() = %q, want %q", got, test.name)
}
lead := test.authenticator.RefreshLead()
if test.wantNil {
if lead != nil {
t.Fatalf("RefreshLead() = %v, want nil", lead)
}
return
}
if lead == nil || *lead != test.want {
t.Fatalf("RefreshLead() = %v, want %v", lead, test.want)
}
})
}
}