mirror of
https://gh-proxy.org/https://github.com/klinsmaya/CLIProxyAPI.git
synced 2026-11-08 01:16:47 +08:00
fix(oauth): hide completed sessions from legacy getter
This commit is contained in:
@@ -259,7 +259,7 @@ func CompletePluginOAuthSessionsByProvider(provider string) int {
|
||||
|
||||
func GetOAuthSession(state string) (provider string, status string, ok bool) {
|
||||
session, ok := oauthSessions.Get(state)
|
||||
if !ok {
|
||||
if !ok || session.Completed {
|
||||
return "", "", false
|
||||
}
|
||||
return session.Provider, session.Status, true
|
||||
|
||||
@@ -26,6 +26,23 @@ func TestOAuthSessionStoreCompleteKeepsShortLivedSession(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetOAuthSessionHidesCompletedSession(t *testing.T) {
|
||||
store := newOAuthSessionStore(time.Minute)
|
||||
replaceOAuthSessionStoreForTest(t, store)
|
||||
store.Register("completed-state", "codex")
|
||||
store.Complete("completed-state")
|
||||
|
||||
provider, status, ok := GetOAuthSession("completed-state")
|
||||
if ok {
|
||||
t.Fatalf("GetOAuthSession() = (%q, %q, true), want completed session hidden", provider, status)
|
||||
}
|
||||
|
||||
_, _, _, _, completed, detailsOK := GetOAuthSessionDetails("completed-state")
|
||||
if !detailsOK || !completed {
|
||||
t.Fatalf("GetOAuthSessionDetails() completed/ok = %t/%t, want true/true", completed, detailsOK)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAuthStatusRejectsUnknownStateAndAcceptsCompletedState(t *testing.T) {
|
||||
store := newOAuthSessionStore(time.Minute)
|
||||
replaceOAuthSessionStoreForTest(t, store)
|
||||
|
||||
Reference in New Issue
Block a user