11'use strict'
22
33var chai = require ( 'chai' )
4+ var expect = chai . expect
45chai . should ( )
56
67var parse = require ( '../' ) . parse
@@ -255,29 +256,52 @@ describe('parse', function () {
255256 subject . ssl . should . eql ( false )
256257 } )
257258
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 '
260261 var subject = parse ( connectionString )
261262 subject . ssl . should . eql ( {
262263 rejectUnauthorized : false ,
263264 } )
264265 } )
265266
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 '
268269 var subject = parse ( connectionString )
269270 subject . ssl . should . eql ( {
270271 rejectUnauthorized : false ,
271272 } )
272273 } )
273274
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 '
276277 var subject = parse ( connectionString )
277278 subject . ssl . should . have . property ( 'checkServerIdentity' ) . that . is . a ( 'function' )
278279 expect ( subject . ssl . checkServerIdentity ( ) ) . to . be . undefined
279280 } )
280281
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+
281305 it ( 'configuration parameter sslmode=verify-full' , function ( ) {
282306 var connectionString = 'pg:///?sslmode=verify-full'
283307 var subject = parse ( connectionString )
@@ -287,9 +311,17 @@ describe('parse', function () {
287311 it ( 'configuration parameter ssl=true and sslmode=require still work with sslrootcert=/path/to/ca' , function ( ) {
288312 var connectionString = 'pg:///?ssl=true&sslrootcert=' + __dirname + '/example.ca&sslmode=require'
289313 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 )
290322 subject . ssl . should . have . property ( 'ca' , 'example ca\n' )
291323 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
293325 } )
294326
295327 it ( 'allow other params like max, ...' , function ( ) {
0 commit comments