@@ -11,7 +11,7 @@ governing permissions and limitations under the License.
11
11
12
12
const queryString = require ( 'query-string' )
13
13
const { createHttpsProxy, createHttpProxy } = require ( '../src/proxy' )
14
- const { createApiServer } = require ( '../src/api-server' )
14
+ const { createApiServer, HOSTNAME } = require ( '../src/api-server' )
15
15
const fetch = require ( 'node-fetch' )
16
16
const HttpsProxyAgent = require ( 'https-proxy-agent' )
17
17
const HttpProxyAgent = require ( 'http-proxy-agent' )
@@ -64,7 +64,7 @@ describe('http proxy', () => {
64
64
const apiServerAddress = apiServer . address ( )
65
65
const queryObject = { foo : 'bar' }
66
66
67
- const testUrl = `${ protocol } ://localhost :${ apiServerAddress . port } /mirror?${ queryString . stringify ( queryObject ) } `
67
+ const testUrl = `${ protocol } ://${ HOSTNAME } :${ apiServerAddress . port } /mirror?${ queryString . stringify ( queryObject ) } `
68
68
69
69
const proxyUrl = proxyServer . url
70
70
const proxyOpts = urlToHttpOptions ( proxyUrl )
@@ -78,7 +78,7 @@ describe('http proxy', () => {
78
78
79
79
test ( 'failure' , async ( ) => {
80
80
// connect to non-existent server port
81
- const testUrl = `${ protocol } ://localhost :${ portNotInUse } /mirror/?foo=bar`
81
+ const testUrl = `${ protocol } ://${ HOSTNAME } :${ portNotInUse } /mirror/?foo=bar`
82
82
83
83
const proxyUrl = proxyServer . url
84
84
const proxyOpts = urlToHttpOptions ( proxyUrl )
@@ -114,7 +114,7 @@ describe('http proxy', () => {
114
114
const proxyOpts = urlToHttpOptions ( proxyUrl )
115
115
proxyOpts . auth = `${ username } :${ password } `
116
116
117
- const testUrl = `${ protocol } ://localhost :${ apiServerPort } /mirror?${ queryString . stringify ( queryObject ) } `
117
+ const testUrl = `${ protocol } ://${ HOSTNAME } :${ apiServerPort } /mirror?${ queryString . stringify ( queryObject ) } `
118
118
const response = await fetch ( testUrl , {
119
119
agent : new HttpProxyAgent ( proxyOpts ) ,
120
120
headers
@@ -138,7 +138,7 @@ describe('http proxy', () => {
138
138
const proxyOpts = urlToHttpOptions ( proxyUrl )
139
139
proxyOpts . auth = `${ username } :${ password } `
140
140
141
- const testUrl = `${ protocol } ://localhost :${ apiServerPort } /mirror?${ queryString . stringify ( queryObject ) } `
141
+ const testUrl = `${ protocol } ://${ HOSTNAME } :${ apiServerPort } /mirror?${ queryString . stringify ( queryObject ) } `
142
142
const response = await fetch ( testUrl , {
143
143
agent : new HttpProxyAgent ( proxyOpts ) ,
144
144
headers
@@ -170,13 +170,14 @@ describe('https proxy', () => {
170
170
const apiServerAddress = apiServer . address ( )
171
171
const queryObject = { foo : 'bar' }
172
172
173
- const testUrl = `${ protocol } ://localhost :${ apiServerAddress . port } /mirror?${ queryString . stringify ( queryObject ) } `
173
+ const testUrl = `${ protocol } ://${ HOSTNAME } :${ apiServerAddress . port } /mirror?${ queryString . stringify ( queryObject ) } `
174
174
175
175
const proxyUrl = proxyServer . url
176
176
const proxyOpts = urlToHttpOptions ( proxyUrl )
177
177
// the passing on of this property to the underlying implementation only works on https-proxy-agent@2.2.4
178
178
// this is only used for unit-tests and passed in the constructor
179
179
proxyOpts . rejectUnauthorized = false
180
+ proxyOpts . ALPNProtocols = [ 'http/1.1' ]
180
181
181
182
const response = await fetch ( testUrl , {
182
183
agent : new HttpsProxyAgent ( proxyOpts )
@@ -188,13 +189,14 @@ describe('https proxy', () => {
188
189
189
190
test ( 'failure' , async ( ) => {
190
191
// connect to non-existent server port
191
- const testUrl = `${ protocol } ://localhost :${ portNotInUse } /mirror/?foo=bar`
192
+ const testUrl = `${ protocol } ://${ HOSTNAME } :${ portNotInUse } /mirror/?foo=bar`
192
193
193
194
const proxyUrl = proxyServer . url
194
195
const proxyOpts = urlToHttpOptions ( proxyUrl )
195
196
// the passing on of this property to the underlying implementation only works on https-proxy-agent@2.2.4
196
197
// this is only used for unit-tests and passed in the constructor
197
198
proxyOpts . rejectUnauthorized = false
199
+ proxyOpts . ALPNProtocols = [ 'http/1.1' ]
198
200
199
201
const response = await fetch ( testUrl , {
200
202
agent : new HttpsProxyAgent ( proxyOpts )
@@ -230,8 +232,9 @@ describe('https proxy', () => {
230
232
// the passing on of this property to the underlying implementation only works on https-proxy-agent@2.2.4
231
233
// this is only used for unit-tests and passed in the constructor
232
234
proxyOpts . rejectUnauthorized = false
235
+ proxyOpts . ALPNProtocols = [ 'http/1.1' ]
233
236
234
- const testUrl = `${ protocol } ://localhost :${ apiServerPort } /mirror?${ queryString . stringify ( queryObject ) } `
237
+ const testUrl = `${ protocol } ://${ HOSTNAME } :${ apiServerPort } /mirror?${ queryString . stringify ( queryObject ) } `
235
238
const response = await fetch ( testUrl , {
236
239
agent : new HttpsProxyAgent ( proxyOpts ) ,
237
240
headers
@@ -256,8 +259,9 @@ describe('https proxy', () => {
256
259
// the passing on of this property to the underlying implementation only works on https-proxy-agent@2.2.4
257
260
// this is only used for unit-tests and passed in the constructor
258
261
proxyOpts . rejectUnauthorized = false
262
+ proxyOpts . ALPNProtocols = [ 'http/1.1' ]
259
263
260
- const testUrl = `${ protocol } ://localhost :${ apiServerPort } /mirror?${ queryString . stringify ( queryObject ) } `
264
+ const testUrl = `${ protocol } ://${ HOSTNAME } :${ apiServerPort } /mirror?${ queryString . stringify ( queryObject ) } `
261
265
const response = await fetch ( testUrl , {
262
266
agent : new HttpsProxyAgent ( proxyOpts ) ,
263
267
headers
0 commit comments