Skip to content

Commit 7d1342e

Browse files
wzrdtalesbrianc
authored andcommitted
verify that sslrootcert is added to libpqConnectionString
1 parent 03c2270 commit 7d1342e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/unit/connection-parameters/creation-tests.js

+28
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,32 @@ test('libpq connection string building', function () {
269269
var c = new Client('postgres://user@password:host/database')
270270
assert(c.ssl, 'Client should have ssl enabled via defaults')
271271
})
272+
273+
test('ssl is set on client', function () {
274+
var sourceConfig = {
275+
user: 'brian',
276+
password: 'hello<ther>e',
277+
port: 5432,
278+
host: 'localhost',
279+
database: 'postgres',
280+
ssl: {
281+
sslmode: 'verify-ca',
282+
sslca: '/path/ca.pem',
283+
sslkey: '/path/cert.key',
284+
sslcert: '/path/cert.crt',
285+
sslrootcert: '/path/root.crt'
286+
}
287+
}
288+
var Client = require('../../../lib/client')
289+
var defaults = require('../../../lib/defaults')
290+
defaults.ssl = true
291+
var c = new ConnectionParameters(sourceConfig)
292+
c.getLibpqConnectionString(assert.calls(function (err, pgCString) {
293+
assert(!err)
294+
assert.equal(
295+
pgCString.indexOf('sslrootcert=\'/path/root.crt\'') !== -1, true,
296+
'libpqConnectionString should contain sslrootcert'
297+
)
298+
}))
299+
})
272300
})

0 commit comments

Comments
 (0)