Updated auth acceptance test style.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Robert Sköld · committed by TJ Holowaychuk · parent 9290f0d · Browse files · 1 file·+19 added−10 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+19 added−10 removed
- tests:+19 added−10 removed
Provenance
- Commit
0dd5836- Tree
b5b5991- Author
Robert Sköld <robert@publicclass.se>- Committer
TJ Holowaychuk <tj@vision-media.ca>- Parent
9290f0d
1 file changed+19 added−10 removed
modified:test/acceptance/auth.js+19 added-10 removed
12323567456789101112131415161717181920212223242526272826293031323314 unmodified lines484950514952535455565758595560616263646566676869707172736574757677783 unmodified linesvar app = require('../../examples/auth/app') , request = require('../support/http') , should = require('should'); , request = require('../support/http');
describe('examples', function(){ describe('auth', function(){ var cookie;describe('auth', function(){ var cookie; describe('GET /',function(){ it('should redirect to /login', function(done){ request(app) .get('/') .end(function(res){ res.statusCode.should.equal(302); res.headers.should.have.property('location').match(/\/login$/); done(); }) }) }) describe('GET /restricted (w/o cookie)',function(){ it('should be restricted', function(done){ it('should redirect to /login', function(done){ request(app) .get('/restricted') .end(function(res){ res.statusCode.should.equal(302); res.headers.should.have.property('location').match(/\/login$/); done(); }) }) }) describe('POST /login', function(){ it('should fail to authenticate', function(done){ it('should fail without proper credentials', function(done){ request(app) .post('/login') .write('&username=not-tj&password=foobar') .end(function(res){14 unmodified lines cookie.should.match(/^connect.sid=/) done(); }) }) it('should not be restricted with an authenticated session cookie',function(done){ }) describe('GET /restricted (w. cookie)',function(){ it('should respond with 200',function(done){ request(app) .get('/restricted') .set('cookie',cookie) .expect(200,done) }) it('should logout',function(done){ }) describe('GET /logout',function(){ it('should respond with 302 and clear cookie',function(done){ request(app) .get('/logout') .set('cookie',cookie) .end(function(res){ res.statusCode.should.equal(302); res.headers.should.not.have.property('set-cookie') done(); }) }) }) describe('GET /restricted (w. expired cookie)',function(){ it('should be restricted again',function(done){ it('should respond with 302',function(done){ request(app) .get('/restricted') .set('cookie',cookie) .expect(302,done)3 unmodified lines