Skip to content

Node.js based forum software built for the modern web

test login for non-existant user

Barış Soner Uşaklıfd47e230573d
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);