You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

293 lines
12 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 () {
  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. })
  123. });
  124. it('auto generated render password tests', function () {
  125. var promises = [];
  126. var passwords = [
  127. {
  128. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  129. site: 'lesspass.com',
  130. counter: 1,
  131. length: 12,
  132. lowercase: true,
  133. uppercase: true,
  134. numbers: true,
  135. symbols: true,
  136. generatedPassword: 'azYS7,olOL2]'
  137. },
  138. {
  139. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  140. site: 'lesspass.com',
  141. counter: 1,
  142. length: 14,
  143. lowercase: true,
  144. uppercase: true,
  145. numbers: true,
  146. symbols: true,
  147. generatedPassword: 'azYS7,olOL2]iz'
  148. },
  149. {
  150. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  151. site: 'lesspass.com',
  152. counter: 1,
  153. length: 12,
  154. lowercase: true,
  155. uppercase: false,
  156. numbers: false,
  157. symbols: false,
  158. generatedPassword: 'azyseqololat'
  159. },
  160. {
  161. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  162. site: 'lesspass.com',
  163. counter: 1,
  164. length: 12,
  165. lowercase: false,
  166. uppercase: true,
  167. numbers: true,
  168. symbols: true,
  169. generatedPassword: 'AZ3[EQ7@OL2]'
  170. },
  171. {
  172. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  173. site: 'lesspass.com',
  174. counter: 1,
  175. length: 12,
  176. lowercase: false,
  177. uppercase: false,
  178. numbers: true,
  179. symbols: true,
  180. generatedPassword: '4?3[7,7@7@2]'
  181. },
  182. {
  183. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  184. site: 'lesspass.com',
  185. counter: 1,
  186. length: 12,
  187. lowercase: false,
  188. uppercase: false,
  189. numbers: false,
  190. symbols: true,
  191. generatedPassword: '[?=[&,:@:@[]'
  192. },
  193. {
  194. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  195. site: 'lesspass.com',
  196. counter: 1,
  197. length: 12,
  198. lowercase: true,
  199. uppercase: true,
  200. numbers: true,
  201. symbols: false,
  202. generatedPassword: 'azYS7uwAW8at'
  203. },
  204. {
  205. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  206. site: 'lesspass.com',
  207. counter: 1,
  208. length: 12,
  209. lowercase: true,
  210. uppercase: true,
  211. numbers: false,
  212. symbols: false,
  213. generatedPassword: 'azYSeqOLolAT'
  214. },
  215. {
  216. encryptedLogin: '63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0',
  217. site: 'lesspass.com',
  218. counter: 2,
  219. length: 12,
  220. lowercase: true,
  221. uppercase: true,
  222. numbers: true,
  223. symbols: true,
  224. generatedPassword: 'obYT2=olOV9='
  225. },
  226. {
  227. encryptedLogin: '7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116',
  228. site: 'lesspass.com',
  229. counter: 1,
  230. length: 12,
  231. lowercase: true,
  232. uppercase: true,
  233. numbers: true,
  234. symbols: true,
  235. generatedPassword: 'erOC1%imIW3,'
  236. },
  237. {
  238. encryptedLogin: 'ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4',
  239. site: 'lesspass.com',
  240. counter: 1,
  241. length: 12,
  242. lowercase: true,
  243. uppercase: true,
  244. numbers: true,
  245. symbols: true,
  246. generatedPassword: 'uvUM5_ucUP5='
  247. }
  248. ];
  249. for (var entry of passwords) {
  250. var passwordOption = {
  251. counter: entry.counter,
  252. length: entry.length,
  253. lowercase: entry.lowercase,
  254. uppercase: entry.uppercase,
  255. numbers: entry.numbers,
  256. symbols: entry.symbols,
  257. };
  258. promises.push(LessPass.renderPassword(entry.encryptedLogin, entry.site, passwordOption));
  259. }
  260. return Promise.all(promises).then(values => {
  261. for (let i = 0; i < values.length; i++) {
  262. assert.equal(passwords[i].generatedPassword, values[i]);
  263. }
  264. });
  265. });
  266. });
  267. });
  268. describe('LessPass', function () {
  269. describe('fingerprint', function () {
  270. it('createFingerprint', function (done) {
  271. LessPass.createFingerprint('password').then(function (fingerprint) {
  272. assert.equal('e56a207acd1e6714735487c199c6f095844b7cc8e5971d86c003a7b6f36ef51e', fingerprint);
  273. done();
  274. })
  275. });
  276. });
  277. });