Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

73 рядки
3.4 KiB

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