3 const request = require('supertest')
6 createUser: createUser,
7 getUserInformation: getUserInformation,
8 getUsersList: getUsersList,
9 removeUser: removeUser,
10 updateUser: updateUser
13 // ---------------------- Export functions --------------------
15 function createUser (url, accessToken, username, password, specialStatus, end) {
21 const path = '/api/v1/users'
25 .set('Accept', 'application/json')
26 .set('Authorization', 'Bearer ' + accessToken)
27 .send({ username: username, password: password })
28 .expect(specialStatus)
32 function getUserInformation (url, accessToken, end) {
33 const path = '/api/v1/users/me'
37 .set('Accept', 'application/json')
38 .set('Authorization', 'Bearer ' + accessToken)
40 .expect('Content-Type', /json/)
44 function getUsersList (url, end) {
45 const path = '/api/v1/users'
49 .set('Accept', 'application/json')
51 .expect('Content-Type', /json/)
55 function removeUser (url, userId, accessToken, expectedStatus, end) {
61 const path = '/api/v1/users'
64 .delete(path + '/' + userId)
65 .set('Accept', 'application/json')
66 .set('Authorization', 'Bearer ' + accessToken)
67 .expect(expectedStatus)
71 function updateUser (url, userId, accessToken, newPassword, end) {
72 const path = '/api/v1/users/' + userId
76 .set('Accept', 'application/json')
77 .set('Authorization', 'Bearer ' + accessToken)
78 .send({ password: newPassword })
83 // ---------------------------------------------------------------------------
85 module.exports = usersUtils