mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-05-30 11:21:30 +08:00
- Added `isUnauthorizedError` and `hasUnauthorizedAuthFailure` to classify and handle unauthorized errors. - Introduced `refreshErrorFromError` to map errors to standardized unauthorized responses. - Modified refresh logic to stop auto-refresh retries for unauthorized errors. - Updated tests to verify unauthorized error handling and refresh retry prevention.
16 lines
522 B
Go
16 lines
522 B
Go
package helps
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
func TestStatusFromHomeErrorCodeMapsAuthenticationErrorToUnauthorized(t *testing.T) {
|
|
if got := statusFromHomeErrorCode("authentication_error"); got != http.StatusUnauthorized {
|
|
t.Fatalf("statusFromHomeErrorCode(authentication_error) = %d, want %d", got, http.StatusUnauthorized)
|
|
}
|
|
if got := statusFromHomeErrorCode("unauthorized"); got != http.StatusUnauthorized {
|
|
t.Fatalf("statusFromHomeErrorCode(unauthorized) = %d, want %d", got, http.StatusUnauthorized)
|
|
}
|
|
}
|