From c5ea02eae1cb80e52509f289f4d8c166fc25f76a Mon Sep 17 00:00:00 2001 From: Brian C Date: Tue, 25 Feb 2020 11:25:12 -0600 Subject: [PATCH] Fix ssl tests (#2116) --- .../pg/test/integration/gh-issues/2085-tests.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/pg/test/integration/gh-issues/2085-tests.js b/packages/pg/test/integration/gh-issues/2085-tests.js index 36f30c747..8ccdca150 100644 --- a/packages/pg/test/integration/gh-issues/2085-tests.js +++ b/packages/pg/test/integration/gh-issues/2085-tests.js @@ -7,9 +7,23 @@ var assert = require('assert') const suite = new helper.Suite() suite.testAsync('it should connect over ssl', async () => { - const client = new helper.pg.Client({ ssl: 'require'}) + const ssl = helper.args.native ? 'require' : { + rejectUnauthorized: false + } + const client = new helper.pg.Client({ ssl }) await client.connect() const { rows } = await client.query('SELECT NOW()') assert.strictEqual(rows.length, 1) await client.end() }) + +suite.testAsync('it should fail with self-signed cert error w/o rejectUnauthorized being passed', async () => { + const ssl = helper.args.native ? 'verify-ca' : { } + const client = new helper.pg.Client({ ssl }) + try { + await client.connect() + } catch (e) { + return; + } + throw new Error('this test should have thrown an error due to self-signed cert') +})