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.
 
 
 
 
 
 

243 lignes
8.0 KiB

  1. import test from 'ava';
  2. import lesspass from '../index';
  3. test('encrypt login with pbkdf2 8192 iterations and sha256', t => {
  4. return lesspass.encryptLogin('test@example.org', 'password').then(encryptedLogin => {
  5. t.is('d8af5f918db6b65b1db3d3984e5a400e39e1dbb19462220e4431de283809f472', encryptedLogin);
  6. })
  7. });
  8. test('encrypt login with utf8 parameter', t => {
  9. return lesspass.encryptLogin('test@example.org', '♥ LessPass ♥').then(encryptedLogin => {
  10. t.is('063092c809334979f505df88ed37845d298c01f7e8a03cbd661edbc084c650ca', encryptedLogin);
  11. })
  12. });
  13. test('render password', t => {
  14. const site = 'lesspass.com';
  15. const encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
  16. const passwordOptions = {
  17. counter: 1,
  18. length: 12,
  19. lowercase: true,
  20. uppercase: true,
  21. numbers: true,
  22. symbols: true
  23. };
  24. t.is('azYS7,olOL2]', lesspass.renderPassword(encryptedLogin, site, passwordOptions));
  25. });
  26. test('auto generated encrypt login tests', t => {
  27. const promises = [];
  28. const passwords = [
  29. {
  30. login: 'contact@lesspass.com',
  31. masterPassword: 'password',
  32. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  33. },
  34. {
  35. login: 'contact@lesspass.com',
  36. masterPassword: 'password',
  37. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  38. },
  39. {
  40. login: 'contact@lesspass.com',
  41. masterPassword: 'password',
  42. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  43. },
  44. {
  45. login: 'contact@lesspass.com',
  46. masterPassword: 'password',
  47. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  48. },
  49. {
  50. login: 'contact@lesspass.com',
  51. masterPassword: 'password',
  52. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  53. },
  54. {
  55. login: 'contact@lesspass.com',
  56. masterPassword: 'password',
  57. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  58. },
  59. {
  60. login: 'contact@lesspass.com',
  61. masterPassword: 'password',
  62. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  63. },
  64. {
  65. login: 'contact@lesspass.com',
  66. masterPassword: 'password',
  67. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  68. },
  69. {
  70. login: 'contact@lesspass.com',
  71. masterPassword: 'password',
  72. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  73. },
  74. {
  75. login: 'lesspass',
  76. masterPassword: 'password',
  77. encryptedLogin: '7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116',
  78. },
  79. {
  80. login: 'contact@lesspass.com',
  81. masterPassword: 'password2',
  82. encryptedLogin: 'ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4',
  83. }
  84. ];
  85. for (const entry of passwords) {
  86. promises.push(lesspass.encryptLogin(entry.login, entry.masterPassword));
  87. }
  88. t.plan(passwords.length);
  89. return Promise.all(promises).then(values => {
  90. for (let i = 0; i < values.length; i++) {
  91. t.is(passwords[i].encryptedLogin, values[i]);
  92. }
  93. });
  94. });
  95. test('auto generated derive encrypted login tests', t => {
  96. const passwords = [
  97. {
  98. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  99. site: 'lesspass.com',
  100. counter: 1,
  101. length: 12,
  102. lowercase: true,
  103. uppercase: true,
  104. numbers: true,
  105. symbols: true,
  106. generatedPassword: 'azYS7,olOL2]'
  107. },
  108. {
  109. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  110. site: 'lesspass.com',
  111. counter: 1,
  112. length: 14,
  113. lowercase: true,
  114. uppercase: true,
  115. numbers: true,
  116. symbols: true,
  117. generatedPassword: 'azYS7,olOL2]iz'
  118. },
  119. {
  120. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  121. site: 'lesspass.com',
  122. counter: 1,
  123. length: 12,
  124. lowercase: true,
  125. uppercase: false,
  126. numbers: false,
  127. symbols: false,
  128. generatedPassword: 'azyseqololat'
  129. },
  130. {
  131. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  132. site: 'lesspass.com',
  133. counter: 1,
  134. length: 12,
  135. lowercase: false,
  136. uppercase: true,
  137. numbers: true,
  138. symbols: true,
  139. generatedPassword: 'AZ3[EQ7@OL2]'
  140. },
  141. {
  142. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  143. site: 'lesspass.com',
  144. counter: 1,
  145. length: 12,
  146. lowercase: false,
  147. uppercase: false,
  148. numbers: true,
  149. symbols: true,
  150. generatedPassword: '4?3[7,7@7@2]'
  151. },
  152. {
  153. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  154. site: 'lesspass.com',
  155. counter: 1,
  156. length: 12,
  157. lowercase: false,
  158. uppercase: false,
  159. numbers: false,
  160. symbols: true,
  161. generatedPassword: '[?=[&,:@:@[]'
  162. },
  163. {
  164. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  165. site: 'lesspass.com',
  166. counter: 1,
  167. length: 12,
  168. lowercase: true,
  169. uppercase: true,
  170. numbers: true,
  171. symbols: false,
  172. generatedPassword: 'azYS7uwAW8at'
  173. },
  174. {
  175. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  176. site: 'lesspass.com',
  177. counter: 1,
  178. length: 12,
  179. lowercase: true,
  180. uppercase: true,
  181. numbers: false,
  182. symbols: false,
  183. generatedPassword: 'azYSeqOLolAT'
  184. },
  185. {
  186. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  187. site: 'lesspass.com',
  188. counter: 2,
  189. length: 12,
  190. lowercase: true,
  191. uppercase: true,
  192. numbers: true,
  193. symbols: true,
  194. generatedPassword: 'obYT2=olOV9='
  195. },
  196. {
  197. encryptedLogin: '7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116',
  198. site: 'lesspass.com',
  199. counter: 1,
  200. length: 12,
  201. lowercase: true,
  202. uppercase: true,
  203. numbers: true,
  204. symbols: true,
  205. generatedPassword: 'erOC1%imIW3,'
  206. },
  207. {
  208. encryptedLogin: 'ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4',
  209. site: 'lesspass.com',
  210. counter: 1,
  211. length: 12,
  212. lowercase: true,
  213. uppercase: true,
  214. numbers: true,
  215. symbols: true,
  216. generatedPassword: 'uvUM5_ucUP5='
  217. }
  218. ];
  219. t.plan(passwords.length);
  220. for (let i = 0; i < passwords.length; i++) {
  221. let password = passwords[i];
  222. let passwordOption = {
  223. counter: password.counter,
  224. length: password.length,
  225. lowercase: password.lowercase,
  226. uppercase: password.uppercase,
  227. numbers: password.numbers,
  228. symbols: password.symbols,
  229. };
  230. t.is(password.generatedPassword, lesspass.renderPassword(password.encryptedLogin, password.site, passwordOption));
  231. }
  232. });