From 06775a8f022cab91e8f77fb1ba965f3432f47804 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 2 May 2023 19:24:34 -0700 Subject: [PATCH] [https-proxy-agent] Add test for `rejectUnauthorized: false` missing on request options (#148) --- .changeset/wild-wasps-double.md | 5 +++++ packages/https-proxy-agent/test/test.ts | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 .changeset/wild-wasps-double.md diff --git a/.changeset/wild-wasps-double.md b/.changeset/wild-wasps-double.md new file mode 100644 index 00000000..f41440cc --- /dev/null +++ b/.changeset/wild-wasps-double.md @@ -0,0 +1,5 @@ +--- +'https-proxy-agent': patch +--- + +Add test for `rejectUnauthorized: false` missing on request options diff --git a/packages/https-proxy-agent/test/test.ts b/packages/https-proxy-agent/test/test.ts index c02e201b..8ecb8210 100644 --- a/packages/https-proxy-agent/test/test.ts +++ b/packages/https-proxy-agent/test/test.ts @@ -197,6 +197,23 @@ describe('HttpsProxyAgent', () => { // The module does seem to work fine on an actual proxy though. const nodeVersion = parseFloat(process.versions.node); + it('should throw an "error" when `rejectUnauthorized: false` is missing', async () => { + const agent = new HttpsProxyAgent(sslProxyUrl, { + rejectUnauthorized: false, + }); + + let err: Error | undefined; + try { + await req(sslServerUrl, { + agent, + }); + } catch (_err) { + err = _err as Error; + } + assert(err); + expect(err.message).toMatch(/self( |-)signed certificate/); + }); + testIf( nodeVersion >= 18, 'should work over an HTTP proxy',