mirror of
https://github.com/zebrajr/express.git
synced 2026-01-15 12:15:27 +00:00
tests: add test for multiple ips in "trust proxy"
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user