From 07d256144ea35aaa4b593461148cf3422f399fb7 Mon Sep 17 00:00:00 2001
From: Shane Tomlinson <stomlinson@mozilla.com>
Date: Wed, 8 Aug 2012 12:06:35 +0100
Subject: [PATCH] Some cleanup from the bcrypt upgrade to v0.7.1.

* Change the last bcrypt.get_rounds to bcrypt.getRounds.
* Remove the bcrypt require from tests where it is not needed.
* Remove exports.get_rounds from bcrypt.js, it has been deprecated.
---
 lib/bcrypt.js                        | 2 +-
 lib/wsapi/authenticate_user.js       | 2 +-
 tests/heartbeat-test.js              | 9 ++++-----
 tests/password-bcrypt-update-test.js | 4 ++--
 tests/password-update-test.js        | 3 +--
 tests/session-context-test.js        | 3 +--
 tests/session-duration-test.js       | 1 -
 tests/session-prolong-test.js        | 3 +--
 8 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/lib/bcrypt.js b/lib/bcrypt.js
index a2c0f231d..e78b846c7 100644
--- a/lib/bcrypt.js
+++ b/lib/bcrypt.js
@@ -46,7 +46,7 @@ exports.compare = function(pass, hash, cb) {
   })
 };
 
-exports.get_rounds = exports.getRounds = function(hash) {
+exports.getRounds = function(hash) {
   return bcrypt.getRounds(hash);
 };
 
diff --git a/lib/wsapi/authenticate_user.js b/lib/wsapi/authenticate_user.js
index 496b972b3..97ee9f325 100644
--- a/lib/wsapi/authenticate_user.js
+++ b/lib/wsapi/authenticate_user.js
@@ -104,7 +104,7 @@ exports.process = function(req, res) {
                 } else {
                   logger.info("bcrypt rounds of password for " + uid +
                               " successfully updated (from " +
-                              bcrypt.get_rounds(hash) + " to "
+                              bcrypt.getRounds(hash) + " to "
                               + config.get('bcrypt_work_factor') + ")");
                 }
               });
diff --git a/tests/heartbeat-test.js b/tests/heartbeat-test.js
index 6dd5341b4..303046d00 100755
--- a/tests/heartbeat-test.js
+++ b/tests/heartbeat-test.js
@@ -13,7 +13,6 @@ start_stop = require('./lib/start-stop.js'),
 wsapi = require('./lib/wsapi.js'),
 db = require('../lib/db.js'),
 config = require('../lib/configuration.js'),
-bcrypt = require('bcrypt'),
 http = require('http');
 
 var suite = vows.describe('heartbeat');
@@ -58,7 +57,7 @@ start_stop.addStartupBatches(suite);
 suite.addBatch({
   "stopping the browserid process": {
     topic: function() {
-      process.kill(parseInt(process.env['BROWSERID_PID'], 10), 'SIGSTOP');      
+      process.kill(parseInt(process.env['BROWSERID_PID'], 10), 'SIGSTOP');
       this.callback();
     },
     "then doing a deep __heartbeat__ on router": {
@@ -88,7 +87,7 @@ suite.addBatch({
       },
       "but upon SIGCONT": {
         topic: function(e, code) {
-          process.kill(parseInt(process.env['BROWSERID_PID'], 10), 'SIGCONT');      
+          process.kill(parseInt(process.env['BROWSERID_PID'], 10), 'SIGCONT');
           this.callback();
         },
         "a deep heartbeat": {
@@ -119,7 +118,7 @@ suite.addBatch({
 suite.addBatch({
   "stopping the static process": {
     topic: function() {
-      process.kill(parseInt(process.env['STATIC_PID'], 10), 'SIGSTOP');      
+      process.kill(parseInt(process.env['STATIC_PID'], 10), 'SIGSTOP');
       this.callback();
     },
     "then doing a deep __heartbeat__ on router": {
@@ -149,7 +148,7 @@ suite.addBatch({
       },
       "but upon SIGCONT": {
         topic: function(e, code) {
-          process.kill(parseInt(process.env['STATIC_PID'], 10), 'SIGCONT');      
+          process.kill(parseInt(process.env['STATIC_PID'], 10), 'SIGCONT');
           this.callback();
         },
         "a deep heartbeat": {
diff --git a/tests/password-bcrypt-update-test.js b/tests/password-bcrypt-update-test.js
index 033e9109f..49a8e6084 100755
--- a/tests/password-bcrypt-update-test.js
+++ b/tests/password-bcrypt-update-test.js
@@ -94,7 +94,7 @@ suite.addBatch({
     "is bcrypted with the expected number of rounds": function(err, r) {
       assert.isNull(err);
       assert.equal(typeof r, 'string');
-      assert.equal(config.get('bcrypt_work_factor'), bcrypt.get_rounds(r));
+      assert.equal(config.get('bcrypt_work_factor'), bcrypt.getRounds(r));
     }
   }
 });
@@ -143,7 +143,7 @@ suite.addBatch({
       "its bcrypted with 8 rounds": function(err, r) {
         assert.isNull(err);
         assert.equal(typeof r, 'string');
-        assert.equal(8, bcrypt.get_rounds(r));
+        assert.equal(8, bcrypt.getRounds(r));
       }
     }
   }
diff --git a/tests/password-update-test.js b/tests/password-update-test.js
index 98ca73842..a33ac5568 100755
--- a/tests/password-update-test.js
+++ b/tests/password-update-test.js
@@ -12,8 +12,7 @@ vows = require('vows'),
 start_stop = require('./lib/start-stop.js'),
 wsapi = require('./lib/wsapi.js'),
 db = require('../lib/db.js'),
-config = require('../lib/configuration.js'),
-bcrypt = require('bcrypt');
+config = require('../lib/configuration.js');
 
 var suite = vows.describe('password-length');
 
diff --git a/tests/session-context-test.js b/tests/session-context-test.js
index 6c2fe805a..9fbdc8bdd 100755
--- a/tests/session-context-test.js
+++ b/tests/session-context-test.js
@@ -12,8 +12,7 @@ vows = require('vows'),
 start_stop = require('./lib/start-stop.js'),
 wsapi = require('./lib/wsapi.js'),
 db = require('../lib/db.js'),
-config = require('../lib/configuration.js'),
-bcrypt = require('bcrypt');
+config = require('../lib/configuration.js');
 
 var suite = vows.describe('session-context');
 
diff --git a/tests/session-duration-test.js b/tests/session-duration-test.js
index a28c7f20f..f40a2f7b0 100755
--- a/tests/session-duration-test.js
+++ b/tests/session-duration-test.js
@@ -14,7 +14,6 @@ start_stop = require('./lib/start-stop.js'),
 wsapi = require('./lib/wsapi.js'),
 db = require('../lib/db.js'),
 config = require('../lib/configuration.js'),
-bcrypt = require('bcrypt'),
 primary = require('./lib/primary.js'),
 ca = require('../lib/keysigner/ca.js'),
 jwcrypto = require('jwcrypto');
diff --git a/tests/session-prolong-test.js b/tests/session-prolong-test.js
index 2df5cc4d2..b4348502c 100755
--- a/tests/session-prolong-test.js
+++ b/tests/session-prolong-test.js
@@ -12,8 +12,7 @@ vows = require('vows'),
 start_stop = require('./lib/start-stop.js'),
 wsapi = require('./lib/wsapi.js'),
 db = require('../lib/db.js'),
-config = require('../lib/configuration.js'),
-bcrypt = require('bcrypt');
+config = require('../lib/configuration.js');
 
 var suite = vows.describe('session-prolong');
 
-- 
GitLab