-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcsrf.js
36 lines (27 loc) · 917 Bytes
/
csrf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var request = require('supertest');
var should = require('should');
var cookie = require('cookie');
var utls = require('lockit-utils');
var config = require('./app/config.js');
var app = require('./app/app.js');
var db = utls.getDatabase(config);
var adapter = require(db.adapter)(config);
var _config = JSON.parse(JSON.stringify(config));
_config.port = 7000;
_config.csrf = true;
var _app = app(_config);
describe('# csrf', function() {
describe('GET /delete-account', function() {
it('should include the token in the view', function(done) {
request(_app)
.get('/delete-account')
.end(function(err, res) {
var cookies = cookie.parse(res.headers['set-cookie'][0]);
var token = cookies.csrf;
res.text.should.containEql('name="_csrf" value="' + token + '"');
res.statusCode.should.equal(200);
done();
});
});
});
});