File tree Expand file tree Collapse file tree 1 file changed +25
-12
lines changed
packages/pg/test/integration/client Expand file tree Collapse file tree 1 file changed +25
-12
lines changed Original file line number Diff line number Diff line change 11'use strict'
2- var pg = require ( __dirname + '/../../../lib' )
3- var config = require ( __dirname + '/test-helper' ) . config
4- test ( 'can connect with ssl' , function ( ) {
5- return false
6- config . ssl = {
7- rejectUnauthorized : false
2+ const { pg, Suite } = require ( './test-helper' )
3+ const assert = require ( 'assert' )
4+
5+ const suite = new Suite ( )
6+
7+ suite . testAsync ( 'it can connect w/ ssl' , async ( ) => {
8+ const ssl = {
9+ rejectUnauthorized : false ,
810 }
9- pg . connect ( config , assert . success ( function ( client ) {
10- return false
11- client . query ( 'SELECT NOW()' , assert . success ( function ( ) {
12- pg . end ( )
13- } ) )
14- } ) )
11+
12+ const client = new pg . Client ( { ssl } )
13+ await client . connect ( )
14+ assert . strictEqual ( client . connection . stream . encrypted , true )
15+ await client . end ( )
16+ } )
17+
18+ suite . testAsync ( 'it rejects on self-signed cert' , async ( ) => {
19+ const ssl = true
20+ const client = new pg . Client ( { ssl } )
21+ try {
22+ await client . connect ( )
23+ } catch ( e ) {
24+ assert ( e . message . includes ( 'self signed' ) )
25+ return
26+ }
27+ throw new Error ( 'connection should have failed with self-signed cert error' )
1528} )
You can’t perform that action at this time.
0 commit comments