You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

63 regels
2.8 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. assert.equal('W', LessPass._renderPassword(entropy)[0]);
  6. });
  7. it('render password use quotient as second entropy recursively', function () {
  8. var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
  9. assert.equal('H', LessPass._renderPassword(entropy)[1]);
  10. });
  11. it('render password has default length of 16', function () {
  12. var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
  13. assert.equal(16, LessPass._renderPassword(entropy).length);
  14. });
  15. it('render password can specify length', function () {
  16. var entropy = 'dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e';
  17. var passwordProfile = {
  18. length: 20,
  19. lowercase: true,
  20. uppercase: true,
  21. digits: true,
  22. symbols: true
  23. };
  24. assert.equal(20, LessPass._renderPassword(entropy, passwordProfile).length);
  25. });
  26. it('include one char per set of characters', function () {
  27. var password = LessPass._insertStringPseudoRandomly('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 passwordProfile = {
  33. length: 6,
  34. lowercase: true,
  35. uppercase: true,
  36. digits: true,
  37. symbols: true,
  38. };
  39. var generatedPassword = LessPass._renderPassword(entropy, passwordProfile);
  40. var passwordLength = generatedPassword.length;
  41. var lowercaseOk = false;
  42. var uppercaseOk = false;
  43. var digitsOk = false;
  44. var symbolsOk = false;
  45. while (passwordLength--) {
  46. if ('abcdefghijklmnopqrstuvwxyz'.indexOf(generatedPassword[passwordLength]) !== -1) {
  47. lowercaseOk = true;
  48. }
  49. if ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(generatedPassword[passwordLength]) !== -1) {
  50. uppercaseOk = true;
  51. }
  52. if ('0123456789'.indexOf(generatedPassword[passwordLength]) !== -1) {
  53. digitsOk = true;
  54. }
  55. if ('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'.indexOf(generatedPassword[passwordLength]) !== -1) {
  56. symbolsOk = true;
  57. }
  58. }
  59. assert.equal(6, generatedPassword.length);
  60. assert(lowercaseOk && uppercaseOk && digitsOk && symbolsOk, 'there is no at least one char in every characters set');
  61. });
  62. });