Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit cd18ccf

Browse files
committed
Use localhost instead of 127.0.0.1 for tests
Fixes warning on Node 12: ``` (node:74065) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version. ```
1 parent 778ea05 commit cd18ccf

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

test/test.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,17 @@ describe('ProxyAgent', function () {
144144
res.end(JSON.stringify(req.headers));
145145
});
146146

147-
var uri = 'http://127.0.0.1:' + proxyPort;
147+
var uri = 'http://localhost:' + proxyPort;
148148
var agent = new ProxyAgent(uri);
149149

150-
var opts = url.parse('http://127.0.0.1:' + httpPort + '/test');
150+
var opts = url.parse('http://localhost:' + httpPort + '/test');
151151
opts.agent = agent;
152152

153153
var req = http.get(opts, function (res) {
154154
toBuffer(res, function (err, buf) {
155155
if (err) return done(err);
156156
var data = JSON.parse(buf.toString('utf8'));
157-
assert.equal('127.0.0.1:' + httpPort, data.host);
157+
assert.equal('localhost:' + httpPort, data.host);
158158
assert('via' in data);
159159
done();
160160
});
@@ -169,17 +169,17 @@ describe('ProxyAgent', function () {
169169
res.end(JSON.stringify(req.headers));
170170
});
171171

172-
process.env.HTTP_PROXY = 'http://127.0.0.1:' + proxyPort;
172+
process.env.HTTP_PROXY = 'http://localhost:' + proxyPort;
173173
var agent = new ProxyAgent();
174174

175-
var opts = url.parse('http://127.0.0.1:' + httpPort + '/test');
175+
var opts = url.parse('http://localhost:' + httpPort + '/test');
176176
opts.agent = agent;
177177

178178
var req = http.get(opts, function (res) {
179179
toBuffer(res, function (err, buf) {
180180
if (err) return done(err);
181181
var data = JSON.parse(buf.toString('utf8'));
182-
assert.equal('127.0.0.1:' + httpPort, data.host);
182+
assert.equal('localhost:' + httpPort, data.host);
183183
assert('via' in data);
184184
done();
185185
});
@@ -197,14 +197,14 @@ describe('ProxyAgent', function () {
197197
process.env.NO_PROXY = '*';
198198
var agent = new ProxyAgent();
199199

200-
var opts = url.parse('http://127.0.0.1:' + httpPort + '/test');
200+
var opts = url.parse('http://localhost:' + httpPort + '/test');
201201
opts.agent = agent;
202202

203203
var req = http.get(opts, function (res) {
204204
toBuffer(res, function (err, buf) {
205205
if (err) return done(err);
206206
var data = JSON.parse(buf.toString('utf8'));
207-
assert.equal('127.0.0.1:' + httpPort, data.host);
207+
assert.equal('localhost:' + httpPort, data.host);
208208
assert(!('via' in data));
209209
done();
210210
});
@@ -219,19 +219,19 @@ describe('ProxyAgent', function () {
219219
res.end(JSON.stringify(req.headers));
220220
});
221221

222-
var uri = 'https://127.0.0.1:' + proxyHttpsPort;
222+
var uri = 'https://localhost:' + proxyHttpsPort;
223223
var proxy = url.parse(uri);
224224
proxy.rejectUnauthorized = false;
225225
var agent = new ProxyAgent(proxy);
226226

227-
var opts = url.parse('http://127.0.0.1:' + httpPort + '/test');
227+
var opts = url.parse('http://localhost:' + httpPort + '/test');
228228
opts.agent = agent;
229229

230230
var req = http.get(opts, function (res) {
231231
toBuffer(res, function (err, buf) {
232232
if (err) return done(err);
233233
var data = JSON.parse(buf.toString('utf8'));
234-
assert.equal('127.0.0.1:' + httpPort, data.host);
234+
assert.equal('localhost:' + httpPort, data.host);
235235
assert('via' in data);
236236
done();
237237
});
@@ -246,17 +246,17 @@ describe('ProxyAgent', function () {
246246
res.end(JSON.stringify(req.headers));
247247
});
248248

249-
var uri = 'socks://127.0.0.1:' + socksPort;
249+
var uri = 'socks://localhost:' + socksPort;
250250
var agent = new ProxyAgent(uri);
251251

252-
var opts = url.parse('http://127.0.0.1:' + httpPort + '/test');
252+
var opts = url.parse('http://localhost:' + httpPort + '/test');
253253
opts.agent = agent;
254254

255255
var req = http.get(opts, function (res) {
256256
toBuffer(res, function (err, buf) {
257257
if (err) return done(err);
258258
var data = JSON.parse(buf.toString('utf8'));
259-
assert.equal('127.0.0.1:' + httpPort, data.host);
259+
assert.equal('localhost:' + httpPort, data.host);
260260
done();
261261
});
262262
});
@@ -272,18 +272,18 @@ describe('ProxyAgent', function () {
272272
res.end(JSON.stringify(req.headers));
273273
});
274274

275-
var uri = 'http://127.0.0.1:' + proxyPort;
275+
var uri = 'http://localhost:' + proxyPort;
276276
var agent = new ProxyAgent(uri);
277277

278-
var opts = url.parse('https://127.0.0.1:' + httpsPort + '/test');
278+
var opts = url.parse('https://localhost:' + httpsPort + '/test');
279279
opts.agent = agent;
280280
opts.rejectUnauthorized = false;
281281

282282
var req = https.get(opts, function (res) {
283283
toBuffer(res, function (err, buf) {
284284
if (err) return done(err);
285285
var data = JSON.parse(buf.toString('utf8'));
286-
assert.equal('127.0.0.1:' + httpsPort, data.host);
286+
assert.equal('localhost:' + httpsPort, data.host);
287287
done();
288288
});
289289
});
@@ -301,20 +301,20 @@ describe('ProxyAgent', function () {
301301

302302
var agent = new ProxyAgent({
303303
protocol: 'https:',
304-
host: '127.0.0.1',
304+
host: 'localhost',
305305
port: proxyHttpsPort,
306306
rejectUnauthorized: false
307307
});
308308

309-
var opts = url.parse('https://127.0.0.1:' + httpsPort + '/test');
309+
var opts = url.parse('https://localhost:' + httpsPort + '/test');
310310
opts.agent = agent;
311311
opts.rejectUnauthorized = false;
312312

313313
var req = https.get(opts, function (res) {
314314
toBuffer(res, function (err, buf) {
315315
if (err) return done(err);
316316
var data = JSON.parse(buf.toString('utf8'));
317-
assert.equal('127.0.0.1:' + httpsPort, data.host);
317+
assert.equal('localhost:' + httpsPort, data.host);
318318
assert(gotReq);
319319
done();
320320
});
@@ -331,18 +331,18 @@ describe('ProxyAgent', function () {
331331
res.end(JSON.stringify(req.headers));
332332
});
333333

334-
var uri = 'socks://127.0.0.1:' + socksPort;
334+
var uri = 'socks://localhost:' + socksPort;
335335
var agent = new ProxyAgent(uri);
336336

337-
var opts = url.parse('https://127.0.0.1:' + httpsPort + '/test');
337+
var opts = url.parse('https://localhost:' + httpsPort + '/test');
338338
opts.agent = agent;
339339
opts.rejectUnauthorized = false;
340340

341341
var req = https.get(opts, function (res) {
342342
toBuffer(res, function (err, buf) {
343343
if (err) return done(err);
344344
var data = JSON.parse(buf.toString('utf8'));
345-
assert.equal('127.0.0.1:' + httpsPort, data.host);
345+
assert.equal('localhost:' + httpsPort, data.host);
346346
assert(gotReq);
347347
done();
348348
});

0 commit comments

Comments
 (0)