aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/users.js11
-rw-r--r--server/tests/api/users.js31
2 files changed, 40 insertions, 2 deletions
diff --git a/server/tests/api/check-params/users.js b/server/tests/api/check-params/users.js
index b04f9f4a6..4a176e6c2 100644
--- a/server/tests/api/check-params/users.js
+++ b/server/tests/api/check-params/users.js
@@ -270,6 +270,14 @@ describe('Test users API validators', function () {
270 requestsUtils.makePutBodyRequest(server.url, path + userId, userAccessToken, data, done) 270 requestsUtils.makePutBodyRequest(server.url, path + userId, userAccessToken, data, done)
271 }) 271 })
272 272
273 it('Should fail with an invalid display NSFW attribute', function (done) {
274 const data = {
275 displayNSFW: -1
276 }
277
278 requestsUtils.makePutBodyRequest(server.url, path + userId, userAccessToken, data, done)
279 })
280
273 it('Should fail with an non authenticated user', function (done) { 281 it('Should fail with an non authenticated user', function (done) {
274 const data = { 282 const data = {
275 password: 'my super password' 283 password: 'my super password'
@@ -280,7 +288,8 @@ describe('Test users API validators', function () {
280 288
281 it('Should succeed with the correct params', function (done) { 289 it('Should succeed with the correct params', function (done) {
282 const data = { 290 const data = {
283 password: 'my super password' 291 password: 'my super password',
292 displayNSFW: true
284 } 293 }
285 294
286 requestsUtils.makePutBodyRequest(server.url, path + userId, userAccessToken, data, done, 204) 295 requestsUtils.makePutBodyRequest(server.url, path + userId, userAccessToken, data, done, 204)
diff --git a/server/tests/api/users.js b/server/tests/api/users.js
index 2b6956baa..a5e8a7edf 100644
--- a/server/tests/api/users.js
+++ b/server/tests/api/users.js
@@ -209,6 +209,7 @@ describe('Test users', function () {
209 209
210 expect(user.username).to.equal('user_1') 210 expect(user.username).to.equal('user_1')
211 expect(user.email).to.equal('user_1@example.com') 211 expect(user.email).to.equal('user_1@example.com')
212 expect(user.displayNSFW).to.be.falsy
212 expect(user.id).to.exist 213 expect(user.id).to.exist
213 214
214 done() 215 done()
@@ -237,10 +238,13 @@ describe('Test users', function () {
237 const user = users[0] 238 const user = users[0]
238 expect(user.username).to.equal('user_1') 239 expect(user.username).to.equal('user_1')
239 expect(user.email).to.equal('user_1@example.com') 240 expect(user.email).to.equal('user_1@example.com')
241 expect(user.displayNSFW).to.be.falsy
240 242
241 const rootUser = users[1] 243 const rootUser = users[1]
242 expect(rootUser.username).to.equal('root') 244 expect(rootUser.username).to.equal('root')
243 expect(rootUser.email).to.equal('admin1@example.com') 245 expect(rootUser.email).to.equal('admin1@example.com')
246 expect(rootUser.displayNSFW).to.be.falsy
247
244 userId = user.id 248 userId = user.id
245 249
246 done() 250 done()
@@ -261,6 +265,7 @@ describe('Test users', function () {
261 const user = users[0] 265 const user = users[0]
262 expect(user.username).to.equal('root') 266 expect(user.username).to.equal('root')
263 expect(user.email).to.equal('admin1@example.com') 267 expect(user.email).to.equal('admin1@example.com')
268 expect(user.displayNSFW).to.be.falsy
264 269
265 done() 270 done()
266 }) 271 })
@@ -280,6 +285,7 @@ describe('Test users', function () {
280 const user = users[0] 285 const user = users[0]
281 expect(user.username).to.equal('user_1') 286 expect(user.username).to.equal('user_1')
282 expect(user.email).to.equal('user_1@example.com') 287 expect(user.email).to.equal('user_1@example.com')
288 expect(user.displayNSFW).to.be.falsy
283 289
284 done() 290 done()
285 }) 291 })
@@ -299,6 +305,7 @@ describe('Test users', function () {
299 const user = users[0] 305 const user = users[0]
300 expect(user.username).to.equal('user_1') 306 expect(user.username).to.equal('user_1')
301 expect(user.email).to.equal('user_1@example.com') 307 expect(user.email).to.equal('user_1@example.com')
308 expect(user.displayNSFW).to.be.falsy
302 309
303 done() 310 done()
304 }) 311 })
@@ -317,15 +324,18 @@ describe('Test users', function () {
317 324
318 expect(users[0].username).to.equal('root') 325 expect(users[0].username).to.equal('root')
319 expect(users[0].email).to.equal('admin1@example.com') 326 expect(users[0].email).to.equal('admin1@example.com')
327 expect(users[0].displayNSFW).to.be.falsy
328
320 expect(users[1].username).to.equal('user_1') 329 expect(users[1].username).to.equal('user_1')
321 expect(users[1].email).to.equal('user_1@example.com') 330 expect(users[1].email).to.equal('user_1@example.com')
331 expect(users[1].displayNSFW).to.be.falsy
322 332
323 done() 333 done()
324 }) 334 })
325 }) 335 })
326 336
327 it('Should update the user password', function (done) { 337 it('Should update the user password', function (done) {
328 usersUtils.updateUser(server.url, userId, accessTokenUser, 'new password', function (err, res) { 338 usersUtils.updateUser(server.url, userId, accessTokenUser, 'new password', null, function (err, res) {
329 if (err) throw err 339 if (err) throw err
330 340
331 server.user.password = 'new password' 341 server.user.password = 'new password'
@@ -333,6 +343,25 @@ describe('Test users', function () {
333 }) 343 })
334 }) 344 })
335 345
346 it('Should be able to change the NSFW display attribute', function (done) {
347 usersUtils.updateUser(server.url, userId, accessTokenUser, null, true, function (err, res) {
348 if (err) throw err
349
350 usersUtils.getUserInformation(server.url, accessTokenUser, function (err, res) {
351 if (err) throw err
352
353 const user = res.body
354
355 expect(user.username).to.equal('user_1')
356 expect(user.email).to.equal('user_1@example.com')
357 expect(user.displayNSFW).to.be.truthy
358 expect(user.id).to.exist
359
360 done()
361 })
362 })
363 })
364
336 it('Should be able to remove this user', function (done) { 365 it('Should be able to remove this user', function (done) {
337 usersUtils.removeUser(server.url, userId, accessToken, done) 366 usersUtils.removeUser(server.url, userId, accessToken, done)
338 }) 367 })