Fix failing image and login tests

This commit is contained in:
Jonathan Cremin 2015-08-22 23:19:20 +01:00
parent 0910b16e1e
commit 3091c6dff6
2 changed files with 25 additions and 12 deletions

View file

@ -6,21 +6,29 @@ const request = agent(app.listen());
describe('hostr-web user', function() {
describe('when POST /signin with invalid credentials', function() {
it('should not redirect to /', function(done) {
request
.post('/signin')
.send({'email': 'test@hostr.co', 'password': 'test-passworddeded'})
.expect(200, done);
request.get('/signin').end(function(err, response) {
const match = response.text.match(/name="_csrf" value="([^"]+)"/);
const csrf = match[1];
request
.post('/signin')
.send({'email': 'test@hostr.co', 'password': 'test-passworddeded', '_csrf': csrf})
.expect(200, done);
});
});
});
describe('when POST /signin with valid credentials', function() {
it('should redirect to /', function(done) {
request
.post('/signin')
.send({'email': 'test@hostr.co', 'password': 'test-password'})
.expect(302)
.expect('Location', '/')
.end(done);
request.get('/signin').end(function(err, response) {
const match = response.text.match(/name="_csrf" value="([^"]+)"/);
const csrf = match[1];
request
.post('/signin')
.send({'email': 'test@hostr.co', 'password': 'test-password', '_csrf': csrf})
.expect(302)
.expect('Location', '/')
.end(done);
});
});
});
});