diff --git a/test/req.ip.js b/test/req.ip.js index 1cd255216b..23623cfce6 100644 --- a/test/req.ip.js +++ b/test/req.ip.js @@ -21,7 +21,7 @@ describe('req', function(){ .expect('client', done); }) - it('should return the addr after trusted proxy', function(done){ + it('should return the addr after trusted proxy based on count', function (done) { var app = express(); app.set('trust proxy', 2); @@ -36,6 +36,21 @@ describe('req', function(){ .expect('p1', done); }) + it('should return the addr after trusted proxy based on list', function (done) { + var app = express() + + app.set('trust proxy', '10.0.0.1, 10.0.0.2, 127.0.0.1, ::1') + + app.get('/', function (req, res) { + res.send(req.ip) + }) + + request(app) + .get('/') + .set('X-Forwarded-For', '10.0.0.2, 10.0.0.3, 10.0.0.1', '10.0.0.4') + .expect('10.0.0.3', done) + }) + it('should return the addr after trusted proxy, from sub app', function (done) { var app = express(); var sub = express();