No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

71 líneas
3.4 KiB

  1. var assert = chai.assert;
  2. describe('LessPass', function () {
  3. describe('deriveEncryptedLogin', function () {
  4. it('should createHmac', function () {
  5. var encryptedLogin = '9f505f3a95fe0485da3242cb81c9fe25c2f400d8399737655a8dad2b52778d88';
  6. var salt = 'lesspass.com1';
  7. return LessPass._createHmac(encryptedLogin, salt).then(function (hmac) {
  8. assert.equal('be00f942fc8aa67d8e76fc2456862b9d66d166ebfdd3dc2f0116e278209532ed', hmac);
  9. });
  10. });
  11. it('should derive encrypted login with default options', function () {
  12. const encryptedLogin = '90cff82b8847525370a8f29a59ecf45db62c719a535788ad0df58d32304e925d';
  13. const site = 'lesspass.com';
  14. const option = {
  15. counter: 1,
  16. length: 12,
  17. lowercase: true,
  18. uppercase: true,
  19. numbers: true,
  20. symbols: true,
  21. };
  22. var p1 = LessPass._deriveEncryptedLogin(encryptedLogin, site);
  23. var p2 = LessPass._deriveEncryptedLogin(encryptedLogin, site, option);
  24. Promise.all([p1, p2]).then(function (generatedPasswords) {
  25. assert.equal(generatedPasswords[0], generatedPasswords[1])
  26. });
  27. });
  28. it('should derive encrypted login with defined length', function () {
  29. var encryptedLogin = 'd79d8482f708122288af7b259393a58fe05840f4555cc935cdd3f062b9aa75ed';
  30. var site = 'lesspass.com';
  31. var option = {
  32. counter: 1,
  33. length: 10,
  34. };
  35. return LessPass._deriveEncryptedLogin(encryptedLogin, site, option).then(function (generatedPassword) {
  36. assert.equal(10, generatedPassword.length);
  37. });
  38. });
  39. it('should return two different passwords if site different', function () {
  40. const encryptedLogin = 'f4fd3885fb70085f2285c3382e2d9adb4c2553285fc45dd896791aa5e79070a9';
  41. const site = 'google.com';
  42. const site2 = 'facebook.com';
  43. var p1 = LessPass._deriveEncryptedLogin(encryptedLogin, site);
  44. var p2 = LessPass._deriveEncryptedLogin(encryptedLogin, site2);
  45. return Promise.all([p1, p2]).then(function (derivedEncryptedLogins) {
  46. assert.notEqual(derivedEncryptedLogins[0], derivedEncryptedLogins[1])
  47. });
  48. });
  49. it('should return two different passwords if counter different', function () {
  50. const encryptedLogin = 'dfba06278c9aa24d992bc2d390a53efef482788859455875f72015335d085fcd';
  51. const site = 'lesspass.com';
  52. const option = {counter: 1};
  53. const option2 = {counter: 2};
  54. var p1 = LessPass._deriveEncryptedLogin(encryptedLogin, site, option);
  55. var p2 = LessPass._deriveEncryptedLogin(encryptedLogin, site, option2);
  56. return Promise.all([p1, p2]).then(function (derivedEncryptedLogins) {
  57. assert.notEqual(derivedEncryptedLogins[0], derivedEncryptedLogins[1])
  58. });
  59. });
  60. it('should derive encrypted login with sha 256', function () {
  61. const encryptedLogin = '9f505f3a95fe0485da3242cb81c9fe25c2f400d8399737655a8dad2b52778d88';
  62. const site = 'lesspass.com';
  63. LessPass._deriveEncryptedLogin(encryptedLogin, site).then(function (encryptedLogin) {
  64. assert.equal('be00f942fc8a', encryptedLogin);
  65. });
  66. });
  67. });
  68. });