diff --git a/test/authentication.js b/test/authentication.js index 7b49f69efa..6691a96c66 100644 --- a/test/authentication.js +++ b/test/authentication.js @@ -147,6 +147,33 @@ describe('authentication', function () { }); }); + it('should fail to login if user does not exist', function (done) { + var jar = request.jar(); + request({ + url: nconf.get('url') + '/api/config', + json: true, + jar: jar, + }, function (err, response, body) { + assert.ifError(err); + + request.post(nconf.get('url') + '/login', { + form: { + username: 'doesnotexist', + password: 'nopassword', + }, + json: true, + jar: jar, + headers: { + 'x-csrf-token': body.csrf_token, + }, + }, function (err, response, body) { + assert.equal(response.statusCode, 403); + assert.equal(body, '[[error:invalid-login-credentials]]'); + done(); + }); + }); + }); + after(function (done) { db.emptydb(done);