Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

63 wiersze
2.2 KiB

  1. import test from 'ava';
  2. import lesspass from '../index';
  3. test('should derive encrypted login with default length', t => {
  4. const encryptedLogin = '9f505f3a95fe0485da3242cb81c9fe25c2f400d8399737655a8dad2b52778d88';
  5. const site = 'lesspass.com';
  6. t.is(12, lesspass._deriveEncryptedLogin(encryptedLogin, site).length);
  7. });
  8. test('should derive encrypted login with default options', t => {
  9. const encryptedLogin = '90cff82b8847525370a8f29a59ecf45db62c719a535788ad0df58d32304e925d';
  10. const site = 'lesspass.com';
  11. const option = {
  12. counter: 1,
  13. length: 12,
  14. lowercase: true,
  15. uppercase: true,
  16. numbers: true,
  17. symbols: true,
  18. };
  19. t.is(
  20. lesspass._deriveEncryptedLogin(encryptedLogin, site),
  21. lesspass._deriveEncryptedLogin(encryptedLogin, site, option)
  22. );
  23. });
  24. test('should derive encrypted login with defined length', t => {
  25. const encryptedLogin = 'd79d8482f708122288af7b259393a58fe05840f4555cc935cdd3f062b9aa75ed';
  26. const site = 'lesspass.com';
  27. const option = {
  28. counter: 1,
  29. length: 10,
  30. };
  31. t.is(10, lesspass._deriveEncryptedLogin(encryptedLogin, site, option).length);
  32. });
  33. test('should return two different passwords if site different', t => {
  34. const encryptedLogin = 'f4fd3885fb70085f2285c3382e2d9adb4c2553285fc45dd896791aa5e79070a9';
  35. const site = 'google.com';
  36. const site2 = 'facebook.com';
  37. t.not(
  38. lesspass._deriveEncryptedLogin(encryptedLogin, site),
  39. lesspass._deriveEncryptedLogin(encryptedLogin, site2)
  40. );
  41. });
  42. test('should return two different passwords if counter different', t => {
  43. const encryptedLogin = 'dfba06278c9aa24d992bc2d390a53efef482788859455875f72015335d085fcd';
  44. const site = 'lesspass.com';
  45. const option = {counter: 1};
  46. const option2 = {counter: 2};
  47. t.not(
  48. lesspass._deriveEncryptedLogin(encryptedLogin, site, option),
  49. lesspass._deriveEncryptedLogin(encryptedLogin, site, option2)
  50. );
  51. });
  52. test('should derive encrypted login with sha 256', t => {
  53. const encryptedLogin = '9f505f3a95fe0485da3242cb81c9fe25c2f400d8399737655a8dad2b52778d88';
  54. const site = 'lesspass.com';
  55. t.is('be00f942fc8a', lesspass._deriveEncryptedLogin(encryptedLogin, site));
  56. });