user.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. process.env.NODE_ENV = 'test'
  2. process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
  3. let chai = require('chai')
  4. let server = require('../server')
  5. let should = chai.should()
  6. let expect = chai.expect
  7. let { sequelize } = require('../models')
  8. const Errors = require('../lib/errors.js')
  9. chai.use(require('chai-http'))
  10. chai.use(require('chai-things'))
  11. describe('User', () => {
  12. //Wait for app to start before commencing
  13. before((done) => {
  14. if(server.locals.appStarted) done()
  15. server.on('appStarted', () => {
  16. done()
  17. })
  18. })
  19. //Delete all rows in table after
  20. //tests completed
  21. after(() => sequelize.sync({ force: true }) )
  22. describe('/ POST user', () => {
  23. it('should create an account', (done) => {
  24. chai.request(server)
  25. .post('/api/v1/user')
  26. .set('content-type', 'application/x-www-form-urlencoded')
  27. .send({
  28. username: 'username',
  29. password: 'password'
  30. })
  31. .end((err, res) => {
  32. res.should.have.status(200)
  33. res.should.be.json
  34. res.body.should.have.property('username', 'username')
  35. res.body.should.have.property('hash')
  36. res.body.should.have.property('color')
  37. res.body.color.should.not.be.null
  38. done()
  39. })
  40. })
  41. it('should create an admin account if no is already created', (done) => {
  42. chai.request(server)
  43. .post('/api/v1/user')
  44. .set('content-type', 'application/json')
  45. .send({
  46. username: 'adminaccount',
  47. password: 'password',
  48. admin: true
  49. })
  50. .end((err, res) => {
  51. res.should.have.status(200)
  52. res.body.should.have.property('username', 'adminaccount')
  53. res.body.should.have.property('hash')
  54. res.body.should.have.property('admin', true)
  55. done()
  56. })
  57. })
  58. it('should give an error if an admin account is already created and no token is provided', (done) => {
  59. chai.request(server)
  60. .post('/api/v1/user')
  61. .set('content-type', 'application/json')
  62. .send({
  63. username: 'adminaccount1',
  64. password: 'password',
  65. admin: true
  66. })
  67. .end((err, res) => {
  68. res.should.have.status(400)
  69. res.should.be.json
  70. res.body.should.have.property('errors')
  71. res.body.errors.should.include.something.that.deep.equals(Errors.missingParameter('token'))
  72. done()
  73. })
  74. })
  75. it('should give an error if admin and token fields are not of the correct type ', (done) => {
  76. chai.request(server)
  77. .post('/api/v1/user')
  78. .set('content-type', 'application/json')
  79. .send({
  80. username: 'adminaccount1',
  81. password: 'password',
  82. admin: 'not a boolean',
  83. token: 123
  84. })
  85. .end((err, res) => {
  86. res.should.have.status(400)
  87. res.should.be.json
  88. res.body.should.have.property('errors')
  89. res.body.errors.should.include.something.that.deep.equals(Errors.invalidParameterType('admin', 'boolean'))
  90. res.body.errors.should.include.something.that.deep.equals(Errors.invalidParameterType('token', 'string'))
  91. done()
  92. })
  93. })
  94. it('should give an error if an admin account is already created and token is invalid', (done) => {
  95. chai.request(server)
  96. .post('/api/v1/user')
  97. .set('content-type', 'application/json')
  98. .send({
  99. username: 'adminaccount1',
  100. password: 'password',
  101. admin: true,
  102. token: 'invalid_token'
  103. })
  104. .end((err, res) => {
  105. res.should.have.status(401)
  106. res.should.be.json
  107. res.body.should.have.property('errors')
  108. res.body.errors.should.include.something.that.deep.equals(Errors.invalidToken)
  109. done()
  110. })
  111. })
  112. it('should create an admin account provided with a token', async () => {
  113. let agent = chai.request.agent(server)
  114. await agent
  115. .post('/api/v1/user/adminaccount/login')
  116. .set('content-type', 'application/json')
  117. .send({
  118. password: 'password'
  119. })
  120. let tokenRes = await agent.post('/api/v1/admin_token')
  121. let token = tokenRes.body.token
  122. let accountRes = await chai.request(server)
  123. .post('/api/v1/user')
  124. .set('content-type', 'application/json')
  125. .send({
  126. username: 'adminaccount1',
  127. password: 'password',
  128. admin: true,
  129. token: token
  130. })
  131. accountRes.should.have.status(200)
  132. accountRes.should.be.json
  133. accountRes.body.should.have.property('admin', true)
  134. accountRes.body.should.have.property('username', 'adminaccount1')
  135. accountRes.body.should.have.property('hash')
  136. try {
  137. let invalidAccountRes = await chai.request(server)
  138. .post('/api/v1/user')
  139. .set('content-type', 'application/json')
  140. .send({
  141. username: 'adminaccount2',
  142. password: 'password',
  143. admin: true,
  144. token: token
  145. })
  146. invalidAccountRes.should.have.status(401)
  147. invalidAccountRes.should.be.json
  148. invalidAccountRes.body.should.have.property('errors')
  149. invalidAccountRes.body.errors.should.include.something.that.deep.equals(Errors.invalidToken)
  150. } catch (res) {
  151. res.should.have.status(401)
  152. JSON.parse(res.response.text).errors.should.include.something.that.deep.equals(Errors.invalidToken)
  153. }
  154. })
  155. it('should throw an error if account already created', (done) => {
  156. chai.request(server)
  157. .post('/api/v1/user')
  158. .set('content-type', 'application/x-www-form-urlencoded')
  159. .send({
  160. username: 'username',
  161. password: 'password'
  162. })
  163. .end((err, res) => {
  164. res.should.have.status(400)
  165. res.should.be.json
  166. res.body.should.have.property('errors')
  167. res.body.errors.should.include.something.that.deep.equals(Errors.accountAlreadyCreated)
  168. done()
  169. })
  170. })
  171. it('should throw an error if no username or password', (done) => {
  172. chai.request(server)
  173. .post('/api/v1/user')
  174. .set('content-type', 'application/x-www-form-urlencoded')
  175. .send({})
  176. .end((err, res) => {
  177. res.should.have.status(400)
  178. res.should.be.json
  179. res.body.should.have.property('errors')
  180. res.body.errors.should.include.something.that.deep.equals(Errors.missingParameter('username'))
  181. res.body.errors.should.include.something.that.deep.equals(Errors.missingParameter('password'))
  182. done()
  183. })
  184. })
  185. it('should throw an error if username or password are not a string', (done) => {
  186. chai.request(server)
  187. .post('/api/v1/user')
  188. .set('content-type', 'application/json')
  189. .send({
  190. username: 123,
  191. password: 123
  192. })
  193. .end((err, res) => {
  194. res.should.have.status(400)
  195. res.should.be.json
  196. res.body.should.have.property('errors')
  197. res.body.should.have.property('errors')
  198. res.body.errors.should.include.something.that.deep.equals(Errors.invalidParameterType('username', 'string'))
  199. res.body.errors.should.include.something.that.deep.equals(Errors.invalidParameterType('password', 'string'))
  200. done()
  201. })
  202. })
  203. it('should throw an error if username or password less than 6 characters', (done) => {
  204. chai.request(server)
  205. .post('/api/v1/user')
  206. .set('content-type', 'application/x-www-form-urlencoded')
  207. .send({
  208. username: 'test',
  209. password: 'pass'
  210. })
  211. .end((err, res) => {
  212. res.should.have.status(400)
  213. res.should.be.json
  214. res.body.should.have.property('errors')
  215. res.body.errors.should.contain.something.that.deep.equals(Errors.parameterLengthTooSmall('username', '6'))
  216. res.body.errors.should.contain.something.that.deep.equals(Errors.parameterLengthTooSmall('password', '6'))
  217. done()
  218. })
  219. })
  220. it('should throw an error if username greater than 50 characters or password is greater than 100 characters', (done) => {
  221. chai.request(server)
  222. .post('/api/v1/user')
  223. .set('content-type', 'application/x-www-form-urlencoded')
  224. .send({
  225. username: '123456789012345678901234567890123456789012345678901',
  226. password: '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901'
  227. })
  228. .end((err, res) => {
  229. res.should.have.status(400)
  230. res.should.be.json
  231. res.body.should.have.property('errors')
  232. res.body.errors.should.contain.something.that.deep.equals(Errors.parameterLengthTooLarge('username', '50'))
  233. res.body.errors.should.contain.something.that.deep.equals(Errors.parameterLengthTooLarge('password', '100'))
  234. done()
  235. })
  236. })
  237. })
  238. describe('/:username GET user', () => {
  239. it('should return the user', async () => {
  240. let res = await chai.request(server)
  241. .get('/api/v1/user/username')
  242. res.should.have.status(200)
  243. res.should.be.json
  244. res.body.should.have.property('username', 'username')
  245. res.body.should.have.property('color')
  246. res.body.should.not.have.property('hash')
  247. })
  248. it('should return an error if username invalid', async () => {
  249. try {
  250. let res = await chai.request(server)
  251. .get('/api/v1/user/not_a_user')
  252. res.should.have.status(400)
  253. res.body.errors.should.contain.something.that.deep.equals(Errors.accountDoesNotExist)
  254. } catch(res) {
  255. let body = JSON.parse(res.response.text)
  256. res.should.have.status(400)
  257. body.errors.should.contain.something.that.deep.equals(Errors.accountDoesNotExist)
  258. }
  259. })
  260. it('should get posts as well if posts query is appended', async () => {
  261. let agent = chai.request.agent(server)
  262. await agent
  263. .post('/api/v1/user/adminaccount/login')
  264. .set('content-type', 'application/x-www-form-urlencoded')
  265. .send({ password: 'password' })
  266. await agent
  267. .post('/api/v1/category')
  268. .set('content-type', 'application/x-www-form-urlencoded')
  269. .send({ name: 'categorynamehere' })
  270. await agent
  271. .post('/api/v1/thread')
  272. .set('content-type', 'application/x-www-form-urlencoded')
  273. .send({ name: 'a thread name', category: 'categorynamehere' })
  274. await agent
  275. .post('/api/v1/post')
  276. .set('content-type', 'application/json')
  277. .send({ threadId: 1, content: 'content for post' })
  278. await agent
  279. .post('/api/v1/post')
  280. .set('content-type', 'application/json')
  281. .send({ threadId: 1, content: 'content for another post' })
  282. let res = await agent
  283. .get('/api/v1/user/adminaccount?posts=true')
  284. res.should.be.json
  285. res.should.have.status(200)
  286. res.body.should.have.property('username', 'adminaccount')
  287. res.body.should.have.property('Posts')
  288. res.body.Posts.should.have.property('length', 2)
  289. res.body.Posts[0].should.have.deep.property('Thread.id', 1)
  290. res.body.Posts[0].should.have.deep.property('User.username', 'adminaccount')
  291. })
  292. it('should allow pagination', async () => {
  293. let agent = chai.request.agent(server)
  294. await agent
  295. .post('/api/v1/user')
  296. .set('content-type', 'application/x-www-form-urlencoded')
  297. .send({ username: 'paginationaccount', password: 'password' })
  298. for(var i = 0; i < 30; i++) {
  299. let thread = await agent
  300. .post('/api/v1/thread')
  301. .set('content-type', 'application/json')
  302. .send({ category: 'categorynamehere', name: `THREAD ${i}` })
  303. await agent
  304. .post('/api/v1/post')
  305. .set('content-type', 'application/json')
  306. .send({ threadId: thread.body.id, content: `POST ${i}` })
  307. }
  308. let pageOne = await agent.get('/api/v1/user/paginationaccount?posts=true')
  309. let pageTwo = await agent.get(pageOne.body.meta.nextURL)
  310. let pageThree = await agent.get(pageTwo.body.meta.nextURL)
  311. pageOne.body.Posts.should.have.length(10)
  312. pageOne.body.meta.should.have.property('nextPostsCount', 10)
  313. pageOne.body.Posts[0].should.have.property('content', '<p>POST 29</p>\n')
  314. pageTwo.body.Posts.should.have.length(10)
  315. pageTwo.body.meta.should.have.property('nextPostsCount', 10)
  316. pageTwo.body.Posts[0].should.have.property('content', '<p>POST 19</p>\n')
  317. pageThree.body.Posts.should.have.length(10)
  318. pageThree.body.meta.should.have.property('nextPostsCount', 0)
  319. pageThree.body.Posts[0].should.have.property('content', '<p>POST 9</p>\n')
  320. pageThree.body.Posts[9].should.have.property('content', '<p>POST 0</p>\n')
  321. expect(pageThree.body.meta.nextURL).to.be.null
  322. })
  323. it('should get threads as well if threads query is appended', async () => {
  324. let agent = chai.request.agent(server)
  325. await agent
  326. .post('/api/v1/user')
  327. .set('content-type', 'application/x-www-form-urlencoded')
  328. .send({ username: 'threadaccount', password: 'password' })
  329. for(var i = 0; i < 20; i++) {
  330. let thread = await agent
  331. .post('/api/v1/thread')
  332. .set('content-type', 'application/json')
  333. .send({ category: 'categorynamehere', name: 'THREAD ' + i })
  334. await agent
  335. .post('/api/v1/post')
  336. .set('content-type', 'application/json')
  337. .send({ threadId: thread.body.id, content: `POST ${i}` })
  338. }
  339. let pageOne = await agent.get('/api/v1/user/threadaccount?threads=true')
  340. //Add another newer thread
  341. //This should not affect other tests
  342. let thread = await agent
  343. .post('/api/v1/thread')
  344. .set('content-type', 'application/json')
  345. .send({ category: 'categorynamehere', name: 'THREAD 20'})
  346. await agent
  347. .post('/api/v1/post')
  348. .set('content-type', 'application/json')
  349. .send({ threadId: thread.body.id, content: `POST 20` })
  350. let pageTwo = await agent.get(pageOne.body.meta.nextURL)
  351. pageOne.body.Threads.should.have.length(10)
  352. pageOne.body.Threads[0].should.have.property('name', 'THREAD 19')
  353. pageOne.body.meta.should.have.property('nextThreadsCount', 10)
  354. pageTwo.body.Threads.should.have.length(10)
  355. pageTwo.body.Threads[0].should.have.property('name', 'THREAD 9')
  356. pageTwo.body.meta.should.have.property('nextThreadsCount', 0)
  357. expect(pageTwo.body.meta.nextURL).to.be.null
  358. })
  359. })
  360. describe('/:username/login POST user', () => {
  361. let agent = chai.request.agent(server)
  362. it('should throw an error if invalid username is provided', (done) => {
  363. chai.request(server)
  364. .post('/api/v1/user/invalid_username/login')
  365. .set('content-type', 'application/x-www-form-urlencoded')
  366. .send({
  367. password: 'password'
  368. })
  369. .end((err, res) => {
  370. res.should.have.status(401)
  371. res.body.should.have.property('errors')
  372. res.body.errors.should.contain.something.that.deep.equals(Errors.invalidLoginCredentials)
  373. done()
  374. })
  375. })
  376. it('should throw an error if invalid password is provided', (done) => {
  377. chai.request(server)
  378. .post('/api/v1/user/username/login')
  379. .set('content-type', 'application/x-www-form-urlencoded')
  380. .send({
  381. password: 'invalid_password'
  382. })
  383. .end((err, res) => {
  384. res.should.have.status(401)
  385. res.body.should.have.property('errors')
  386. res.body.errors.should.contain.something.that.deep.equals(Errors.invalidLoginCredentials)
  387. res.should.not.have.cookie('username')
  388. done()
  389. })
  390. })
  391. it('should log in the user', (done) => {
  392. agent
  393. .post('/api/v1/user/username/login')
  394. .set('content-type', 'application/x-www-form-urlencoded')
  395. .send({
  396. password: 'password'
  397. })
  398. .end((err, res) => {
  399. res.should.have.status(200)
  400. res.should.be.json
  401. res.should.have.cookie('username', 'username')
  402. if(err) {
  403. done(err)
  404. } else {
  405. done()
  406. }
  407. })
  408. })
  409. })
  410. describe('/:username/logout POST user', () => {
  411. let agent = chai.request.agent(server)
  412. it('should log out the user', (done) => {
  413. agent
  414. .post('/api/v1/user/login')
  415. .set('content-type', 'application/x-www-form-urlencoded')
  416. .send({
  417. username: 'username',
  418. password: 'password'
  419. })
  420. .end((err, res) => {
  421. agent
  422. .post('/api/v1/user/username/logout')
  423. .end((err, res) => {
  424. res.should.have.status(200)
  425. res.should.not.have.cookie('username')
  426. if(err) {
  427. done(err)
  428. } else {
  429. done()
  430. }
  431. })
  432. })
  433. })
  434. })
  435. describe('/:username PUT user', () => {
  436. let agent = chai.request.agent(server)
  437. before(async () => {
  438. await agent
  439. .post('/api/v1/user/adminaccount/login')
  440. .set('content-type', 'application/json')
  441. .send({
  442. password: 'password'
  443. })
  444. })
  445. it('should add user description if it doesn\'t already exist', async () => {
  446. let putRes = await agent
  447. .put('/api/v1/user/adminaccount')
  448. .set('content-type', 'application/json')
  449. .send({
  450. description: 'description here'
  451. })
  452. putRes.should.be.json
  453. putRes.body.should.have.property('success', true)
  454. let getRes = await agent.get('/api/v1/user/adminaccount')
  455. getRes.should.be.json
  456. getRes.body.should.have.property('description', 'description here')
  457. getRes.body.should.have.property('username', 'adminaccount')
  458. getRes.body.should.have.property('color')
  459. })
  460. it('should update user description if it already exists', async () => {
  461. let putRes = await agent
  462. .put('/api/v1/user/adminaccount')
  463. .set('content-type', 'application/json')
  464. .send({
  465. description: 'new description here'
  466. })
  467. putRes.should.be.json
  468. putRes.body.should.have.property('success', true)
  469. let getRes = await agent.get('/api/v1/user/adminaccount')
  470. getRes.should.be.json
  471. getRes.body.should.have.property('description', 'new description here')
  472. })
  473. it('should return an error if username is not logged in', done => {
  474. agent
  475. .put('/api/v1/user/notloggedin')
  476. .set('content-type', 'application/json')
  477. .send({
  478. description: 'new description here'
  479. })
  480. .end((err, res) => {
  481. res.should.be.json
  482. res.should.have.status(400)
  483. res.body.errors.should.contain.something.that.deep.equals(Errors.requestNotAuthorized)
  484. done()
  485. })
  486. })
  487. it('should return an error if description is not a string', done => {
  488. agent
  489. .put('/api/v1/user/adminaccount')
  490. .set('content-type', 'application/json')
  491. .send({
  492. description: 123
  493. })
  494. .end((err, res) => {
  495. res.should.be.json
  496. res.should.have.status(400)
  497. res.body.errors.should.contain.something.that.deep.equals(Errors.invalidParameterType('description', 'string'))
  498. done()
  499. })
  500. })
  501. it('should return an error if description is too long', done => {
  502. let str = []
  503. for(var i = 0; i < 1025; i++) { str.push('a') }
  504. agent
  505. .put('/api/v1/user/adminaccount')
  506. .set('content-type', 'application/json')
  507. .send({
  508. description: str.join('')
  509. })
  510. .end((err, res) => {
  511. res.should.be.json
  512. res.should.have.status(400)
  513. res.body.errors.should.contain.something.that.deep.equals(Errors.parameterLengthTooLarge('description', '1024'))
  514. done()
  515. })
  516. })
  517. it('should update user password', async () => {
  518. let passwordAgent = chai.request.agent(server)
  519. await passwordAgent
  520. .post('/api/v1/user/adminaccount/login')
  521. .set('content-type', 'application/json')
  522. .send({
  523. password: 'password'
  524. })
  525. let putRes = await passwordAgent
  526. .put('/api/v1/user/adminaccount')
  527. .set('content-type', 'application/json')
  528. .send({
  529. currentPassword: 'password',
  530. newPassword: 'qwertyuiop'
  531. })
  532. putRes.should.be.json
  533. putRes.body.should.have.property('success', true)
  534. await passwordAgent.post('/api/v1/user/adminaccount/logout')
  535. let loginRes = await passwordAgent
  536. .post('/api/v1/user/adminaccount/login')
  537. .set('content-type', 'application/json')
  538. .send({
  539. password: 'qwertyuiop'
  540. })
  541. loginRes.should.have.status(200)
  542. loginRes.should.be.json
  543. loginRes.should.have.cookie('username', 'adminaccount')
  544. })
  545. it('should return an error if username is not logged in', done => {
  546. agent
  547. .put('/api/v1/user/notloggedin')
  548. .set('content-type', 'application/json')
  549. .send({
  550. currentPassword: 'qwertyuiop',
  551. newPassword: 'azertyuiop'
  552. })
  553. .end((err, res) => {
  554. res.should.have.status(400)
  555. res.body.errors.should.contain.something.that.deep.equals(Errors.requestNotAuthorized)
  556. done()
  557. })
  558. })
  559. it('should return an error if current password is incorrect', done => {
  560. agent
  561. .put('/api/v1/user/adminaccount')
  562. .set('content-type', 'application/json')
  563. .send({
  564. currentPassword: 'nottheirpassword',
  565. newPassword: 'azertyuiop'
  566. })
  567. .end((err, res) => {
  568. res.should.have.status(400)
  569. res.body.errors.should.contain.something.that.deep.equals(Errors.invalidLoginCredentials)
  570. done()
  571. })
  572. })
  573. it('should return an error if password is the same', done => {
  574. agent
  575. .put('/api/v1/user/adminaccount')
  576. .set('content-type', 'application/json')
  577. .send({
  578. currentPassword: 'qwertyuiop',
  579. newPassword: 'qwertyuiop'
  580. })
  581. .end((err, res) => {
  582. res.should.have.status(400)
  583. res.body.errors.should.contain.something.that.deep.equals(Errors.passwordSame)
  584. done()
  585. })
  586. })
  587. it('should return an error if password is too short', done => {
  588. agent
  589. .put('/api/v1/user/adminaccount')
  590. .set('content-type', 'application/json')
  591. .send({
  592. currentPassword: 'qwertyuiop',
  593. newPassword: ''
  594. })
  595. .end((err, res) => {
  596. res.should.have.status(400)
  597. res.body.errors.should.contain.something.that.deep.equals(Errors.parameterLengthTooSmall('new password', '7'))
  598. done()
  599. })
  600. })
  601. it('should return an error if password is too long', done => {
  602. let str = []
  603. for(var i = 0; i < 2000; i++) { str.push('a') }
  604. agent
  605. .put('/api/v1/user/adminaccount')
  606. .set('content-type', 'application/json')
  607. .send({
  608. currentPassword: 'qwertyuiop',
  609. newPassword: str.join('')
  610. })
  611. .end((err, res) => {
  612. res.should.have.status(400)
  613. res.body.errors.should.contain.something.that.deep.equals(Errors.parameterLengthTooLarge('new password', '1024'))
  614. done()
  615. })
  616. })
  617. it('should return an error if missing currentPassword', done => {
  618. agent
  619. .put('/api/v1/user/adminaccount')
  620. .set('content-type', 'application/json')
  621. .send({
  622. newPassword: 'qwertyujkjnbgfdswazxcvbhytr'
  623. })
  624. .end((err, res) => {
  625. res.should.have.status(400)
  626. res.body.errors.should.contain.something.that.deep.equals(Errors.missingParameter('current password'))
  627. done()
  628. })
  629. })
  630. })
  631. })