-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path2085-tests.js
29 lines (24 loc) · 819 Bytes
/
2085-tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"use strict"
var helper = require('./../test-helper')
var assert = require('assert')
const suite = new helper.Suite()
suite.testAsync('it should connect over ssl', async () => {
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')
})