Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

64 lignes
3.3 KiB

  1. var assert = chai.assert;
  2. describe('LessPass v2', function () {
  3. it('render password use remainder of long division beetween entropy and set of chars length as an index ', function () {
  4. var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
  5. var setOfCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  6. assert.equal('y', LessPass._renderPassword(entropy, setOfCharacters)[0]);
  7. });
  8. it('render password use quotient as second entropy recursively', function () {
  9. var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
  10. var setOfCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  11. assert.equal('5', LessPass._renderPassword(entropy, setOfCharacters)[1]);
  12. });
  13. it('render password has default length of 14', function () {
  14. var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
  15. var setOfCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  16. assert.equal(14, LessPass._renderPassword(entropy, setOfCharacters).length);
  17. });
  18. it('render password can specify length', function () {
  19. var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
  20. var setOfCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  21. var passwordProfile = {
  22. length: 20
  23. };
  24. assert.equal(20, LessPass._renderPassword(entropy, setOfCharacters, passwordProfile).length);
  25. });
  26. it('include one char per set of characters', function () {
  27. var password = LessPass._includeOneCharPerSetOfCharacters('123456', bigInt(7 * 6 + 2), 'uT');
  28. assert.equal('T12u3456', password);
  29. });
  30. it('render password return at least one char in every characters set', function () {
  31. var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
  32. var setOfCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
  33. var passwordProfile = {
  34. length: 6,
  35. lowercase: true,
  36. uppercase: true,
  37. digits: true,
  38. symbols: true,
  39. };
  40. var generatedPassword = LessPass._renderPassword(entropy, setOfCharacters, passwordProfile);
  41. var passwordLength = generatedPassword.length;
  42. var lowercaseOk = false;
  43. var uppercaseOk = false;
  44. var digitsOk = false;
  45. var symbolsOk = false;
  46. while (passwordLength--) {
  47. if ('abcdefghijklmnopqrstuvwxyz'.indexOf(generatedPassword[passwordLength]) !== -1) {
  48. lowercaseOk = true;
  49. }
  50. if ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(generatedPassword[passwordLength]) !== -1) {
  51. uppercaseOk = true;
  52. }
  53. if ('0123456789'.indexOf(generatedPassword[passwordLength]) !== -1) {
  54. digitsOk = true;
  55. }
  56. if ('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'.indexOf(generatedPassword[passwordLength]) !== -1) {
  57. symbolsOk = true;
  58. }
  59. }
  60. assert.equal(6, generatedPassword.length);
  61. assert(lowercaseOk && uppercaseOk && digitsOk && symbolsOk, 'there is no at least one char in every characters set');
  62. });
  63. });