koa-lite/test/request/ips.js
broucz 4b1a1da652 test: switch all functions to arrow functions
closes #553

Update test: application -> use() should throw if not a function

Fix lint

Use arrow function

Refactor test using arrow function

Remove non mandatory brackets

fix for merge

Fix: missing refactor after merge

Use arrow function for old generator
2015-11-02 11:22:05 -08:00

26 lines
705 B
JavaScript

'use strict';
const request = require('../helpers/context').request;
describe('req.ips', () => {
describe('when X-Forwarded-For is present', () => {
describe('and proxy is not trusted', () => {
it('should be ignored', () => {
const req = request();
req.app.proxy = false;
req.header['x-forwarded-for'] = '127.0.0.1,127.0.0.2';
req.ips.should.eql([]);
});
});
describe('and proxy is trusted', () => {
it('should be used', () => {
const req = request();
req.app.proxy = true;
req.header['x-forwarded-for'] = '127.0.0.1,127.0.0.2';
req.ips.should.eql(['127.0.0.1', '127.0.0.2']);
});
});
});
});