Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

346 строки
14 KiB

  1. var assert = chai.assert;
  2. describe('LessPass', function () {
  3. describe('encryptLogin', function () {
  4. it('should use pbkdf2 with 8192 iterations and sha256', function (done) {
  5. LessPass.encryptLogin('test@example.org', 'password').then(function (encryptedLogin) {
  6. assert.equal('d8af5f918db6b65b1db3d3984e5a400e39e1dbb19462220e4431de283809f472', encryptedLogin);
  7. done();
  8. });
  9. });
  10. it('should allow to customize number of iterations', function (done) {
  11. LessPass.encryptLogin('test@example.org', 'password', {iterations: 4096}).then(function (encryptedLogin) {
  12. assert.equal('0a91208545e3aa4935d3a22984ca097a7669259a04d261ac16361bdc1a2e960f', encryptedLogin);
  13. done();
  14. });
  15. });
  16. it('should allow to customize key length', function (done) {
  17. LessPass.encryptLogin('test@example.org', 'password', {keylen: 16}).then(function (encryptedLogin) {
  18. assert.equal('d8af5f918db6b65b1db3d3984e5a400e', encryptedLogin);
  19. done();
  20. });
  21. });
  22. it('should allow to customize iterations and key length', function (done) {
  23. LessPass.encryptLogin('test@example.org', 'password', {
  24. iterations: 4096,
  25. keylen: 16
  26. }).then(function (encryptedLogin) {
  27. assert.equal('0a91208545e3aa4935d3a22984ca097a', encryptedLogin);
  28. done();
  29. });
  30. });
  31. it('should allow utf8 parameter', function (done) {
  32. LessPass.encryptLogin('test@example.org', '♥ LessPass ♥').then(function (encryptedLogin) {
  33. assert.equal('997fe81d3d0db236e039c75efdb487f17a902fdf94f9dacaa9884329c85d9651', encryptedLogin);
  34. done();
  35. });
  36. });
  37. it('auto generated encrypt login tests', function () {
  38. var promises = [];
  39. var passwords = [
  40. {
  41. login: 'contact@lesspass.com',
  42. masterPassword: 'password',
  43. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  44. },
  45. {
  46. login: 'contact@lesspass.com',
  47. masterPassword: 'password',
  48. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  49. },
  50. {
  51. login: 'contact@lesspass.com',
  52. masterPassword: 'password',
  53. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  54. },
  55. {
  56. login: 'contact@lesspass.com',
  57. masterPassword: 'password',
  58. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  59. },
  60. {
  61. login: 'contact@lesspass.com',
  62. masterPassword: 'password',
  63. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  64. },
  65. {
  66. login: 'contact@lesspass.com',
  67. masterPassword: 'password',
  68. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  69. },
  70. {
  71. login: 'contact@lesspass.com',
  72. masterPassword: 'password',
  73. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  74. },
  75. {
  76. login: 'contact@lesspass.com',
  77. masterPassword: 'password',
  78. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  79. },
  80. {
  81. login: 'contact@lesspass.com',
  82. masterPassword: 'password',
  83. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  84. },
  85. {
  86. login: 'lesspass',
  87. masterPassword: 'password',
  88. encryptedLogin: '7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116',
  89. },
  90. {
  91. login: 'contact@lesspass.com',
  92. masterPassword: 'password2',
  93. encryptedLogin: 'ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4',
  94. }
  95. ];
  96. for (var entry of passwords) {
  97. promises.push(LessPass.encryptLogin(entry.login, entry.masterPassword));
  98. }
  99. return Promise.all(promises).then(values => {
  100. for (let i = 0; i < values.length; i++) {
  101. assert.equal(passwords[i].encryptedLogin, values[i]);
  102. }
  103. });
  104. });
  105. });
  106. });
  107. describe('LessPass', function () {
  108. describe('renderPassword', function () {
  109. it('render password', function (done) {
  110. var site = 'lesspass.com';
  111. var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
  112. var passwordOptions = {
  113. counter: 1,
  114. length: 12,
  115. lowercase: true,
  116. uppercase: true,
  117. numbers: true,
  118. symbols: true
  119. };
  120. LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
  121. assert.equal('azYS7,olOL2]', generatedPassword);
  122. done();
  123. })
  124. });
  125. it('render password with a custom template', function () {
  126. var site = 'lesspass.com';
  127. var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
  128. var passwordOptions = {
  129. counter: 1,
  130. length: 12,
  131. lowercase: true,
  132. uppercase: true,
  133. numbers: true,
  134. symbols: true,
  135. template: 'n'
  136. };
  137. return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
  138. var i = generatedPassword.length;
  139. while (i--) {
  140. assert('0123456789'.indexOf(generatedPassword[i]) !== -1)
  141. }
  142. })
  143. });
  144. it('render password with a custom template too short', function () {
  145. var site = 'lesspass.com';
  146. var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
  147. var passwordOptions = {
  148. counter: 1,
  149. length: 12,
  150. lowercase: true,
  151. uppercase: true,
  152. numbers: true,
  153. symbols: true,
  154. template: 'CvcnCVsn'
  155. };
  156. return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
  157. assert.equal('Sor4WU:8Wad5', generatedPassword);
  158. })
  159. });
  160. it('render password with a custom template too long', function () {
  161. var site = 'lesspass.com';
  162. var encryptedLogin = '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0';
  163. var passwordOptions = {
  164. counter: 1,
  165. length: 6,
  166. lowercase: true,
  167. uppercase: true,
  168. numbers: true,
  169. symbols: true,
  170. template: 'CvcnCVsn'
  171. };
  172. return LessPass.renderPassword(encryptedLogin, site, passwordOptions).then(function (generatedPassword) {
  173. assert.equal('Sor4WU', generatedPassword);
  174. })
  175. });
  176. it('auto generated render password tests', function () {
  177. var promises = [];
  178. var passwords = [
  179. {
  180. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  181. site: 'lesspass.com',
  182. counter: 1,
  183. length: 12,
  184. lowercase: true,
  185. uppercase: true,
  186. numbers: true,
  187. symbols: true,
  188. generatedPassword: 'azYS7,olOL2]'
  189. },
  190. {
  191. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  192. site: 'lesspass.com',
  193. counter: 1,
  194. length: 14,
  195. lowercase: true,
  196. uppercase: true,
  197. numbers: true,
  198. symbols: true,
  199. generatedPassword: 'azYS7,olOL2]iz'
  200. },
  201. {
  202. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  203. site: 'lesspass.com',
  204. counter: 1,
  205. length: 12,
  206. lowercase: true,
  207. uppercase: false,
  208. numbers: false,
  209. symbols: false,
  210. generatedPassword: 'azyseqololat'
  211. },
  212. {
  213. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  214. site: 'lesspass.com',
  215. counter: 1,
  216. length: 12,
  217. lowercase: false,
  218. uppercase: true,
  219. numbers: true,
  220. symbols: true,
  221. generatedPassword: 'AZ3[EQ7@OL2]'
  222. },
  223. {
  224. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  225. site: 'lesspass.com',
  226. counter: 1,
  227. length: 12,
  228. lowercase: false,
  229. uppercase: false,
  230. numbers: true,
  231. symbols: true,
  232. generatedPassword: '4?3[7,7@7@2]'
  233. },
  234. {
  235. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  236. site: 'lesspass.com',
  237. counter: 1,
  238. length: 12,
  239. lowercase: false,
  240. uppercase: false,
  241. numbers: false,
  242. symbols: true,
  243. generatedPassword: '[?=[&,:@:@[]'
  244. },
  245. {
  246. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  247. site: 'lesspass.com',
  248. counter: 1,
  249. length: 12,
  250. lowercase: true,
  251. uppercase: true,
  252. numbers: true,
  253. symbols: false,
  254. generatedPassword: 'azYS7uwAW8at'
  255. },
  256. {
  257. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  258. site: 'lesspass.com',
  259. counter: 1,
  260. length: 12,
  261. lowercase: true,
  262. uppercase: true,
  263. numbers: false,
  264. symbols: false,
  265. generatedPassword: 'azYSeqOLolAT'
  266. },
  267. {
  268. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  269. site: 'lesspass.com',
  270. counter: 2,
  271. length: 12,
  272. lowercase: true,
  273. uppercase: true,
  274. numbers: true,
  275. symbols: true,
  276. generatedPassword: 'obYT2=olOV9='
  277. },
  278. {
  279. encryptedLogin: '7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116',
  280. site: 'lesspass.com',
  281. counter: 1,
  282. length: 12,
  283. lowercase: true,
  284. uppercase: true,
  285. numbers: true,
  286. symbols: true,
  287. generatedPassword: 'erOC1%imIW3,'
  288. },
  289. {
  290. encryptedLogin: 'ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4',
  291. site: 'lesspass.com',
  292. counter: 1,
  293. length: 12,
  294. lowercase: true,
  295. uppercase: true,
  296. numbers: true,
  297. symbols: true,
  298. generatedPassword: 'uvUM5_ucUP5='
  299. }
  300. ];
  301. for (var entry of passwords) {
  302. var passwordOption = {
  303. counter: entry.counter,
  304. length: entry.length,
  305. lowercase: entry.lowercase,
  306. uppercase: entry.uppercase,
  307. numbers: entry.numbers,
  308. symbols: entry.symbols,
  309. };
  310. promises.push(LessPass.renderPassword(entry.encryptedLogin, entry.site, passwordOption));
  311. }
  312. return Promise.all(promises).then(values => {
  313. for (let i = 0; i < values.length; i++) {
  314. assert.equal(passwords[i].generatedPassword, values[i]);
  315. }
  316. });
  317. });
  318. });
  319. });
  320. describe('LessPass', function () {
  321. describe('fingerprint', function () {
  322. it('createFingerprint', function () {
  323. return LessPass.createFingerprint('password').then(function (fingerprint) {
  324. assert.equal('e56a207acd1e6714735487c199c6f095844b7cc8e5971d86c003a7b6f36ef51e', fingerprint);
  325. })
  326. });
  327. });
  328. });