X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fusers%2Fusers.ts;h=af5a5fd258d04c383e830b50d8e9891159f9b65f;hb=5baee5fca418487e72ddcd6419d31bca8659b668;hp=3e1a0c19b90fcb345cf79b32396b22a5f5591e16;hpb=76314386aeafdd6849b7b70c517779d6b2013473;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 3e1a0c19b..af5a5fd25 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,23 +29,24 @@ import { registerUserWithChannel, removeUser, removeVideo, + reportVideoAbuse, ServerInfo, testImage, unblockUser, + updateCustomSubConfig, updateMyAvatar, updateMyUser, updateUser, + updateVideoAbuse, uploadVideo, userLogin, - reportVideoAbuse, - addVideoCommentThread, - updateVideoAbuse, - getVideoAbusesList + 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' const expect = chai.expect @@ -59,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 ]) @@ -204,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/' @@ -228,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 () { @@ -246,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_BLOCK }) }) @@ -273,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_BLOCK) expect(userMe.specialPlaylists).to.have.lengthOf(1) expect(userMe.specialPlaylists[0].type).to.equal(VideoPlaylistType.WATCH_LATER) @@ -293,7 +312,7 @@ describe('Test users', function () { describe('My videos & quotas', function () { it('Should be able to upload a video with this user', async function () { - this.timeout(5000) + this.timeout(10000) const videoAttributes = { name: 'super user video', @@ -345,6 +364,36 @@ describe('Test users', function () { expect(videos).to.have.lengthOf(0) } }) + + it('Should disable webtorrent, enable HLS, and update my quota', async function () { + this.timeout(60000) + + { + const res = await getCustomConfig(server.url, server.accessToken) + const config = res.body as CustomConfig + config.transcoding.webtorrent.enabled = false + config.transcoding.hls.enabled = true + config.transcoding.enabled = true + await updateCustomSubConfig(server.url, server.accessToken, config) + } + + { + const videoAttributes = { + name: 'super user video 2', + fixture: 'video_short.webm' + } + await uploadVideo(server.url, accessTokenUser, videoAttributes) + + await waitJobs([ server ]) + } + + { + const res = await getMyUserVideoQuotaUsed(server.url, accessTokenUser) + const data = res.body + + expect(data.videoQuotaUsed).to.be.greaterThan(220000) + } + }) }) describe('Users listing', function () { @@ -369,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 }) @@ -852,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)