File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,9 @@ class Client_AuroraDataMySQL extends Client_MySQL { // eslint-disable-line camel
6666 throw new Error ( `Failed to load aws-sdk rdsdataservice client, did you forget to install it as a dependency? (${ err . message } )` ) ;
6767 }
6868
69- const https = require ( 'https' ) ;
69+ const https = this . config . connection . sdkConfig && String ( this . config . connection . sdkConfig . endpoint ) . startsWith ( 'http:' )
70+ ? require ( 'http' )
71+ : require ( 'https' ) ;
7072
7173 const agent = new https . Agent ( {
7274 keepAlive : true
Original file line number Diff line number Diff line change @@ -101,6 +101,30 @@ describe('SDK configuration tests', () => {
101101 }
102102 } ) ;
103103 } ) ;
104+
105+ test ( 'Uses HTTP agent when called with an HTTP endpoint' , ( ) => {
106+ require ( 'knex' ) ( {
107+ client : require ( '..' ) ,
108+ connection : {
109+ database : constants . DATABASE ,
110+ resourceArn : constants . AURORA_CLUSTER_ARN ,
111+ secretArn : constants . SECRET_ARN ,
112+ sdkConfig : {
113+ endpoint : 'http://localhost:8080'
114+ }
115+ }
116+ } ) ;
117+
118+ expect ( RDSDataService ) . toHaveBeenCalledTimes ( 1 ) ;
119+ expect ( RDSDataService ) . toHaveBeenCalledWith ( {
120+ endpoint : 'http://localhost:8080' ,
121+ httpOptions : {
122+ agent : expect . objectContaining ( {
123+ protocol : 'http:'
124+ } )
125+ }
126+ } ) ;
127+ } ) ;
104128} ) ;
105129
106130test ( 'Destroy functionality' , async ( ) => {
You can’t perform that action at this time.
0 commit comments