1
1
'use strict'
2
2
3
3
var chai = require ( 'chai' )
4
+ var expect = chai . expect
4
5
chai . should ( )
5
6
6
7
var parse = require ( '../' ) . parse
@@ -255,29 +256,52 @@ describe('parse', function () {
255
256
subject . ssl . should . eql ( false )
256
257
} )
257
258
258
- it ( 'configuration parameter sslmode=prefer' , function ( ) {
259
- var connectionString = 'pg:///?sslmode=prefer'
259
+ it ( 'configuration parameter sslmode=prefer with libpq compatibility ' , function ( ) {
260
+ var connectionString = 'pg:///?sslmode=prefer&sslcompat=libpq '
260
261
var subject = parse ( connectionString )
261
262
subject . ssl . should . eql ( {
262
263
rejectUnauthorized : false ,
263
264
} )
264
265
} )
265
266
266
- it ( 'configuration parameter sslmode=require' , function ( ) {
267
- var connectionString = 'pg:///?sslmode=require'
267
+ it ( 'configuration parameter sslmode=require with libpq compatibility ' , function ( ) {
268
+ var connectionString = 'pg:///?sslmode=require&sslcompat=libpq '
268
269
var subject = parse ( connectionString )
269
270
subject . ssl . should . eql ( {
270
271
rejectUnauthorized : false ,
271
272
} )
272
273
} )
273
274
274
- it ( 'configuration parameter sslmode=verify-ca' , function ( ) {
275
- var connectionString = 'pg:///?sslmode=verify-ca'
275
+ it ( 'configuration parameter sslmode=verify-ca with libpq compatibility ' , function ( ) {
276
+ var connectionString = 'pg:///?sslmode=verify-ca&sslcompat=libpq '
276
277
var subject = parse ( connectionString )
277
278
subject . ssl . should . have . property ( 'checkServerIdentity' ) . that . is . a ( 'function' )
278
279
expect ( subject . ssl . checkServerIdentity ( ) ) . to . be . undefined
279
280
} )
280
281
282
+ it ( 'configuration parameter sslmode=prefer with libpq compatibility' , function ( ) {
283
+ var connectionString = 'pg:///?sslmode=prefer&sslcompat=libpq'
284
+ var subject = parse ( connectionString )
285
+ subject . ssl . should . eql ( {
286
+ rejectUnauthorized : false ,
287
+ } )
288
+ } )
289
+
290
+ it ( 'configuration parameter sslmode=require with libpq compatibility' , function ( ) {
291
+ var connectionString = 'pg:///?sslmode=require&sslcompat=libpq'
292
+ var subject = parse ( connectionString )
293
+ subject . ssl . should . eql ( {
294
+ rejectUnauthorized : false ,
295
+ } )
296
+ } )
297
+
298
+ it ( 'configuration parameter sslmode=verify-ca with libpq compatibility' , function ( ) {
299
+ var connectionString = 'pg:///?sslmode=verify-ca&sslcompat=libpq'
300
+ var subject = parse ( connectionString )
301
+ subject . ssl . should . have . property ( 'checkServerIdentity' ) . that . is . a ( 'function' )
302
+ expect ( subject . ssl . checkServerIdentity ( ) ) . be . undefined
303
+ } )
304
+
281
305
it ( 'configuration parameter sslmode=verify-full' , function ( ) {
282
306
var connectionString = 'pg:///?sslmode=verify-full'
283
307
var subject = parse ( connectionString )
@@ -287,9 +311,17 @@ describe('parse', function () {
287
311
it ( 'configuration parameter ssl=true and sslmode=require still work with sslrootcert=/path/to/ca' , function ( ) {
288
312
var connectionString = 'pg:///?ssl=true&sslrootcert=' + __dirname + '/example.ca&sslmode=require'
289
313
var subject = parse ( connectionString )
314
+ subject . ssl . should . eql ( {
315
+ ca : 'example ca\n' ,
316
+ } )
317
+ } )
318
+
319
+ it ( 'configuration parameter ssl=true and sslmode=require still work with sslrootcert=/path/to/ca with libpq compatibility' , function ( ) {
320
+ var connectionString = 'pg:///?ssl=true&sslrootcert=' + __dirname + '/example.ca&sslmode=require&sslcompat=libpq'
321
+ var subject = parse ( connectionString )
290
322
subject . ssl . should . have . property ( 'ca' , 'example ca\n' )
291
323
subject . ssl . should . have . property ( 'checkServerIdentity' ) . that . is . a ( 'function' )
292
- expect ( subject . ssl . checkServerIdentity ( ) ) . to . be . undefined
324
+ expect ( subject . ssl . checkServerIdentity ( ) ) . be . undefined
293
325
} )
294
326
295
327
it ( 'allow other params like max, ...' , function ( ) {
0 commit comments