File tree 1 file changed +28
-0
lines changed
test/unit/connection-parameters
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -269,4 +269,32 @@ test('libpq connection string building', function () {
269
269
var c = new Client ( 'postgres://user@password:host/database' )
270
270
assert ( c . ssl , 'Client should have ssl enabled via defaults' )
271
271
} )
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
+ } )
272
300
} )
You can’t perform that action at this time.
0 commit comments