req.ips.js
This file
Path
test/req.ips.js
70 lines · 1.7 KiB · JavaScript
Last changed by
remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3
History of this fileTake it
The walk stopped after 200 commits: lines older than a10f695 point at it.
pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 1–2why, one step back12var express = require('../')remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3
line 3why, one step back3 , request = require('supertest');pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 4–22why, one step back45describe('req', function(){6 describe('.ips', function(){7 describe('when X-Forwarded-For is present', function(){8 describe('when "trust proxy" is enabled', function(){9 it('should return an array of the specified addresses', function(done){10 var app = express();1112 app.enable('trust proxy');1314 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')21 .expect('["client","p1","p2"]', done);22 })improve proxy trust with ip address listDouglas Christopher Wilsonbefore adoption566720b
lines 23–37why, one step back2324 it('should stop at first untrusted', function(done){25 var app = express();2627 app.set('trust proxy', 2);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('["p1","p2"]', done);37 })pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 38–70why, one step back38 })3940 describe('when "trust proxy" is disabled', function(){41 it('should return an empty array', function(done){42 var app = express();4344 app.use(function(req, res, next){45 res.send(req.ips);46 });4748 request(app)49 .get('/')50 .set('X-Forwarded-For', 'client, p1, p2')51 .expect('[]', done);52 })53 })54 })5556 describe('when X-Forwarded-For is not present', function(){57 it('should return []', function(done){58 var app = express();5960 app.use(function(req, res, next){61 res.send(req.ips);62 });6364 request(app)65 .get('/')66 .expect('[]', done);67 })68 })69 })70})