From 7d1342e03bcddeb1f1fc6211c0f4566334f7fd03 Mon Sep 17 00:00:00 2001 From: Tobias Gurtzick Date: Sat, 19 Aug 2017 14:02:23 +0200 Subject: [PATCH] verify that sslrootcert is added to libpqConnectionString --- .../connection-parameters/creation-tests.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/unit/connection-parameters/creation-tests.js b/test/unit/connection-parameters/creation-tests.js index 9e02e56d..a3fa2513 100644 --- a/test/unit/connection-parameters/creation-tests.js +++ b/test/unit/connection-parameters/creation-tests.js @@ -269,4 +269,32 @@ test('libpq connection string building', function () { var c = new Client('postgres://user@password:host/database') assert(c.ssl, 'Client should have ssl enabled via defaults') }) + + test('ssl is set on client', function () { + var sourceConfig = { + user: 'brian', + password: 'helloe', + port: 5432, + host: 'localhost', + database: 'postgres', + ssl: { + sslmode: 'verify-ca', + sslca: '/path/ca.pem', + sslkey: '/path/cert.key', + sslcert: '/path/cert.crt', + sslrootcert: '/path/root.crt' + } + } + var Client = require('../../../lib/client') + var defaults = require('../../../lib/defaults') + defaults.ssl = true + var c = new ConnectionParameters(sourceConfig) + c.getLibpqConnectionString(assert.calls(function (err, pgCString) { + assert(!err) + assert.equal( + pgCString.indexOf('sslrootcert=\'/path/root.crt\'') !== -1, true, + 'libpqConnectionString should contain sslrootcert' + ) + })) + }) })