Skip to content

Commit c5ea02e

Browse files
authored
Fix ssl tests (brianc#2116)
1 parent d5dc421 commit c5ea02e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/pg/test/integration/gh-issues/2085-tests.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,23 @@ var assert = require('assert')
77
const suite = new helper.Suite()
88

99
suite.testAsync('it should connect over ssl', async () => {
10-
const client = new helper.pg.Client({ ssl: 'require'})
10+
const ssl = helper.args.native ? 'require' : {
11+
rejectUnauthorized: false
12+
}
13+
const client = new helper.pg.Client({ ssl })
1114
await client.connect()
1215
const { rows } = await client.query('SELECT NOW()')
1316
assert.strictEqual(rows.length, 1)
1417
await client.end()
1518
})
19+
20+
suite.testAsync('it should fail with self-signed cert error w/o rejectUnauthorized being passed', async () => {
21+
const ssl = helper.args.native ? 'verify-ca' : { }
22+
const client = new helper.pg.Client({ ssl })
23+
try {
24+
await client.connect()
25+
} catch (e) {
26+
return;
27+
}
28+
throw new Error('this test should have thrown an error due to self-signed cert')
29+
})

0 commit comments

Comments
 (0)