Skip to content
Myr

req.ips.js

This file

Path

test/req.ips.js

55 lines · 1.3 KiB · JavaScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 496ee40 point at it.

Merge branch 'master' of github.com:visionmedia/expressTJ Holowaychukbefore adoption496ee40

lines 1–55why, one step back
1
2var express = require('../')3 , request = require('./support/http');45describe('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 })23 })2425 describe('when "trust proxy" is disabled', function(){26 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 })38 })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})