mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-11-16 22:57:53 +08:00
- 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
44 lines
1.4 KiB
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|