diff options
Diffstat (limited to 'server/tests/api/users.ts')
-rw-r--r-- | server/tests/api/users.ts | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/server/tests/api/users.ts b/server/tests/api/users.ts index dbf0801f3..bdef62c46 100644 --- a/server/tests/api/users.ts +++ b/server/tests/api/users.ts | |||
@@ -25,10 +25,12 @@ import { | |||
25 | updateUser, | 25 | updateUser, |
26 | updateMyUser, | 26 | updateMyUser, |
27 | registerUser, | 27 | registerUser, |
28 | removeUser | 28 | removeUser, |
29 | killallServers, | ||
30 | getUserInformation, | ||
31 | getBlacklistedVideosList | ||
29 | } from '../utils' | 32 | } from '../utils' |
30 | import { killallServers } from '../utils/servers' | 33 | import { UserRole } from '../../../shared' |
31 | import { getUserInformation } from '../utils/users' | ||
32 | 34 | ||
33 | describe('Test users', function () { | 35 | describe('Test users', function () { |
34 | let server: ServerInfo | 36 | let server: ServerInfo |
@@ -188,6 +190,7 @@ describe('Test users', function () { | |||
188 | expect(user.email).to.equal('user_1@example.com') | 190 | expect(user.email).to.equal('user_1@example.com') |
189 | expect(user.displayNSFW).to.be.false | 191 | expect(user.displayNSFW).to.be.false |
190 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | 192 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) |
193 | expect(user.roleLabel).to.equal('User') | ||
191 | expect(user.id).to.be.a('number') | 194 | expect(user.id).to.be.a('number') |
192 | }) | 195 | }) |
193 | 196 | ||
@@ -234,6 +237,7 @@ describe('Test users', function () { | |||
234 | const user = users[0] | 237 | const user = users[0] |
235 | expect(user.username).to.equal('root') | 238 | expect(user.username).to.equal('root') |
236 | expect(user.email).to.equal('admin1@example.com') | 239 | expect(user.email).to.equal('admin1@example.com') |
240 | expect(user.roleLabel).to.equal('Administrator') | ||
237 | expect(user.displayNSFW).to.be.false | 241 | expect(user.displayNSFW).to.be.false |
238 | }) | 242 | }) |
239 | 243 | ||
@@ -319,7 +323,7 @@ describe('Test users', function () { | |||
319 | }) | 323 | }) |
320 | 324 | ||
321 | it('Should be able to update another user', async function () { | 325 | it('Should be able to update another user', async function () { |
322 | await updateUser(server.url, userId, accessToken, 'updated2@example.com', 42) | 326 | await updateUser(server.url, userId, accessToken, 'updated2@example.com', 42, UserRole.MODERATOR) |
323 | 327 | ||
324 | const res = await getUserInformation(server.url, accessToken, userId) | 328 | const res = await getUserInformation(server.url, accessToken, userId) |
325 | const user = res.body | 329 | const user = res.body |
@@ -328,9 +332,18 @@ describe('Test users', function () { | |||
328 | expect(user.email).to.equal('updated2@example.com') | 332 | expect(user.email).to.equal('updated2@example.com') |
329 | expect(user.displayNSFW).to.be.ok | 333 | expect(user.displayNSFW).to.be.ok |
330 | expect(user.videoQuota).to.equal(42) | 334 | expect(user.videoQuota).to.equal(42) |
335 | expect(user.roleLabel).to.equal('Moderator') | ||
331 | expect(user.id).to.be.a('number') | 336 | expect(user.id).to.be.a('number') |
332 | }) | 337 | }) |
333 | 338 | ||
339 | it('Should not be able to delete a user by a moderator', async function () { | ||
340 | await removeUser(server.url, 2, accessTokenUser, 403) | ||
341 | }) | ||
342 | |||
343 | it('Should be able to list video blacklist by a moderator', async function () { | ||
344 | await getBlacklistedVideosList(server.url, accessTokenUser) | ||
345 | }) | ||
346 | |||
334 | it('Should be able to remove this user', async function () { | 347 | it('Should be able to remove this user', async function () { |
335 | await removeUser(server.url, userId, accessToken) | 348 | await removeUser(server.url, userId, accessToken) |
336 | }) | 349 | }) |