Parcourir la source

make tests pass

pull/342/head
Guillaume Vincent il y a 8 ans
Parent
révision
851b57e2e5
4 fichiers modifiés avec 24 ajouts et 11 suppressions
  1. +1
    -1
      index.js
  2. +6
    -6
      tests/v2/api.tests.js
  3. +7
    -1
      tests/v2/entropy.tests.js
  4. +10
    -3
      tests/v2/renderPassword.tests.js

+ 1
- 1
index.js Voir le fichier

@@ -17,7 +17,7 @@ module.exports = {
_calcEntropy: v2._calcEntropy,
_consumeEntropy: v2._consumeEntropy,
_getSetOfCharacters: v2._getSetOfCharacters,
_validRules: v2._validRules,
_getConfiguredRules: v2._getConfiguredRules,
_insertStringPseudoRandomly: v2._insertStringPseudoRandomly,
_getOneCharPerRule: v2._getOneCharPerRule,
_renderPassword: v2._renderPassword,

+ 6
- 6
tests/v2/api.tests.js Voir le fichier

@@ -13,7 +13,7 @@ describe('LessPass v2', function () {
digits: true,
symbols: true,
length: 16,
counter: 1,
index: 1,
version: 2
};
return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
@@ -31,11 +31,11 @@ describe('LessPass v2', function () {
digits: true,
symbols: false,
length: 14,
counter: 1,
index: 2,
version: 2
};
return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
assert.equal('y5Im77Ctww2695', generatedPassword);
assert.equal('MBAsB7b1Prt8Sl', generatedPassword);
});
});
it('render password only digit', function () {
@@ -49,11 +49,11 @@ describe('LessPass v2', function () {
digits: true,
symbols: false,
length: 6,
counter: 1,
index: 3,
version: 2
};
return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {
assert.equal('874623', generatedPassword);
assert.equal('117843', generatedPassword);
});
});
it('render password no number', function () {
@@ -67,7 +67,7 @@ describe('LessPass v2', function () {
digits: false,
symbols: true,
length: 14,
counter: 1,
index: 1,
version: 2
};
return LessPass.generatePassword(site, login, masterPassword, passwordProfile).then(function (generatedPassword) {


+ 7
- 1
tests/v2/entropy.tests.js Voir le fichier

@@ -7,7 +7,13 @@ describe('LessPass v2', function () {
var site = 'example.org';
var login = 'contact@example.org';
var masterPassword = 'password';
return LessPass._calcEntropy(site, login, masterPassword).then(function (entropy) {
var passwordProfile = {
iterations: 100000,
keylen: 32,
digest: 'sha256',
index: 1
};
return LessPass._calcEntropy(site, login, masterPassword, passwordProfile).then(function (entropy) {
assert.equal('dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e', entropy);
});
});


+ 10
- 3
tests/v2/renderPassword.tests.js Voir le fichier

@@ -1,17 +1,24 @@
var assert = chai.assert;

describe('LessPass v2', function () {
var defaultPasswordProfile = {
length: 16,
lowercase: true,
uppercase: true,
digits: true,
symbols: true
};
it('render password use remainder of long division beetween entropy and set of chars length as an index', function () {
var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
assert.equal('W', LessPass._renderPassword(entropy)[0]);
assert.equal('W', LessPass._renderPassword(entropy, defaultPasswordProfile)[0]);
});
it('render password use quotient as second entropy recursively', function () {
var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
assert.equal('H', LessPass._renderPassword(entropy)[1]);
assert.equal('H', LessPass._renderPassword(entropy, defaultPasswordProfile)[1]);
});
it('render password has default length of 16', function () {
var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
assert.equal(16, LessPass._renderPassword(entropy).length);
assert.equal(16, LessPass._renderPassword(entropy, defaultPasswordProfile).length);
});
it('render password can specify length', function () {
var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';


Chargement…
Annuler
Enregistrer