auth.js
This file
Path
test/acceptance/auth.js
42 lines · 1008 bytes · JavaScript
Last changed by
res.location: remove resolving relative urlsJonathan Ongbefore adoptionaac1d52
History of this fileTake it
The walk stopped after 200 commits: lines older than 8942722 point at it.
typoTJ Holowaychukbefore adoption8942722
lines 1–20why, one step back1var app = require('../../examples/auth/app')2 , request = require('../support/http');34function redirects(to, fn){5 return function(err, res){6 res.statusCode.should.equal(302)7 res.headers.should.have.property('location').match(to);8 fn()9 }10}1112function getCookie(res) {13 return res.headers['set-cookie'][0].split(';')[0];14}1516describe('auth', function(){17 describe('GET /',function(){18 it('should redirect to /login', function(done){19 request(app)20 .get('/')res.location: remove resolving relative urlsJonathan Ongbefore adoptionaac1d52
line 21why, one step back21 .end(redirects(/login$/, done))typoTJ Holowaychukbefore adoption8942722
lines 22–28why, one step back22 })23 })2425 describe('GET /restricted (w/o cookie)',function(){26 it('should redirect to /login', function(done){27 request(app)28 .get('/restricted')res.location: remove resolving relative urlsJonathan Ongbefore adoptionaac1d52
line 29why, one step back29 .end(redirects(/login$/,done))typoTJ Holowaychukbefore adoption8942722
lines 30–38why, one step back30 })31 })3233 describe('POST /login', function(){34 it('should fail without proper credentials', function(done){35 request(app)36 .post('/login')37 .type('urlencoded')38 .send('username=not-tj&password=foobar')res.location: remove resolving relative urlsJonathan Ongbefore adoptionaac1d52
line 39why, one step back39 .end(redirects(/login$/, done))typoTJ Holowaychukbefore adoption8942722
lines 40–42why, one step back40 })41 })42})