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.
 
 
 
 
 
 

252 lignes
8.3 KiB

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