Files
CLIProxyAPI/sdk/auth/refresh_registry_test.go
Luis Pater 9812b1e768 fix(auth): validate access token expiration and retain valid credentials on refresh failure
- Parse and prioritize JWT `exp` claims when determining access token expiration.
- Retain active credentials and schedule backoff retries on refresh failures if the access token remains unexpired.
- Demote and block auth credentials with expired access tokens during model scheduling and candidate selection.
- Reduce Codex token refresh lead duration to 24 hours.

Closes: #5095
2026-09-03 01:33:11 +08:00

33 lines
976 B
Go

package auth
import (
"testing"
"time"
)
func TestProviderRefreshLeads(t *testing.T) {
tests := []struct {
name string
authenticator Authenticator
want time.Duration
}{
{name: "codex", authenticator: NewCodexAuthenticator(), want: 24 * 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: "xai", authenticator: NewXAIAuthenticator(), want: 5 * time.Minute},
}
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 lead == nil || *lead != test.want {
t.Fatalf("RefreshLead() = %v, want %v", lead, test.want)
}
})
}
}