@@ -1362,6 +1362,58 @@ describe("provider management validation", () => {
13621362 }
13631363 } ) ;
13641364
1365+ test ( "disabled OpenAI recovery strips allowPrivateNetwork after successful re-enable" , async ( ) => {
1366+ if ( existsSync ( TEST_DIR ) ) rmSync ( TEST_DIR , { recursive : true } ) ;
1367+ mkdirSync ( TEST_DIR , { recursive : true } ) ;
1368+ process . env . OPENCODEX_HOME = TEST_DIR ;
1369+ const liveConfig : OcxConfig = {
1370+ port : 0 ,
1371+ hostname : "127.0.0.1" ,
1372+ defaultProvider : "extra" ,
1373+ openaiProviderTierVersion : 2 ,
1374+ providers : {
1375+ openai : {
1376+ adapter : "openai-responses" ,
1377+ baseUrl : "https://chatgpt.com/backend-api/codex" ,
1378+ authMode : "forward" ,
1379+ allowPrivateNetwork : true ,
1380+ disabled : true ,
1381+ } ,
1382+ extra : {
1383+ adapter : "openai-chat" ,
1384+ baseUrl : "https://extra.example.test/v1" ,
1385+ liveModels : false ,
1386+ models : [ "extra-model" ] ,
1387+ } ,
1388+ } ,
1389+ } ;
1390+ saveConfig ( liveConfig ) ;
1391+ const resolvedError = spyOn ( destinationPolicy , "providerDestinationResolvedError" )
1392+ . mockResolvedValue ( null ) ;
1393+
1394+ try {
1395+ const request = new Request ( "http://127.0.0.1/api/providers?name=openai" , {
1396+ method : "PATCH" ,
1397+ headers : { "content-type" : "application/json" } ,
1398+ body : JSON . stringify ( { disabled : false } ) ,
1399+ } ) ;
1400+ const response = await handleManagementAPI ( request , new URL ( request . url ) , liveConfig , {
1401+ refreshCodexCatalog : async ( ) => undefined ,
1402+ } ) ;
1403+ expect ( response ?. status ) . toBe ( 200 ) ;
1404+ expect ( liveConfig . providers . openai ) . toEqual ( {
1405+ adapter : "openai-responses" ,
1406+ baseUrl : "https://chatgpt.com/backend-api/codex" ,
1407+ authMode : "forward" ,
1408+ codexAccountMode : "pool" ,
1409+ } ) ;
1410+ expect ( Object . hasOwn ( liveConfig . providers . openai as object , "allowPrivateNetwork" ) ) . toBe ( false ) ;
1411+ expect ( Object . hasOwn ( loadConfig ( ) . providers . openai as object , "allowPrivateNetwork" ) ) . toBe ( false ) ;
1412+ } finally {
1413+ resolvedError . mockRestore ( ) ;
1414+ }
1415+ } ) ;
1416+
13651417 for ( const [ label , baseUrl ] of [
13661418 [ "uppercase host" , "https://CHATGPT.com/backend-api/codex" ] ,
13671419 [ "explicit :443 port" , "https://chatgpt.com:443/backend-api/codex" ] ,
0 commit comments