From fd47e230573dee60ecc6bce43acc4fbb4a32ce3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 19 May 2017 16:18:18 -0400 Subject: [PATCH] test login for non-existant user --- test/authentication.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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);