@@ -5,6 +5,7 @@ import { addExtensionMethods, Span, TRACEPARENT_REGEXP, Transaction } from '@sen
5
5
import { parseSemver } from '@sentry/utils' ;
6
6
import * as http from 'http' ;
7
7
import * as https from 'https' ;
8
+ import * as HttpsProxyAgent from 'https-proxy-agent' ;
8
9
import * as nock from 'nock' ;
9
10
10
11
import { Breadcrumb } from '../../src' ;
@@ -143,7 +144,7 @@ describe('default protocols', () => {
143
144
const key = 'catcatchers' ;
144
145
const p = captureBreadcrumb ( key ) ;
145
146
146
- let nockProtocol = 'https: ' ;
147
+ let nockProtocol = 'https' ;
147
148
// NOTE: Prior to Node 9, `https` used internals of `http` module, so
148
149
// the integration doesn't patch the `https` module. However this then
149
150
// causes issues with nock, because nock will patch the `https` module
@@ -160,7 +161,7 @@ describe('default protocols', () => {
160
161
// because the latest versions of nock no longer support Node v8 and lower,
161
162
// so won't bother dealing with this old Node edge case.
162
163
if ( NODE_VERSION . major && NODE_VERSION . major < 9 ) {
163
- nockProtocol = 'http: ' ;
164
+ nockProtocol = 'http' ;
164
165
}
165
166
nock ( `${ nockProtocol } ://${ key } .ingest.sentry.io` )
166
167
. get ( '/api/123122332/store/' )
@@ -175,4 +176,31 @@ describe('default protocols', () => {
175
176
const b = await p ;
176
177
expect ( b . data ?. url ) . toEqual ( expect . stringContaining ( 'https://' ) ) ;
177
178
} ) ;
179
+
180
+ it ( 'makes https request over http proxy' , async ( ) => {
181
+ const key = 'catcatchers' ;
182
+ const p = captureBreadcrumb ( key ) ;
183
+ let nockProtocol = 'https' ;
184
+
185
+ const proxy = 'http://<PROXY_URL>:3128' ;
186
+ const agent = new HttpsProxyAgent ( proxy ) ;
187
+
188
+ if ( NODE_VERSION . major && NODE_VERSION . major < 9 ) {
189
+ nockProtocol = 'http' ;
190
+ }
191
+
192
+ nock ( `${ nockProtocol } ://${ key } .ingest.sentry.io` )
193
+ . get ( '/api/123122332/store/' )
194
+ . reply ( 200 ) ;
195
+
196
+ https . get ( {
197
+ host : `${ key } .ingest.sentry.io` ,
198
+ path : '/api/123122332/store/' ,
199
+ timeout : 300 ,
200
+ agent,
201
+ } ) ;
202
+
203
+ const b = await p ;
204
+ expect ( b . data ?. url ) . toEqual ( expect . stringContaining ( 'https://' ) ) ;
205
+ } ) ;
178
206
} ) ;
0 commit comments