tests: add missing FQDN router URL tests
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent ef497fd · Browse files · 1 file·+105 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+105 added−0 removed
- tests:+105 added−0 removed
Provenance
- Commit
968b00c- Tree
d159268- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
ef497fd
1 file changed+105 added−0 removed
modified:test/Router.js+105 added
172 unmodified lines173 router.handle({ url: '/', method: 'GET' }, {}, done);174 });175 })176 177+ describe('FQDN', function () {178+ it('should not obscure FQDNs', function (done) {179+ var request = { hit: 0, url: 'http://example.com/foo', method: 'GET' };180+ var router = new Router();181+182+ router.use(function (req, res, next) {183+ assert.equal(req.hit++, 0);184+ assert.equal(req.url, 'http://example.com/foo');185+ next();186+ });187+188+ router.handle(request, {}, function (err) {189+ if (err) return done(err);190+ assert.equal(request.hit, 1);191+ done();192+ });193+ });194+195+ it('should ignore FQDN in search', function (done) {196+ var request = { hit: 0, url: '/proxy?url=http://example.com/blog/post/1', method: 'GET' };197+ var router = new Router();198+199+ router.use('/proxy', function (req, res, next) {200+ assert.equal(req.hit++, 0);201+ assert.equal(req.url, '/?url=http://example.com/blog/post/1');202+ next();203+ });204+205+ router.handle(request, {}, function (err) {206+ if (err) return done(err);207+ assert.equal(request.hit, 1);208+ done();209+ });210+ });211+212+ it('should adjust FQDN req.url', function (done) {213+ var request = { hit: 0, url: 'http://example.com/blog/post/1', method: 'GET' };214+ var router = new Router();215+216+ router.use('/blog', function (req, res, next) {217+ assert.equal(req.hit++, 0);218+ assert.equal(req.url, 'http://example.com/post/1');219+ next();220+ });221+222+ router.handle(request, {}, function (err) {223+ if (err) return done(err);224+ assert.equal(request.hit, 1);225+ done();226+ });227+ });228+229+ it('should adjust FQDN req.url with multiple handlers', function (done) {230+ var request = { hit: 0, url: 'http://example.com/blog/post/1', method: 'GET' };231+ var router = new Router();232+233+ router.use(function (req, res, next) {234+ assert.equal(req.hit++, 0);235+ assert.equal(req.url, 'http://example.com/blog/post/1');236+ next();237+ });238+239+ router.use('/blog', function (req, res, next) {240+ assert.equal(req.hit++, 1);241+ assert.equal(req.url, 'http://example.com/post/1');242+ next();243+ });244+245+ router.handle(request, {}, function (err) {246+ if (err) return done(err);247+ assert.equal(request.hit, 2);248+ done();249+ });250+ });251+252+ it('should adjust FQDN req.url with multiple routed handlers', function (done) {253+ var request = { hit: 0, url: 'http://example.com/blog/post/1', method: 'GET' };254+ var router = new Router();255+256+ router.use('/blog', function (req, res, next) {257+ assert.equal(req.hit++, 0);258+ assert.equal(req.url, 'http://example.com/post/1');259+ next();260+ });261+262+ router.use('/blog', function (req, res, next) {263+ assert.equal(req.hit++, 1);264+ assert.equal(req.url, 'http://example.com/post/1');265+ next();266+ });267+268+ router.use(function (req, res, next) {269+ assert.equal(req.hit++, 2);270+ assert.equal(req.url, 'http://example.com/blog/post/1');271+ next();272+ });273+274+ router.handle(request, {}, function (err) {275+ if (err) return done(err);276+ assert.equal(request.hit, 3);277+ done();278+ });279+ });280+ })281+282 describe('.all', function() {283 it('should support using .all to capture all http verbs', function(done){284 var router = new Router();285 141 unmodified lines