req.ips.js
This file
Path
test/req.ips.js
55 lines · 1.3 KiB · JavaScript
Last changed by
Added `req.ip`TJ Holowaychukbefore adoptiond84d0b6
History of this fileTake it
The walk stopped after 200 commits: lines older than 7294806 point at it.
try npm publishConfigTJ Holowaychukbefore adoption7294806
lines 1–7why, one step back12var express = require('../')3 , request = require('./support/http');45describe('req', function(){6 describe('.ips', function(){7 describe('when X-Forwarded-For is present', function(){Added `req.ip`TJ Holowaychukbefore adoptiond84d0b6
line 8why, one step back8 describe('when "trust proxy" is enabled', function(){Fixed setting check for req.ipsTJ Holowaychukbefore adoptione3cbac2
lines 9–10why, one step back9 it('should return an array of the specified addresses', function(done){10 var app = express();try npm publishConfigTJ Holowaychukbefore adoption7294806
line 11why, one step back11Fixed setting check for req.ipsTJ Holowaychukbefore adoptione3cbac2
line 12why, one step back12 app.enable('trust proxy');try npm publishConfigTJ Holowaychukbefore adoption7294806
line 13why, one step back13Fixed setting check for req.ipsTJ Holowaychukbefore adoptione3cbac2
lines 14–20why, one step back14 app.use(function(req, res, next){15 res.send(req.ips);16 });1718 request(app)19 .get('/')20 .set('X-Forwarded-For', 'client, p1, p2')Changed: dont reverse `req.ips`TJ Holowaychukbefore adoptionb694ba2
line 21why, one step back21 .expect('["client","p1","p2"]', done);Fixed setting check for req.ipsTJ Holowaychukbefore adoptione3cbac2
lines 22–24why, one step back22 })23 })24Added `req.ip`TJ Holowaychukbefore adoptiond84d0b6
line 25why, one step back25 describe('when "trust proxy" is disabled', function(){Fixed setting check for req.ipsTJ Holowaychukbefore adoptione3cbac2
lines 26–37why, one step back26 it('should return an empty array', function(done){27 var app = express();2829 app.use(function(req, res, next){30 res.send(req.ips);31 });3233 request(app)34 .get('/')35 .set('X-Forwarded-For', 'client, p1, p2')36 .expect('[]', done);37 })try npm publishConfigTJ Holowaychukbefore adoption7294806
lines 38–55why, one step back38 })39 })4041 describe('when X-Forwarded-For is not present', function(){42 it('should return []', function(done){43 var app = express();4445 app.use(function(req, res, next){46 res.send(req.ips);47 });4849 request(app)50 .get('/')51 .expect('[]', done);52 })53 })54 })55})