mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-09-11 14:47:58 +08:00
- 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
33 lines
976 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|