Skip to content
Myr

Added failing test for gotcha

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent eac6665 · Browse files · 1 file+17 added−3 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+17 added−3 removed

  • tests:+17 added−3 removed

1 file+17 added−3 removed

modified:test/express.test.js+17 added-3 removed
433 unmodified lines
434 { body: 'restored' }435 );436 },437 438 'test route middleware': function(){439 var app = express.createServer();438 'test route middleware': function(beforeExit){439 var app = express.createServer()440 , calls = 0;441442 function allow(role) {443 return function(req, res, next) {444 // this is totally not real, dont use this :)
15 unmodified lines
460 }461 }462 }463464 app.param('user', function(req, res, next, user){465 ++calls;466 next();467 });468469 app.get('/xxx', allow('member'), restrictAge(18), function(req, res){470 res.send(200);471 });472
3 unmodified lines
476477 app.get('/tobi', [allow('member')], [[restrictAge(18)]], function(req, res){478 res.send(200);479 });480 481 app.get('/user/:user', [allow('member')], [[restrictAge(18)]], function(req, res){482 res.send(200);483 });484475 ['xxx', 'booze', 'tobi'].forEach(function(thing){485 ['xxx', 'booze', 'tobi', 'user/tj'].forEach(function(thing){486 assert.response(app,487 { url: '/' + thing },488 { body: 'Unauthorized', status: 401 });489 assert.response(app,
2 unmodified lines
492 assert.response(app,493 { url: '/' + thing, headers: { 'X-Role': 'member', 'X-Age': 18 }},494 { body: 'OK', status: 200 });495 });496497 beforeExit(function(){498 calls.should.equal(3);499 });500 },501 502 'test named capture groups': function(){503 var app = express.createServer();
118 unmodified lines