8000 add test for http proxy · xiaohuoni/sentry-javascript@de4b2bb · GitHub
[go: up one dir, main page]

Skip to content

Commit de4b2bb

Browse files
committed
add test for http proxy
1 parent f96d47b commit de4b2bb

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

packages/node/test/transports/https.test.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ describe('HTTPSTransport', () => {
293293
dsn,
294294
httpsProxy: 'https://example.com:8080',
295295
});
296-
expect(transport.client).toBeInstanceOf(https.Agent);
296+
expect(transport.client).toBeInstanceOf(https.Agent); // rather than HttpsProxyAgent
297+
delete process.env.no_proxy;
297298
});
298299

299300
test('no_proxy works with a port', async () => {
@@ -302,8 +303,9 @@ describe('HTTPSTransport', () => {
302303
const transport = createTransport({
303304
dsn,
304305
});
305-
expect(transport.client).toBeInstanceOf(https.Agent);
306+
expect(transport.client).toBeInstanceOf(https.Agent); // rather than HttpsProxyAgent
306307
delete process.env.https_proxy;
308+
delete process.env.no_proxy;
307309
});
308310

309311
test('no_proxy works with multiple comma-separated hosts', async () => {
@@ -312,8 +314,9 @@ describe('HTTPSTransport', () => {
312314
const transport = createTransport({
313315
dsn,
314316
});
315-
expect(transport.client).toBeInstanceOf(https.Agent);
316-
delete process.env.https_proxy;
317+
expect(transport.client).toBeInstanceOf(https.Agent); // rather than HttpsProxyAgent
318+
delete process.env.http_proxy;
319+
delete process.env.no_proxy;
317320
});
318321

319322
test('can configure tls certificate through client option', async () => {
@@ -328,5 +331,20 @@ describe('HTTPSTransport', () => {
328331
const requestOptions = (transport.module!.request as jest.Mock).mock.calls[0][0];
329332
expect(requestOptions.ca).toEqual('mockedCert');
330333
});
334+
335+
test('can use an http proxy with an https DSN', async () => {
336+
const transport = createTransport({
337+
dsn,
338+
httpProxy: 'https://example.com:8080',
339+
});
340+
const client = (transport.client as unknown) as { proxy: Record<string, string | number>; secureProxy: boolean };
341+
342+
expect(client).toBeInstanceOf(HttpsProxyAgent);
343+
expect(async () => {
344+
await transport.sendEvent({
345+
message: 'test',
346+
});
347+
}).not.toThrow();
348+
});
331349
});
332350
});

0 commit comments

Comments
 (0)
0