2015-07-09 23:01:43 +01:00
|
|
|
import { agent } from 'supertest';
|
2015-08-22 16:16:15 +01:00
|
|
|
import app from '../../app';
|
2015-07-09 23:01:43 +01:00
|
|
|
|
|
|
|
const request = agent(app.listen());
|
|
|
|
|
|
|
|
describe('hostr-web user', function() {
|
|
|
|
describe('when POST /signin with invalid credentials', function() {
|
2016-05-25 21:03:07 +01:00
|
|
|
it('should not redirect to /', function() {
|
2015-08-22 23:19:20 +01:00
|
|
|
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})
|
2016-05-25 21:03:07 +01:00
|
|
|
.expect(200);
|
2015-08-22 23:19:20 +01:00
|
|
|
});
|
2015-07-09 23:01:43 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when POST /signin with valid credentials', function() {
|
2016-05-25 21:03:07 +01:00
|
|
|
it('should redirect to /', function() {
|
2015-08-22 23:19:20 +01:00
|
|
|
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', '/')
|
2020-04-28 20:31:28 +01:00
|
|
|
.end(function() {
|
|
|
|
// Hax
|
|
|
|
process.exit();
|
|
|
|
});
|
2015-08-22 23:19:20 +01:00
|
|
|
});
|
2015-07-09 23:01:43 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|