@@ -19,8 +19,10 @@ describe('open-api HTTP adapter', function () {
1919 let originalEnv ;
2020 let originalEnvHttpProxyAgent ;
2121 let originalProxyAgent ;
22+ let originalRedirect ;
2223 let originalRequest ;
2324 let agentOptions ;
25+ let redirectOptions ;
2426 let requestOptions ;
2527
2628 beforeEach ( function ( ) {
@@ -33,8 +35,10 @@ describe('open-api HTTP adapter', function () {
3335
3436 originalEnvHttpProxyAgent = undici . EnvHttpProxyAgent ;
3537 originalProxyAgent = undici . ProxyAgent ;
38+ originalRedirect = undici . interceptors . redirect ;
3639 originalRequest = undici . request ;
3740 agentOptions = [ ] ;
41+ redirectOptions = undefined ;
3842 requestOptions = undefined ;
3943
4044 class CapturingAgent {
@@ -49,6 +53,10 @@ describe('open-api HTTP adapter', function () {
4953
5054 undici . EnvHttpProxyAgent = CapturingAgent ;
5155 undici . ProxyAgent = CapturingAgent ;
56+ undici . interceptors . redirect = ( options ) => {
57+ redirectOptions = options ;
58+ return ( ) => { } ;
59+ } ;
5260 undici . request = async ( _url , options ) => {
5361 requestOptions = options ;
5462 return {
@@ -65,6 +73,7 @@ describe('open-api HTTP adapter', function () {
6573 afterEach ( function ( ) {
6674 undici . EnvHttpProxyAgent = originalEnvHttpProxyAgent ;
6775 undici . ProxyAgent = originalProxyAgent ;
76+ undici . interceptors . redirect = originalRedirect ;
6877 undici . request = originalRequest ;
6978 proxyEnvKeys . forEach ( ( key ) => {
7079 if ( originalEnv [ key ] == null ) {
@@ -96,6 +105,33 @@ describe('open-api HTTP adapter', function () {
96105 expect ( agentOptions [ 0 ] . requestTls . allowH2 ) . to . equal ( false ) ;
97106 } ) ;
98107
108+ it ( 'passes proxyTunnel to undici proxy agents' , async function ( ) {
109+ await HTTP ( ) . get ( {
110+ url : 'http://example.com/subscription' ,
111+ proxy : 'http://127.0.0.1:8080' ,
112+ proxyTunnel : true ,
113+ } ) ;
114+ await HTTP ( ) . get ( {
115+ url : 'http://example.com/subscription' ,
116+ proxyTunnel : true ,
117+ } ) ;
118+
119+ expect ( agentOptions ) . to . have . length ( 2 ) ;
120+ expect ( agentOptions . map ( ( { proxyTunnel } ) => proxyTunnel ) ) . to . deep . equal ( [
121+ true ,
122+ true ,
123+ ] ) ;
124+ } ) ;
125+
126+ it ( 'uses the Undici option that throws at the redirect limit' , async function ( ) {
127+ await HTTP ( ) . get ( 'https://example.com/subscription' ) ;
128+
129+ expect ( redirectOptions ) . to . deep . equal ( {
130+ maxRedirections : 3 ,
131+ throwOnMaxRedirect : true ,
132+ } ) ;
133+ } ) ;
134+
99135 it ( 'normalizes Node.js request header names to lowercase' , async function ( ) {
100136 await HTTP ( {
101137 headers : {
0 commit comments