@@ -72,7 +72,7 @@ test('trust should not alter input array', function (t) {
72
72
const arr = [ 'loopback' , '10.0.0.1' ]
73
73
const req = createReq ( '127.0.0.1' )
74
74
t . doesNotThrow ( proxyaddr . bind ( null , req , arr ) )
75
- t . deepEqual ( arr , [ 'loopback' , '10.0.0.1' ] )
75
+ t . same ( arr , [ 'loopback' , '10.0.0.1' ] )
76
76
t . end ( )
77
77
} )
78
78
@@ -115,7 +115,7 @@ test('trust should be invoked as trust(addr, i)', function (t) {
115
115
return log . push ( Array . prototype . slice . call ( arguments ) )
116
116
} )
117
117
118
- t . deepEqual ( log , [
118
+ t . same ( log , [
119
119
[ '127.0.0.1' , 0 ] ,
120
120
[ '10.0.0.1' , 1 ]
121
121
] )
@@ -125,249 +125,249 @@ test('trust should be invoked as trust(addr, i)', function (t) {
125
125
126
126
test ( 'with all trusted should return socket address wtesth no headers' , function ( t ) {
127
127
const req = createReq ( '127.0.0.1' )
128
- t . strictEqual ( proxyaddr ( req , all ) , '127.0.0.1' )
128
+ t . equal ( proxyaddr ( req , all ) , '127.0.0.1' )
129
129
t . end ( )
130
130
} )
131
131
132
132
test ( 'with all trusted should return header value' , function ( t ) {
133
133
const req = createReq ( '127.0.0.1' , {
134
134
'x-forwarded-for' : '10.0.0.1'
135
135
} )
136
- t . strictEqual ( proxyaddr ( req , all ) , '10.0.0.1' )
136
+ t . equal ( proxyaddr ( req , all ) , '10.0.0.1' )
137
137
t . end ( )
138
138
} )
139
139
140
140
test ( 'with all trusted should return furthest header value' , function ( t ) {
141
141
const req = createReq ( '127.0.0.1' , {
142
142
'x-forwarded-for' : '10.0.0.1, 10.0.0.2'
143
143
} )
144
- t . strictEqual ( proxyaddr ( req , all ) , '10.0.0.1' )
144
+ t . equal ( proxyaddr ( req , all ) , '10.0.0.1' )
145
145
t . end ( )
146
146
} )
147
147
148
148
test ( 'with none trusted should return socket address wtesth no headers' , function ( t ) {
149
149
const req = createReq ( '127.0.0.1' )
150
- t . strictEqual ( proxyaddr ( req , none ) , '127.0.0.1' )
150
+ t . equal ( proxyaddr ( req , none ) , '127.0.0.1' )
151
151
t . end ( )
152
152
} )
153
153
154
154
test ( 'with none trusted should return socket address wtesth headers' , function ( t ) {
155
155
const req = createReq ( '127.0.0.1' , {
156
156
'x-forwarded-for' : '10.0.0.1, 10.0.0.2'
157
157
} )
158
- t . strictEqual ( proxyaddr ( req , none ) , '127.0.0.1' )
158
+ t . equal ( proxyaddr ( req , none ) , '127.0.0.1' )
159
159
t . end ( )
160
160
} )
161
161
162
162
test ( 'with some trusted should return socket address wtesth no headers' , function ( t ) {
163
163
const req = createReq ( '127.0.0.1' )
164
- t . strictEqual ( proxyaddr ( req , trust10x ) , '127.0.0.1' )
164
+ t . equal ( proxyaddr ( req , trust10x ) , '127.0.0.1' )
165
165
t . end ( )
166
166
} )
167
167
168
168
test ( 'with some trusted should return socket address when not trusted' , function ( t ) {
169
169
const req = createReq ( '127.0.0.1' , {
170
170
'x-forwarded-for' : '10.0.0.1, 10.0.0.2'
171
171
} )
172
- t . strictEqual ( proxyaddr ( req , trust10x ) , '127.0.0.1' )
172
+ t . equal ( proxyaddr ( req , trust10x ) , '127.0.0.1' )
173
173
t . end ( )
174
174
} )
175
175
176
176
test ( 'with some trusted should return header when socket trusted' , function ( t ) {
177
177
const req = createReq ( '10.0.0.1' , {
178
178
'x-forwarded-for' : '192.168.0.1'
179
179
} )
180
- t . strictEqual ( proxyaddr ( req , trust10x ) , '192.168.0.1' )
180
+ t . equal ( proxyaddr ( req , trust10x ) , '192.168.0.1' )
181
181
t . end ( )
182
182
} )
183
183
184
184
test ( 'with some trusted should return first untrusted after trusted' , function ( t ) {
185
185
const req = createReq ( '10.0.0.1' , {
186
186
'x-forwarded-for' : '192.168.0.1, 10.0.0.2'
187
187
} )
188
- t . strictEqual ( proxyaddr ( req , trust10x ) , '192.168.0.1' )
188
+ t . equal ( proxyaddr ( req , trust10x ) , '192.168.0.1' )
189
189
t . end ( )
190
190
} )
191
191
192
192
test ( 'with some trusted should not skip untrusted' , function ( t ) {
193
193
const req = createReq ( '10.0.0.1' , {
194
194
'x-forwarded-for' : '10.0.0.3, 192.168.0.1, 10.0.0.2'
195
195
} )
196
- t . strictEqual ( proxyaddr ( req , trust10x ) , '192.168.0.1' )
196
+ t . equal ( proxyaddr ( req , trust10x ) , '192.168.0.1' )
197
197
t . end ( )
198
198
} )
199
199
200
200
test ( 'when given array should accept ltesteral IP addresses' , function ( t ) {
201
201
const req = createReq ( '10.0.0.1' , {
202
202
'x-forwarded-for' : '192.168.0.1, 10.0.0.2'
203
203
} )
204
- t . strictEqual ( proxyaddr ( req , [ '10.0.0.1' , '10.0.0.2' ] ) , '192.168.0.1' )
204
+ t . equal ( proxyaddr ( req , [ '10.0.0.1' , '10.0.0.2' ] ) , '192.168.0.1' )
205
205
t . end ( )
206
206
} )
207
207
208
208
test ( 'when given array should not trust non-IP addresses' , function ( t ) {
209
209
const req = createReq ( '10.0.0.1' , {
210
210
'x-forwarded-for' : '192.168.0.1, 10.0.0.2, localhost'
211
211
} )
212
- t . strictEqual ( proxyaddr ( req , [ '10.0.0.1' , '10.0.0.2' ] ) , 'localhost' )
212
+ t . equal ( proxyaddr ( req , [ '10.0.0.1' , '10.0.0.2' ] ) , 'localhost' )
213
213
t . end ( )
214
214
} )
215
215
216
216
test ( 'when given array should return socket address if none match' , function ( t ) {
217
217
const req = createReq ( '10.0.0.1' , {
218
218
'x-forwarded-for' : '192.168.0.1, 10.0.0.2'
219
219
} )
220
- t . strictEqual ( proxyaddr ( req , [ '127.0.0.1' , '192.168.0.100' ] ) , '10.0.0.1' )
220
+ t . equal ( proxyaddr ( req , [ '127.0.0.1' , '192.168.0.100' ] ) , '10.0.0.1' )
221
221
t . end ( )
222
222
} )
223
223
224
224
test ( 'when array empty should return socket address ' , function ( t ) {
225
225
const req = createReq ( '127.0.0.1' )
226
- t . strictEqual ( proxyaddr ( req , [ ] ) , '127.0.0.1' )
226
+ t . equal ( proxyaddr ( req , [ ] ) , '127.0.0.1' )
227
227
t . end ( )
228
228
} )
229
229
230
230
test ( 'when array empty should return socket address wtesth headers' , function ( t ) {
231
231
const req = createReq ( '127.0.0.1' , {
232
232
'x-forwarded-for' : '10.0.0.1, 10.0.0.2'
233
233
} )
234
- t . strictEqual ( proxyaddr ( req , [ ] ) , '127.0.0.1' )
234
+ t . equal ( proxyaddr ( req , [ ] ) , '127.0.0.1' )
235
235
t . end ( )
236
236
} )
237
237
238
238
test ( 'when given IPv4 addresses should accept ltesteral IP addresses' , function ( t ) {
239
239
const req = createReq ( '10.0.0.1' , {
240
240
'x-forwarded-for' : '192.168.0.1, 10.0.0.2'
241
241
} )
242
- t . strictEqual ( proxyaddr ( req , [ '10.0.0.1' , '10.0.0.2' ] ) , '192.168.0.1' )
242
+ t . equal ( proxyaddr ( req , [ '10.0.0.1' , '10.0.0.2' ] ) , '192.168.0.1' )
243
243
t . end ( )
244
244
} )
245
245
246
246
test ( 'when given IPv4 addresses should accept CIDR notation' , function ( t ) {
247
247
const req = createReq ( '10.0.0.1' , {
248
248
'x-forwarded-for' : '192.168.0.1, 10.0.0.200'
249
249
} )
250
- t . strictEqual ( proxyaddr ( req , '10.0.0.2/26' ) , '10.0.0.200' )
250
+ t . equal ( proxyaddr ( req , '10.0.0.2/26' ) , '10.0.0.200' )
251
251
t . end ( )
252
252
} )
253
253
254
254
test ( 'when given IPv4 addresses should accept netmask notation' , function ( t ) {
255
255
const req = createReq ( '10.0.0.1' , {
256
256
'x-forwarded-for' : '192.168.0.1, 10.0.0.200'
257
257
} )
258
- t . strictEqual ( proxyaddr ( req , '10.0.0.2/255.255.255.192' ) , '10.0.0.200' )
258
+ t . equal ( proxyaddr ( req , '10.0.0.2/255.255.255.192' ) , '10.0.0.200' )
259
259
t . end ( )
260
260
} )
261
261
262
262
test ( 'when given IPv6 addresses should accept ltesteral IP addresses' , function ( t ) {
263
263
const req = createReq ( 'fe80::1' , {
264
264
'x-forwarded-for' : '2002:c000:203::1, fe80::2'
265
265
} )
266
- t . strictEqual ( proxyaddr ( req , [ 'fe80::1' , 'fe80::2' ] ) , '2002:c000:203::1' )
266
+ t . equal ( proxyaddr ( req , [ 'fe80::1' , 'fe80::2' ] ) , '2002:c000:203::1' )
267
267
t . end ( )
268
268
} )
269
269
270
270
test ( 'when given IPv6 addresses should accept CIDR notation' , function ( t ) {
271
271
const req = createReq ( 'fe80::1' , {
272
272
'x-forwarded-for' : '2002:c000:203::1, fe80::ff00'
273
273
} )
274
- t . strictEqual ( proxyaddr ( req , 'fe80::/125' ) , 'fe80::ff00' )
274
+ t . equal ( proxyaddr ( req , 'fe80::/125' ) , 'fe80::ff00' )
275
275
t . end ( )
276
276
} )
277
277
278
278
test ( 'with IP version mixed should match respective versions' , function ( t ) {
279
279
const req = createReq ( '::1' , {
280
280
'x-forwarded-for' : '2002:c000:203::1'
281
281
} )
282
- t . strictEqual ( proxyaddr ( req , [ '127.0.0.1' , '::1' ] ) , '2002:c000:203::1' )
282
+ t . equal ( proxyaddr ( req , [ '127.0.0.1' , '::1' ] ) , '2002:c000:203::1' )
283
283
t . end ( )
284
284
} )
285
285
286
286
test ( 'with IP version mixed should not match IPv4 to IPv6' , function ( t ) {
287
287
const req = createReq ( '::1' , {
288
288
'x-forwarded-for' : '2002:c000:203::1'
289
289
} )
290
- t . strictEqual ( proxyaddr ( req , '127.0.0.1' ) , '::1' )
290
+ t . equal ( proxyaddr ( req , '127.0.0.1' ) , '::1' )
291
291
t . end ( )
292
292
} )
293
293
294
294
test ( 'when IPv4-mapped IPv6 addresses should match IPv4 trust to IPv6 request' , function ( t ) {
295
295
const req = createReq ( '::ffff:a00:1' , {
296
296
'x-forwarded-for' : '192.168.0.1, 10.0.0.2'
297
297
} )
298
- t . strictEqual ( proxyaddr ( req , [ '10.0.0.1' , '10.0.0.2' ] ) , '192.168.0.1' )
298
+ t . equal ( proxyaddr ( req , [ '10.0.0.1' , '10.0.0.2' ] ) , '192.168.0.1' )
299
299
t . end ( )
300
300
} )
301
301
302
302
test ( 'when IPv4-mapped IPv6 addresses should match IPv4 netmask trust to IPv6 request' , function ( t ) {
303
303
const req = createReq ( '::ffff:a00:1' , {
304
304
'x-forwarded-for' : '192.168.0.1, 10.0.0.2'
305
305
} )
306
- t . strictEqual ( proxyaddr ( req , [ '10.0.0.1/16' ] ) , '192.168.0.1' )
306
+ t . equal ( proxyaddr ( req , [ '10.0.0.1/16' ] ) , '192.168.0.1' )
307
307
t . end ( )
308
308
} )
309
309
310
310
test ( 'when IPv4-mapped IPv6 addresses should match IPv6 trust to IPv4 request' , function ( t ) {
311
311
const req = createReq ( '10.0.0.1' , {
312
312
'x-forwarded-for' : '192.168.0.1, 10.0.0.2'
313
313
} )
314
- t . strictEqual ( proxyaddr ( req , [ '::ffff:a00:1' , '::ffff:a00:2' ] ) , '192.168.0.1' )
314
+ t . equal ( proxyaddr ( req , [ '::ffff:a00:1' , '::ffff:a00:2' ] ) , '192.168.0.1' )
315
315
t . end ( )
316
316
} )
317
317
318
318
test ( 'when IPv4-mapped IPv6 addresses should match CIDR notation for IPv4-mapped address' , function ( t ) {
319
319
const req = createReq ( '10.0.0.1' , {
320
320
'x-forwarded-for' : '192.168.0.1, 10.0.0.200'
321
321
} )
322
- t . strictEqual ( proxyaddr ( req , '::ffff:a00:2/122' ) , '10.0.0.200' )
322
+ t . equal ( proxyaddr ( req , '::ffff:a00:2/122' ) , '10.0.0.200' )
323
323
t . end ( )
324
324
} )
325
325
326
326
test ( 'when IPv4-mapped IPv6 addresses should match CIDR notation for IPv4-mapped address mixed wtesth IPv6 CIDR' , function ( t ) {
327
327
const req = createReq ( '10.0.0.1' , {
328
328
'x-forwarded-for' : '192.168.0.1, 10.0.0.200'
329
329
} )
330
- t . strictEqual ( proxyaddr ( req , [ '::ffff:a00:2/122' , 'fe80::/125' ] ) , '10.0.0.200' )
330
+ t . equal ( proxyaddr ( req , [ '::ffff:a00:2/122' , 'fe80::/125' ] ) , '10.0.0.200' )
331
331
t . end ( )
332
332
} )
333
333
334
334
test ( 'when IPv4-mapped IPv6 addresses should match CIDR notation for IPv4-mapped address mixed wtesth IPv4 addresses' , function ( t ) {
335
335
const req = createReq ( '10.0.0.1' , {
336
336
'x-forwarded-for' : '192.168.0.1, 10.0.0.200'
337
337
} )
338
- t . strictEqual ( proxyaddr ( req , [ '::ffff:a00:2/122' , '127.0.0.1' ] ) , '10.0.0.200' )
338
+ t . equal ( proxyaddr ( req , [ '::ffff:a00:2/122' , '127.0.0.1' ] ) , '10.0.0.200' )
339
339
t . end ( )
340
340
} )
341
341
342
342
test ( 'when given predefined names should accept single pre-defined name' , function ( t ) {
343
343
const req = createReq ( 'fe80::1' , {
344
344
'x-forwarded-for' : '2002:c000:203::1, fe80::2'
345
345
} )
346
- t . strictEqual ( proxyaddr ( req , 'linklocal' ) , '2002:c000:203::1' )
346
+ t . equal ( proxyaddr ( req , 'linklocal' ) , '2002:c000:203::1' )
347
347
t . end ( )
348
348
} )
349
349
350
350
test ( 'when given predefined names should accept multiple pre-defined names' , function ( t ) {
351
351
const req = createReq ( '::1' , {
352
352
'x-forwarded-for' : '2002:c000:203::1, fe80::2'
353
353
} )
354
- t . strictEqual ( proxyaddr ( req , [ 'loopback' , 'linklocal' ] ) , '2002:c000:203::1' )
354
+ t . equal ( proxyaddr ( req , [ 'loopback' , 'linklocal' ] ) , '2002:c000:203::1' )
355
355
t . end ( )
356
356
} )
357
357
358
358
test ( 'when header contains non-ip addresses should stop at first non-ip after trusted' , function ( t ) {
359
359
const req = createReq ( '127.0.0.1' , {
360
360
'x-forwarded-for' : 'myrouter, 127.0.0.1, proxy'
361
361
} )
362
- t . strictEqual ( proxyaddr ( req , '127.0.0.1' ) , 'proxy' )
362
+ t . equal ( proxyaddr ( req , '127.0.0.1' ) , 'proxy' )
363
363
t . end ( )
364
364
} )
365
365
366
366
test ( 'when header contains non-ip addresses should stop at first malformed ip after trusted' , function ( t ) {
367
367
const req = createReq ( '127.0.0.1' , {
368
368
'x-forwarded-for' : 'myrouter, 127.0.0.1, ::8:8:8:8:8:8:8:8:8'
369
369
} )
370
- t . strictEqual ( proxyaddr ( req , '127.0.0.1' ) , '::8:8:8:8:8:8:8:8:8' )
370
+ t . equal ( proxyaddr ( req , '127.0.0.1' ) , '::8:8:8:8:8:8:8:8:8' )
371
371
t . end ( )
372
372
} )
373
373
@@ -381,7 +381,7 @@ test('when header contains non-ip addresses should provide all values to functio
381
381
return log . push ( Array . prototype . slice . call ( arguments ) )
382
382
} )
383
383
384
- t . deepEqual ( log , [
384
+ t . same ( log , [
385
385
[ '127.0.0.1' , 0 ] ,
386
386
[ 'proxy' , 1 ] ,
387
387
[ '127.0.0.1' , 2 ]
@@ -391,15 +391,15 @@ test('when header contains non-ip addresses should provide all values to functio
391
391
392
392
test ( 'when socket address undefined should return undefined as address' , function ( t ) {
393
393
const req = createReq ( undefined )
394
- t . strictEqual ( proxyaddr ( req , '127.0.0.1' ) , undefined )
394
+ t . equal ( proxyaddr ( req , '127.0.0.1' ) , undefined )
395
395
t . end ( )
396
396
} )
397
397
398
398
test ( 'when socket address undefined should return undefined even wtesth trusted headers' , function ( t ) {
399
399
const req = createReq ( undefined , {
400
400
'x-forwarded-for' : '127.0.0.1, 10.0.0.1'
401
401
} )
402
- t . strictEqual ( proxyaddr ( req , '127.0.0.1' ) , undefined )
402
+ t . equal ( proxyaddr ( req , '127.0.0.1' ) , undefined )
403
403
t . end ( )
404
404
} )
405
405
0 commit comments