File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1135,6 +1135,8 @@ describe('gemini.tsx main function exit codes', () => {
11351135 vi . mocked ( loadSandboxConfig ) . mockResolvedValue ( { } as any ) ;
11361136 vi . mocked ( loadCliConfig ) . mockResolvedValue ( {
11371137 refreshAuth : vi . fn ( ) . mockRejectedValue ( new Error ( 'Auth failed' ) ) ,
1138+ getRemoteAdminSettings : vi . fn ( ) . mockReturnValue ( undefined ) ,
1139+ isInteractive : vi . fn ( ) . mockReturnValue ( true ) ,
11381140 } as unknown as Config ) ;
11391141 vi . mocked ( loadSettings ) . mockReturnValue (
11401142 createMockSettings ( {
Original file line number Diff line number Diff line change @@ -373,6 +373,7 @@ export async function main() {
373373 // Refresh auth to fetch remote admin settings from CCPA and before entering
374374 // the sandbox because the sandbox will interfere with the Oauth2 web
375375 // redirect.
376+ let initialAuthFailed = false ;
376377 if ( ! settings . merged . security . auth . useExternal ) {
377378 try {
378379 if (
@@ -400,8 +401,7 @@ export async function main() {
400401 }
401402 } catch ( err ) {
402403 debugLogger . error ( 'Error authenticating:' , err ) ;
403- await runExitCleanup ( ) ;
404- process . exit ( ExitCodes . FATAL_AUTHENTICATION_ERROR ) ;
404+ initialAuthFailed = true ;
405405 }
406406 }
407407
@@ -427,6 +427,10 @@ export async function main() {
427427 // another way to decouple refreshAuth from requiring a config.
428428
429429 if ( sandboxConfig ) {
430+ if ( initialAuthFailed ) {
431+ await runExitCleanup ( ) ;
432+ process . exit ( ExitCodes . FATAL_AUTHENTICATION_ERROR ) ;
433+ }
430434 let stdinData = '' ;
431435 if ( ! process . stdin . isTTY ) {
432436 stdinData = await readStdin ( ) ;
You can’t perform that action at this time.
0 commit comments