diff --git a/tests/bcrypt-compatibility-test.js b/tests/bcrypt-compatibility-test.js new file mode 100644 index 0000000000000000000000000000000000000000..e8f9d8c3d8311493b7e78fa14ada066216d75c99 --- /dev/null +++ b/tests/bcrypt-compatibility-test.js @@ -0,0 +1,34 @@ +#!/usr/bin/env node + +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +require('./lib/test_env.js'); + +const assert = +require('assert'), +vows = require('vows'), +config = require('../lib/configuration.js'), +bcrypt = require('bcrypt'); + +var suite = vows.describe('bcrypt-compatibility'); + +suite.addBatch({ + "new bcrypt of password for given salt": { + topic: function () { + var salt = "$2a$04$rakQlaS/TyfjZmoVuRs9ku"; + bcrypt.encrypt("Thisismypassword1!", salt, this.callback); + }, + "should match old bcrypt": function (hash) { + assert.strictEqual(hash, '$2a$04$rakQlaS/TyfjZmoVuRs9kuQHFk2oShl8DNmVbxgSZyOE8Hzgk0One'); + } + }, + "get rounds of old hash should match new bcrypt": function () { + var hash = '$2a$04$rakQlaS/TyfjZmoVuRs9kuQHFk2oShl8DNmVbxgSZyOE8Hzgk0One'; + assert.strictEqual(4, bcrypt.getRounds(hash)); + } +}); + +if (process.argv[1] === __filename) suite.run(); +else suite.export(module);