chat controller test
parent
21e9c98973
commit
0d90279463
@ -1,9 +0,0 @@
|
||||
{
|
||||
"strict" : false, // true: Requires all functions run in ES5 Strict Mode
|
||||
|
||||
// Custom Globals
|
||||
"globals" : {
|
||||
"it": false,
|
||||
"describe": false
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
var request = require('request');
|
||||
var nconf = require('nconf');
|
||||
|
||||
var helpers = module.exports;
|
||||
|
||||
helpers.loginUser = function (username, password, callback) {
|
||||
var jar = request.jar();
|
||||
request({
|
||||
url: nconf.get('url') + '/api/config',
|
||||
json: true,
|
||||
jar: jar
|
||||
}, function (err, response, body) {
|
||||
if (err || response.statusCode !== 200) {
|
||||
return callback(err || new Error('[[error:invalid-response]]'));
|
||||
}
|
||||
|
||||
request.post(nconf.get('url') + '/login', {
|
||||
form: {
|
||||
username: username,
|
||||
password: password,
|
||||
},
|
||||
json: true,
|
||||
jar: jar,
|
||||
headers: {
|
||||
'x-csrf-token': body.csrf_token
|
||||
}
|
||||
}, function (err, response) {
|
||||
if (err || response.statusCode !== 200) {
|
||||
return callback(err || new Error('[[error:invalid-response]]'));
|
||||
}
|
||||
callback();
|
||||
});
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue