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
6.3 KiB

  1. import test from "ava";
  2. import execa from "execa";
  3. test("default options", async t => {
  4. const { stdout } = await execa("./cli.js", [
  5. "lesspass.com",
  6. "contact@lesspass.com",
  7. "password"
  8. ]);
  9. t.is(stdout, "\\g-A1-.OHEwrXjT#");
  10. });
  11. test("no login", async t => {
  12. return execa.shell('echo password | ./cli.js "lesspass.com"').then(result => {
  13. t.is(result.stdout, "master password: 7Cw-APO5Co?G>W>u");
  14. });
  15. });
  16. test("options can be before parameters", async t => {
  17. const { stdout } = await execa("./cli.js", [
  18. "-C",
  19. "lesspass.com",
  20. "contact@lesspass.com",
  21. "password"
  22. ]);
  23. t.is(stdout, "Copied to clipboard");
  24. });
  25. test("long options can be before parameters", async t => {
  26. const { stdout } = await execa("./cli.js", [
  27. "--clipboard",
  28. "lesspass.com",
  29. "contact@lesspass.com",
  30. "password"
  31. ]);
  32. t.is(stdout, "Copied to clipboard");
  33. });
  34. test("length", async t => {
  35. const { stdout } = await execa("./cli.js", [
  36. "lesspass.com",
  37. "contact@lesspass.com",
  38. "password",
  39. "--length=14"
  40. ]);
  41. t.is(stdout, "=0\\A-.OHEKvwrX");
  42. });
  43. test("length shortcut", async t => {
  44. const { stdout } = await execa("./cli.js", [
  45. "lesspass.com",
  46. "contact@lesspass.com",
  47. "password",
  48. "-L=14"
  49. ]);
  50. t.is(stdout, "=0\\A-.OHEKvwrX");
  51. });
  52. test("counter", async t => {
  53. const { stdout } = await execa("./cli.js", [
  54. "lesspass.com",
  55. "contact@lesspass.com",
  56. "password",
  57. "--counter=2"
  58. ]);
  59. t.is(stdout, "Vf:F1'!I`8Y2`GBE");
  60. });
  61. test("counter shortcut", async t => {
  62. const { stdout } = await execa("./cli.js", [
  63. "lesspass.com",
  64. "contact@lesspass.com",
  65. "password",
  66. "-c=2"
  67. ]);
  68. t.is(stdout, "Vf:F1'!I`8Y2`GBE");
  69. });
  70. test("no lowercase", async t => {
  71. const { stdout } = await execa("./cli.js", [
  72. "lesspass.com",
  73. "contact@lesspass.com",
  74. "password",
  75. "--no-lowercase"
  76. ]);
  77. t.is(stdout, 'JBG\\`3{+0["(E\\JJ');
  78. });
  79. test("no lowercase shortcut", async t => {
  80. const { stdout } = await execa("./cli.js", [
  81. "lesspass.com",
  82. "contact@lesspass.com",
  83. "password",
  84. "-uds"
  85. ]);
  86. t.is(stdout, 'JBG\\`3{+0["(E\\JJ');
  87. });
  88. test("only lowercase", async t => {
  89. const { stdout } = await execa("./cli.js", [
  90. "lesspass.com",
  91. "contact@lesspass.com",
  92. "password",
  93. "-l"
  94. ]);
  95. t.is(stdout, "fmnujoqgcxmpffyh");
  96. });
  97. test("no uppercase", async t => {
  98. const { stdout } = await execa("./cli.js", [
  99. "lesspass.com",
  100. "contact@lesspass.com",
  101. "password",
  102. "--no-uppercase"
  103. ]);
  104. t.is(stdout, 'jbg\\`3{+0["(e\\jj');
  105. });
  106. test("no uppercase shortcut", async t => {
  107. const { stdout } = await execa("./cli.js", [
  108. "lesspass.com",
  109. "contact@lesspass.com",
  110. "password",
  111. "-lds"
  112. ]);
  113. t.is(stdout, 'jbg\\`3{+0["(e\\jj');
  114. });
  115. test("only uppercase", async t => {
  116. const { stdout } = await execa("./cli.js", [
  117. "lesspass.com",
  118. "contact@lesspass.com",
  119. "password",
  120. "-u"
  121. ]);
  122. t.is(stdout, "FMNUJOQGCXMPFFYH");
  123. });
  124. test("no digits", async t => {
  125. const { stdout } = await execa("./cli.js", [
  126. "lesspass.com",
  127. "contact@lesspass.com",
  128. "password",
  129. "--no-digits"
  130. ]);
  131. t.is(stdout, ";zkB#m]mNF$;J_Ej");
  132. });
  133. test("no digits shortcut", async t => {
  134. const { stdout } = await execa("./cli.js", [
  135. "lesspass.com",
  136. "contact@lesspass.com",
  137. "password",
  138. "-lus"
  139. ]);
  140. t.is(stdout, ";zkB#m]mNF$;J_Ej");
  141. });
  142. test("only digits", async t => {
  143. const { stdout } = await execa("./cli.js", [
  144. "lesspass.com",
  145. "contact@lesspass.com",
  146. "password",
  147. "-d"
  148. ]);
  149. t.is(stdout, "7587019305478072");
  150. });
  151. test("no symbols", async t => {
  152. const { stdout } = await execa("./cli.js", [
  153. "lesspass.com",
  154. "contact@lesspass.com",
  155. "password",
  156. "--no-symbols"
  157. ]);
  158. t.is(stdout, "OlfK63bmUhqrGODR");
  159. });
  160. test("no symbols shortcut", async t => {
  161. const { stdout } = await execa("./cli.js", [
  162. "lesspass.com",
  163. "contact@lesspass.com",
  164. "password",
  165. "-lud"
  166. ]);
  167. t.is(stdout, "OlfK63bmUhqrGODR");
  168. });
  169. test("only symbols", async t => {
  170. const { stdout } = await execa("./cli.js", [
  171. "lesspass.com",
  172. "contact@lesspass.com",
  173. "password",
  174. "-s"
  175. ]);
  176. t.is(stdout, "<\"]|'`%};'`>-'[,");
  177. });
  178. test("test space in password", async t => {
  179. const { stdout } = await execa("./cli.js", [
  180. "lesspass.com",
  181. "contact@lesspass.com",
  182. "my Master Password"
  183. ]);
  184. t.is(stdout, "D1PBB34\\#fh!LY={");
  185. });
  186. test("doc 1", async t => {
  187. const { stdout } = await execa("./cli.js", [
  188. "lesspass.com",
  189. "contact@lesspass.com",
  190. "password",
  191. "--no-symbols"
  192. ]);
  193. t.is(stdout, "OlfK63bmUhqrGODR");
  194. });
  195. test("doc 1 options before", async t => {
  196. const { stdout } = await execa("./cli.js", [
  197. "--no-symbols",
  198. "lesspass.com",
  199. "contact@lesspass.com",
  200. "password"
  201. ]);
  202. t.is(stdout, "OlfK63bmUhqrGODR");
  203. });
  204. test("doc 2", async t => {
  205. const { stdout } = await execa("./cli.js", [
  206. "lesspass.com",
  207. "contact@lesspass.com",
  208. "password",
  209. "-lud"
  210. ]);
  211. t.is(stdout, "OlfK63bmUhqrGODR");
  212. });
  213. test("doc 2 options before", async t => {
  214. const { stdout } = await execa("./cli.js", [
  215. "-lud",
  216. "lesspass.com",
  217. "contact@lesspass.com",
  218. "password"
  219. ]);
  220. t.is(stdout, "OlfK63bmUhqrGODR");
  221. });
  222. test("doc 3", async t => {
  223. const { stdout } = await execa("./cli.js", [
  224. "lesspass.com",
  225. "contact@lesspass.com",
  226. "password",
  227. "-d",
  228. "-L8"
  229. ]);
  230. t.is(stdout, "75837019");
  231. });
  232. test("doc 3 options before", async t => {
  233. const { stdout } = await execa("./cli.js", [
  234. "-d",
  235. "-L8",
  236. "lesspass.com",
  237. "contact@lesspass.com",
  238. "password"
  239. ]);
  240. t.is(stdout, "75837019");
  241. });
  242. test("doc 3 options before and after", async t => {
  243. const { stdout } = await execa("./cli.js", [
  244. "-d",
  245. "lesspass.com",
  246. "contact@lesspass.com",
  247. "password",
  248. "-L8"
  249. ]);
  250. t.is(stdout, "75837019");
  251. });
  252. test("nrt numbers should be considered as string not integers", async t => {
  253. const p = execa("./cli.js", ["example.org", "123", "password"]);
  254. const p2 = execa("./cli.js", ["example.org", "0123", "password"]);
  255. const p3 = execa("./cli.js", ["example.org", '"0123"', "password"]);
  256. const p4 = execa("./cli.js", ["example.org", "00123", "password"]);
  257. return Promise.all([p, p2, p3, p4]).then(v => {
  258. t.is(v[0].stdout, "sMb8}N&`J4wkF9q~");
  259. t.is(v[1].stdout, "5,4SqhB2[=/h\\DZh");
  260. t.is(v[2].stdout, "u0Fz)EOJ4i\\{{;a~");
  261. t.is(v[3].stdout, '=}|O7hN0ZHdjQ{">');
  262. });
  263. });