Skip to content
Myr

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

1 file+105 added−0 removed

modified:test/Router.js+105 added
172 unmodified lines
173 router.handle({ url: '/', method: 'GET' }, {}, done);174 });175 })176177 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();181182 router.use(function (req, res, next) {183 assert.equal(req.hit++, 0);184 assert.equal(req.url, 'http://example.com/foo');185 next();186 });187188 router.handle(request, {}, function (err) {189 if (err) return done(err);190 assert.equal(request.hit, 1);191 done();192 });193 });194195 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();198199 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 });204205 router.handle(request, {}, function (err) {206 if (err) return done(err);207 assert.equal(request.hit, 1);208 done();209 });210 });211212 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();215216 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 });221222 router.handle(request, {}, function (err) {223 if (err) return done(err);224 assert.equal(request.hit, 1);225 done();226 });227 });228229 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();232233 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 });238239 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 });244245 router.handle(request, {}, function (err) {246 if (err) return done(err);247 assert.equal(request.hit, 2);248 done();249 });250 });251252 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();255256 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 });261262 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 });267268 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 });273274 router.handle(request, {}, function (err) {275 if (err) return done(err);276 assert.equal(request.hit, 3);277 done();278 });279 });280 })281282 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