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
66
66
throw new Error ( `Failed to load aws-sdk rdsdataservice client, did you forget to install it as a dependency? (${ err . message } )` ) ;
67
67
}
68
68
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' ) ;
70
72
71
73
const agent = new https . Agent ( {
72
74
keepAlive : true
Original file line number Diff line number Diff line change @@ -101,6 +101,30 @@ describe('SDK configuration tests', () => {
101
101
}
102
102
} ) ;
103
103
} ) ;
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
+ } ) ;
104
128
} ) ;
105
129
106
130
test ( 'Destroy functionality' , async ( ) => {
You can’t perform that action at this time.
0 commit comments