From c761dc5279716b7b745fd3b9b1c3a0566a30dc6e Mon Sep 17 00:00:00 2001 From: loay Date: Mon, 24 Jul 2017 01:03:14 -0400 Subject: [PATCH 1/2] Add unit test for empty password --- test/user.test.js | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/test/user.test.js b/test/user.test.js index 9e54367c..d70dc30b 100644 --- a/test/user.test.js +++ b/test/user.test.js @@ -398,16 +398,31 @@ describe('User', function() { var pass73Char = pass72Char + '3'; var passTooLong = pass72Char + 'WXYZ1234'; - it('rejects passwords longer than 72 characters', function(done) { - try { - User.create({email: 'b@c.com', password: pass73Char}, function(err) { - if (err) return done(err); - done(new Error('User.create() should have thrown an error.')); - }); - } catch (e) { - expect(e).to.match(/Password too long/); + it('rejects empty passwords creation', function(done) { + User.create({email: 'b@c.com', password: ''}, function(err) { + expect(err.code).to.equal('INVALID_PASSWORD'); + expect(err.statusCode).to.equal(422); done(); - } + }); + }); + + it('rejects updating with empty password', function(done) { + User.create({email: 'blank@c.com', password: pass72Char}, function(err, userCreated) { + if (err) return done(err); + userCreated.updateAttribute('password', '', function(err, userUpdated) { + expect(err.code).to.equal('INVALID_PASSWORD'); + expect(err.statusCode).to.equal(422); + done(); + }); + }); + }); + + it('rejects passwords longer than 72 characters', function(done) { + User.create({email: 'b@c.com', password: pass73Char}, function(err) { + expect(err.code).to.equal('PASSWORD_TOO_LONG'); + expect(err.statusCode).to.equal(422); + done(); + }); }); it('rejects a new user with password longer than 72 characters', function(done) { From a3bf81308852ddbd3d11f462a56d82dbf26495aa Mon Sep 17 00:00:00 2001 From: loay Date: Tue, 25 Jul 2017 14:38:37 -0400 Subject: [PATCH 2/2] Update Travis registry --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e103ed1a..bdd62329 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ cache: directories: - travis_phantomjs before_install: + - npm config set registry http://ci.strongloop.com:4873/ # Upgrade PhantomJS to v2.1.1. - "export PHANTOMJS_VERSION=2.1.1" - "export PATH=$PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin:$PATH"