@@ -112,6 +112,23 @@ function expectDefaultRedirectPayload(res: any) {
112112 } ) ;
113113}
114114
115+ function getUndiciAgentOptions ( dispatcher : unknown ) : Record < string , unknown > | undefined {
116+ if ( ! dispatcher || typeof dispatcher !== 'object' ) {
117+ return undefined ;
118+ }
119+
120+ const optionsSymbol = Object . getOwnPropertySymbols ( dispatcher ) . find (
121+ ( symbol ) => symbol . description === 'options' ,
122+ ) ;
123+ if ( ! optionsSymbol ) {
124+ return undefined ;
125+ }
126+
127+ return ( dispatcher as Record < symbol , unknown > ) [ optionsSymbol ] as
128+ | Record < string , unknown >
129+ | undefined ;
130+ }
131+
115132/** Perform a redirect flow and return the session with pending state */
116133async function performRedirect ( oidcInstance : any , mock : any , session ?: any ) {
117134 const sess = session || { save : vi . fn ( ( cb ) => cb ( ) ) } ;
@@ -1560,6 +1577,10 @@ test('initAuthentication should configure custom fetch when cafile is set', asyn
15601577 'https://idp.example.com/.well-known/openid-configuration' ,
15611578 expect . objectContaining ( { dispatcher : expect . anything ( ) } ) ,
15621579 ) ;
1580+ const requestInit = fetchSpy . mock . calls [ 0 ] [ 1 ] as { dispatcher ?: unknown } ;
1581+ expect ( getUndiciAgentOptions ( requestInit . dispatcher ) ) . toEqual (
1582+ expect . objectContaining ( { allowH2 : false } ) ,
1583+ ) ;
15631584 } finally {
15641585 fetchSpy . mockRestore ( ) ;
15651586 await cleanup ( ) ;
@@ -1598,6 +1619,10 @@ test('initAuthentication should configure custom fetch and warn when insecure TL
15981619 'https://idp.example.com/.well-known/openid-configuration' ,
15991620 expect . objectContaining ( { dispatcher : expect . anything ( ) } ) ,
16001621 ) ;
1622+ const requestInit = fetchSpy . mock . calls [ 0 ] [ 1 ] as { dispatcher ?: unknown } ;
1623+ expect ( getUndiciAgentOptions ( requestInit . dispatcher ) ) . toEqual (
1624+ expect . objectContaining ( { allowH2 : false } ) ,
1625+ ) ;
16011626 } finally {
16021627 fetchSpy . mockRestore ( ) ;
16031628 }
0 commit comments