@@ -516,6 +516,84 @@ describe("modelsStatusCommand auth overview", () => {
516516 }
517517 } ) ;
518518
519+ it ( "keeps delegated OAuth marker display separate from runtime route usability" , async ( ) => {
520+ const localRuntime = createRuntime ( ) ;
521+ const originalLoadConfig = mocks . loadConfig . getMockImplementation ( ) ;
522+ const originalProfiles = { ...mocks . store . profiles } ;
523+ const originalEnvImpl = mocks . resolveEnvApiKey . getMockImplementation ( ) ;
524+ const originalCustomKeyImpl = mocks . getCustomProviderApiKey . getMockImplementation ( ) ;
525+ const originalUsableCustomKeyImpl =
526+ mocks . resolveUsableCustomProviderApiKey . getMockImplementation ( ) ;
527+ mocks . loadConfig . mockReturnValue ( {
528+ agents : {
529+ defaults : {
530+ model : { primary : "openai/gpt-5.5" , fallbacks : [ ] } ,
531+ models : { "openai/gpt-5.5" : { } } ,
532+ } ,
533+ } ,
534+ models : {
535+ providers : {
536+ openai : {
537+ apiKey : "oauth:openai-codex" ,
538+ } ,
539+ } ,
540+ } ,
541+ env : { shellEnv : { enabled : false } } ,
542+ } ) ;
543+ mocks . store . profiles = { } ;
544+ mocks . resolveEnvApiKey . mockImplementation ( ( ) => null ) ;
545+ mocks . getCustomProviderApiKey . mockImplementation ( ( _cfg : unknown , provider : string ) =>
546+ provider === "openai" ? "oauth:openai-codex" : undefined ,
547+ ) ;
548+ mocks . resolveUsableCustomProviderApiKey . mockImplementation ( ( ) => null ) ;
549+
550+ try {
551+ await modelsStatusCommand ( { json : true , check : true } , localRuntime as never ) ;
552+ const payload = parseFirstJsonLog ( localRuntime ) ;
553+ const openai = requireProvider ( payload . auth . providers , "openai" ) ;
554+ expect ( openai . effective ) . toEqual ( {
555+ kind : "models.json" ,
556+ detail : "marker(oauth:openai-codex)" ,
557+ } ) ;
558+ expect ( payload . auth . runtimeAuthRoutes ) . toEqual ( [
559+ {
560+ provider : "openai" ,
561+ runtime : "codex" ,
562+ authProvider : "openai-codex" ,
563+ status : "missing" ,
564+ effective : {
565+ kind : "missing" ,
566+ detail : "missing" ,
567+ } ,
568+ } ,
569+ ] ) ;
570+ expect ( payload . auth . missingProvidersInUse ) . toStrictEqual ( [ "openai" ] ) ;
571+ expect ( localRuntime . exit ) . toHaveBeenCalledWith ( 1 ) ;
572+ } finally {
573+ mocks . store . profiles = originalProfiles ;
574+ if ( originalLoadConfig ) {
575+ mocks . loadConfig . mockImplementation ( originalLoadConfig ) ;
576+ }
577+ if ( originalEnvImpl ) {
578+ mocks . resolveEnvApiKey . mockImplementation ( originalEnvImpl ) ;
579+ } else if ( defaultResolveEnvApiKeyImpl ) {
580+ mocks . resolveEnvApiKey . mockImplementation ( defaultResolveEnvApiKeyImpl ) ;
581+ } else {
582+ mocks . resolveEnvApiKey . mockImplementation ( ( ) => null ) ;
583+ }
584+ if ( originalCustomKeyImpl ) {
585+ mocks . getCustomProviderApiKey . mockImplementation ( originalCustomKeyImpl ) ;
586+ } else {
587+ mocks . getCustomProviderApiKey . mockReturnValue ( undefined ) ;
588+ }
589+ if ( originalUsableCustomKeyImpl ) {
590+ mocks . resolveUsableCustomProviderApiKey . mockImplementation ( originalUsableCustomKeyImpl ) ;
591+ } else {
592+ mocks . resolveUsableCustomProviderApiKey . mockReturnValue ( null ) ;
593+ }
594+ }
595+ } ) ;
596+
519597 it ( "uses Codex synthetic auth for canonical OpenAI text routes" , async ( ) => {
520598 const localRuntime = createRuntime ( ) ;
521599 const originalLoadConfig = mocks . loadConfig . getMockImplementation ( ) ;
0 commit comments