@@ -1259,9 +1259,9 @@ describe('runDev', () => {
12591259 expect ( Object . keys ( actionUrls ) . length ) . toEqual ( 0 )
12601260 } )
12611261
1262- test ( 'parses IMS_OAUTH_S2S environment variable ' , async ( ) => {
1263- const imsAuthData = { access_token : 'test-token' , org_id : 'test-org' }
1264- process . env . IMS_OAUTH_S2S = JSON . stringify ( imsAuthData )
1262+ test ( 'calls loadIMSCredentialsFromEnv for include-ims-credentials support ' , async ( ) => {
1263+ const rtLib = jest . requireActual ( '@adobe/aio-lib-runtime' )
1264+ const loadIMSCredentialsFromEnvSpy = jest . spyOn ( rtLib . utils , 'loadIMSCredentialsFromEnv' )
12651265
12661266 const actionPath = fixturePath ( 'actions/successNoReturnAction.js' )
12671267 const config = createConfig ( {
@@ -1279,31 +1279,10 @@ describe('runDev', () => {
12791279 const { actionUrls, serverCleanup } = await runDev ( runOptions , config , hookRunner )
12801280
12811281 await serverCleanup ( )
1282- // Verify runDev completes successfully when IMS_OAUTH_S2S env var is set with valid JSON
1283- expect ( Object . keys ( actionUrls ) . length ) . toBeGreaterThan ( 0 )
1284- } )
1285-
1286- test ( 'handles invalid IMS_OAUTH_S2S JSON gracefully' , async ( ) => {
1287- process . env . IMS_OAUTH_S2S = 'not-valid-json'
1288-
1289- const actionPath = fixturePath ( 'actions/successNoReturnAction.js' )
1290- const config = createConfig ( {
1291- hasFrontend : false ,
1292- hasBackend : true ,
1293- packageName : 'mypackage' ,
1294- actions : {
1295- myaction : {
1296- function : actionPath
1297- }
1298- }
1299- } )
1300- const runOptions = createRunOptions ( { cert : 'my-cert' , key : 'my-key' } )
1301- const hookRunner = ( ) => { }
1302- const { actionUrls, serverCleanup } = await runDev ( runOptions , config , hookRunner )
13031282
1304- await serverCleanup ( )
1305- // Verify runDev completes successfully even when IMS_OAUTH_S2S contains invalid JSON
1283+ expect ( loadIMSCredentialsFromEnvSpy ) . toHaveBeenCalled ( )
13061284 expect ( Object . keys ( actionUrls ) . length ) . toBeGreaterThan ( 0 )
1285+ loadIMSCredentialsFromEnvSpy . mockRestore ( )
13071286 } )
13081287
13091288 test ( 'no front end, has back end' , async ( ) => {
@@ -1848,8 +1827,8 @@ describe('invokeAction', () => {
18481827 const response = await invokeAction ( { actionRequestContext, logger : mockLogger } )
18491828
18501829 expect ( getIncludeIMSCredentialsAnnotationInputsSpy ) . toHaveBeenCalledWith ( action , expect . anything ( ) )
1851- expect ( actionParams . __ow_ims_access_token ) . toBeUndefined ( )
1852- expect ( actionParams . __ow_ims_org_id ) . toBeUndefined ( )
1830+ expect ( actionParams . __ims_oauth_s2s ) . toBeUndefined ( )
1831+ expect ( actionParams . __ims_env ) . toBeUndefined ( )
18531832 expect ( actionParams . existingParam ) . toEqual ( 'value' )
18541833 expect ( response . statusCode ) . toEqual ( 200 )
18551834 } )
0 commit comments