aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/users.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-09-05 22:09:16 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-09-05 22:09:16 +0200
commit5c98d3bf078852043cbdd582c01e3dc4f4b5b79f (patch)
tree303d57ecc3c5d7b73cbbeb7187986a3dab87bcf0 /server/tests/api/users.ts
parent8094a8980265a0a28e508dbd7cf7c7029e6d98b6 (diff)
downloadPeerTube-5c98d3bf078852043cbdd582c01e3dc4f4b5b79f.tar.gz
PeerTube-5c98d3bf078852043cbdd582c01e3dc4f4b5b79f.tar.zst
PeerTube-5c98d3bf078852043cbdd582c01e3dc4f4b5b79f.zip
Begin tests for user quota
Diffstat (limited to 'server/tests/api/users.ts')
-rw-r--r--server/tests/api/users.ts53
1 files changed, 45 insertions, 8 deletions
diff --git a/server/tests/api/users.ts b/server/tests/api/users.ts
index fd3b51123..104d783bb 100644
--- a/server/tests/api/users.ts
+++ b/server/tests/api/users.ts
@@ -19,14 +19,16 @@ import {
19 makePutBodyRequest, 19 makePutBodyRequest,
20 createUser, 20 createUser,
21 loginAndGetAccessToken, 21 loginAndGetAccessToken,
22 getUserInformation, 22 getMyUserInformation,
23 getUsersList, 23 getUsersList,
24 getUsersListPaginationAndSort, 24 getUsersListPaginationAndSort,
25 updateUser, 25 updateUser,
26 updateMyUser,
26 registerUser, 27 registerUser,
27 removeUser 28 removeUser
28} from '../utils' 29} from '../utils'
29import { killallServers } from '../utils/servers' 30import { killallServers } from '../utils/servers'
31import { getUserInformation } from '../utils/users'
30 32
31describe('Test users', function () { 33describe('Test users', function () {
32 let server: ServerInfo 34 let server: ServerInfo
@@ -166,7 +168,7 @@ describe('Test users', function () {
166 it('Should be able to upload a video again') 168 it('Should be able to upload a video again')
167 169
168 it('Should be able to create a new user', async function () { 170 it('Should be able to create a new user', async function () {
169 await createUser(server.url, accessToken, 'user_1', 'super password') 171 await createUser(server.url, accessToken, 'user_1', 'super password', 2 * 1024 * 1024)
170 }) 172 })
171 173
172 it('Should be able to login with this user', async function () { 174 it('Should be able to login with this user', async function () {
@@ -179,12 +181,13 @@ describe('Test users', function () {
179 }) 181 })
180 182
181 it('Should be able to get the user information', async function () { 183 it('Should be able to get the user information', async function () {
182 const res = await getUserInformation(server.url, accessTokenUser) 184 const res = await getMyUserInformation(server.url, accessTokenUser)
183 const user = res.body 185 const user = res.body
184 186
185 expect(user.username).to.equal('user_1') 187 expect(user.username).to.equal('user_1')
186 expect(user.email).to.equal('user_1@example.com') 188 expect(user.email).to.equal('user_1@example.com')
187 expect(user.displayNSFW).to.be.false 189 expect(user.displayNSFW).to.be.false
190 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
188 expect(user.id).to.be.a('number') 191 expect(user.id).to.be.a('number')
189 }) 192 })
190 193
@@ -282,22 +285,49 @@ describe('Test users', function () {
282 expect(users[1].displayNSFW).to.be.false 285 expect(users[1].displayNSFW).to.be.false
283 }) 286 })
284 287
285 it('Should update the user password', async function () { 288 it('Should update my password', async function () {
286 await updateUser(server.url, userId, accessTokenUser, 'new password', null) 289 await updateMyUser(server.url, accessTokenUser, 'new password')
287 server.user.password = 'new password' 290 server.user.password = 'new password'
288 291
289 await login(server.url, server.client, server.user, 200) 292 await login(server.url, server.client, server.user, 200)
290 }) 293 })
291 294
292 it('Should be able to change the NSFW display attribute', async function () { 295 it('Should be able to change the NSFW display attribute', async function () {
293 await updateUser(server.url, userId, accessTokenUser, null, true) 296 await updateMyUser(server.url, accessTokenUser, undefined, true)
294 297
295 const res = await getUserInformation(server.url, accessTokenUser) 298 const res = await getMyUserInformation(server.url, accessTokenUser)
296 const user = res.body 299 const user = res.body
297 300
298 expect(user.username).to.equal('user_1') 301 expect(user.username).to.equal('user_1')
299 expect(user.email).to.equal('user_1@example.com') 302 expect(user.email).to.equal('user_1@example.com')
300 expect(user.displayNSFW).to.be.ok 303 expect(user.displayNSFW).to.be.ok
304 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
305 expect(user.id).to.be.a('number')
306 })
307
308 it('Should be able to change the email display attribute', async function () {
309 await updateMyUser(server.url, accessTokenUser, undefined, undefined, 'updated@example.com')
310
311 const res = await getMyUserInformation(server.url, accessTokenUser)
312 const user = res.body
313
314 expect(user.username).to.equal('user_1')
315 expect(user.email).to.equal('updated@example.com')
316 expect(user.displayNSFW).to.be.ok
317 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
318 expect(user.id).to.be.a('number')
319 })
320
321 it('Should be able to update another user', async function () {
322 await updateUser(server.url, userId, server.accessToken, 'updated2@example.com', 42 )
323
324 const res = await getUserInformation(server.url, server.accessToken, userId)
325 const user = res.body
326
327 expect(user.username).to.equal('user_1')
328 expect(user.email).to.equal('updated2@example.com')
329 expect(user.displayNSFW).to.be.ok
330 expect(user.videoQuota).to.equal(42)
301 expect(user.id).to.be.a('number') 331 expect(user.id).to.be.a('number')
302 }) 332 })
303 333
@@ -329,7 +359,14 @@ describe('Test users', function () {
329 password: 'my super password' 359 password: 'my super password'
330 } 360 }
331 361
332 await loginAndGetAccessToken(server) 362 accessToken = await loginAndGetAccessToken(server)
363 })
364
365 it('Should have the correct video quota', async function () {
366 const res = await getMyUserInformation(server.url, accessToken)
367 const user = res.body
368
369 expect(user.videoQuota).to.equal(5 * 1024 * 1024)
333 }) 370 })
334 371
335 after(async function () { 372 after(async function () {