3 const request = require('supertest')
9 getUsersListPaginationAndSort,
14 // ---------------------- Export functions --------------------
16 function createUser (url, accessToken, username, password, specialStatus, end) {
22 const path = '/api/v1/users'
26 .set('Accept', 'application/json')
27 .set('Authorization', 'Bearer ' + accessToken)
28 .send({ username: username, password: password })
29 .expect(specialStatus)
33 function getUserInformation (url, accessToken, end) {
34 const path = '/api/v1/users/me'
38 .set('Accept', 'application/json')
39 .set('Authorization', 'Bearer ' + accessToken)
41 .expect('Content-Type', /json/)
45 function getUsersList (url, end) {
46 const path = '/api/v1/users'
50 .set('Accept', 'application/json')
52 .expect('Content-Type', /json/)
56 function getUsersListPaginationAndSort (url, start, count, sort, end) {
57 const path = '/api/v1/users'
61 .query({ start: start })
62 .query({ count: count })
63 .query({ sort: sort })
64 .set('Accept', 'application/json')
66 .expect('Content-Type', /json/)
70 function removeUser (url, userId, accessToken, expectedStatus, end) {
76 const path = '/api/v1/users'
79 .delete(path + '/' + userId)
80 .set('Accept', 'application/json')
81 .set('Authorization', 'Bearer ' + accessToken)
82 .expect(expectedStatus)
86 function updateUser (url, userId, accessToken, newPassword, end) {
87 const path = '/api/v1/users/' + userId
91 .set('Accept', 'application/json')
92 .set('Authorization', 'Bearer ' + accessToken)
93 .send({ password: newPassword })
98 // ---------------------------------------------------------------------------
100 module.exports = usersUtils