Skip to content

Fix ssl tests #2116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/pg/test/integration/gh-issues/2085-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})