2018-03-24 15:37:35 +00:00
|
|
|
const test = require('../testlib');
|
2018-03-23 17:16:39 +00:00
|
|
|
|
2018-03-24 15:37:35 +00:00
|
|
|
test.run(async function () {
|
|
|
|
test('admin', async function (assert, req) {
|
2018-03-24 14:09:33 +00:00
|
|
|
//Try to login with invalid username and password
|
|
|
|
var res = await req({
|
|
|
|
url: '/sessions',
|
|
|
|
method: 'post',
|
|
|
|
data: {
|
|
|
|
username: 'foo',
|
|
|
|
password: 'bar'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.equal(res.status, 403, 'Status not valid');
|
|
|
|
|
|
|
|
//Try to login with invalid username
|
|
|
|
var res = await req({
|
|
|
|
url: '/sessions',
|
|
|
|
method: 'post',
|
|
|
|
data: {
|
|
|
|
username: 'foo',
|
|
|
|
password: 'admin'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.equal(res.status, 403, 'Status not valid');
|
|
|
|
|
|
|
|
//Try to login with invalid password
|
|
|
|
var res = await req({
|
|
|
|
url: '/sessions',
|
|
|
|
method: 'post',
|
|
|
|
data: {
|
|
|
|
username: 'admin',
|
|
|
|
password: 'foo'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.equal(res.status, 403, 'Status not valid');
|
|
|
|
|
|
|
|
//Try to login with missing field
|
|
|
|
var res = await req({
|
|
|
|
url: '/sessions',
|
|
|
|
method: 'post',
|
|
|
|
data: {
|
|
|
|
password: 'admin'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.equal(res.status, 422, 'Status not valid');
|
|
|
|
|
|
|
|
//Try to login with invalid username and password
|
|
|
|
var res = await req({
|
|
|
|
url: '/sessions',
|
|
|
|
method: 'post',
|
|
|
|
data: {
|
|
|
|
username: 'foo/admin',
|
|
|
|
password: 'admin'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.equal(res.status, 201, 'Status not valid');
|
2018-03-23 17:16:39 +00:00
|
|
|
});
|
2018-03-24 15:37:35 +00:00
|
|
|
});
|