X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fusers%2Fusers.ts;h=cad954fcbdb7086e4ad372190f49624865756523;hb=3487330d308166afb542cbacae0475693c0b059e;hp=db82e8fc2244217f735e4186b95f12da9d793004;hpb=5600def4c87d3e6b7724489c9c4415778ea014d3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index db82e8fc2..cad954fcb 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts @@ -2,8 +2,9 @@ import * as chai from 'chai' import 'mocha' -import { MyUser, User, UserRole, Video, VideoPlaylistType, VideoAbuseState, VideoAbuseUpdate } from '../../../../shared/index' +import { MyUser, User, UserRole, Video, VideoAbuseState, VideoAbuseUpdate, VideoPlaylistType } from '../../../../shared/index' import { + addVideoCommentThread, blockUser, cleanupTests, createUser, @@ -11,12 +12,14 @@ import { flushAndRunServer, getAccountRatings, getBlacklistedVideosList, + getCustomConfig, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating, getUserInformation, getUsersList, getUsersListPaginationAndSort, + getVideoAbusesList, getVideoChannel, getVideosList, installPlugin, @@ -26,21 +29,21 @@ import { registerUserWithChannel, removeUser, removeVideo, + reportVideoAbuse, ServerInfo, testImage, unblockUser, + updateCustomSubConfig, updateMyAvatar, updateMyUser, updateUser, + updateVideoAbuse, uploadVideo, userLogin, - reportVideoAbuse, - addVideoCommentThread, - updateVideoAbuse, - getVideoAbusesList, updateCustomSubConfig, getCustomConfig, waitJobs + waitJobs } from '../../../../shared/extra-utils' import { follow } from '../../../../shared/extra-utils/server/follows' -import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' +import { logout, serverLogin, setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' import { getMyVideos } from '../../../../shared/extra-utils/videos/videos' import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' import { CustomConfig } from '@shared/models/server' @@ -60,7 +63,14 @@ describe('Test users', function () { before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + + server = await flushAndRunServer(1, { + rates_limit: { + login: { + max: 30 + } + } + }) await setAccessTokensToServers([ server ]) @@ -205,13 +215,17 @@ describe('Test users', function () { }) describe('Logout', function () { - it('Should logout (revoke token)') - - it('Should not be able to get the user information') + it('Should logout (revoke token)', async function () { + await logout(server.url, server.accessToken) + }) - it('Should not be able to upload a video') + it('Should not be able to get the user information', async function () { + await getMyUserInformation(server.url, server.accessToken, 401) + }) - it('Should not be able to remove a video') + it('Should not be able to upload a video', async function () { + await uploadVideo(server.url, server.accessToken, { name: 'video' }, 401) + }) it('Should not be able to rate a video', async function () { const path = '/api/v1/videos/' @@ -229,13 +243,17 @@ describe('Test users', function () { await makePutBodyRequest(options) }) - it('Should be able to login again') + it('Should be able to login again', async function () { + server.accessToken = await serverLogin(server) + }) it('Should have an expired access token') it('Should refresh the token') - it('Should be able to upload a video again') + it('Should be able to get my user information again', async function () { + await getMyUserInformation(server.url, server.accessToken) + }) }) describe('Creating a user', function () { @@ -247,7 +265,7 @@ describe('Test users', function () { username: user.username, password: user.password, videoQuota: 2 * 1024 * 1024, - adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST + adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST }) }) @@ -274,7 +292,7 @@ describe('Test users', function () { } expect(userMe.adminFlags).to.be.undefined - expect(userGet.adminFlags).to.equal(UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST) + expect(userGet.adminFlags).to.equal(UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST) expect(userMe.specialPlaylists).to.have.lengthOf(1) expect(userMe.specialPlaylists[0].type).to.equal(VideoPlaylistType.WATCH_LATER) @@ -400,6 +418,9 @@ describe('Test users', function () { expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com') expect(user.nsfwPolicy).to.equal('display') + expect(rootUser.lastLoginDate).to.exist + expect(user.lastLoginDate).to.exist + userId = user.id }) @@ -883,7 +904,7 @@ describe('Test users', function () { const reason = 'my super bad reason' await reportVideoAbuse(server.url, user17AccessToken, videoId, reason) - const res1 = await getVideoAbusesList(server.url, server.accessToken) + const res1 = await getVideoAbusesList({ url: server.url, token: server.accessToken }) const abuseId = res1.body.data[0].id const res2 = await getUserInformation(server.url, server.accessToken, user17Id, true)