aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-13 11:05:15 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit41d1d075011174e73dccb74006181a92a618d7b4 (patch)
tree4dc1af0e266977f062cf9716837d04de1cdd628d /server/tests/api/videos
parent6c5065a011b099618681a37bd77eaa7bd3db752e (diff)
downloadPeerTube-41d1d075011174e73dccb74006181a92a618d7b4.tar.gz
PeerTube-41d1d075011174e73dccb74006181a92a618d7b4.tar.zst
PeerTube-41d1d075011174e73dccb74006181a92a618d7b4.zip
Introduce login command
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/multiple-servers.ts3
-rw-r--r--server/tests/api/videos/video-change-ownership.ts11
-rw-r--r--server/tests/api/videos/video-channels.ts3
-rw-r--r--server/tests/api/videos/video-comments.ts3
-rw-r--r--server/tests/api/videos/video-nsfw.ts5
-rw-r--r--server/tests/api/videos/video-playlists.ts6
-rw-r--r--server/tests/api/videos/video-privacy.ts23
-rw-r--r--server/tests/api/videos/videos-filter.ts11
-rw-r--r--server/tests/api/videos/videos-history.ts3
9 files changed, 30 insertions, 38 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 1905aac83..740314bfd 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -24,7 +24,6 @@ import {
24 testImage, 24 testImage,
25 updateVideo, 25 updateVideo,
26 uploadVideo, 26 uploadVideo,
27 userLogin,
28 viewVideo, 27 viewVideo,
29 wait, 28 wait,
30 waitJobs, 29 waitJobs,
@@ -155,7 +154,7 @@ describe('Test multiple servers', function () {
155 password: 'super_password' 154 password: 'super_password'
156 } 155 }
157 await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) 156 await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
158 const userAccessToken = await userLogin(servers[1], user) 157 const userAccessToken = await servers[1].loginCommand.getAccessToken(user)
159 158
160 const videoAttributes = { 159 const videoAttributes = {
161 name: 'my super name for server 2', 160 name: 'my super name for server 2',
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index 1b81fe047..17c738e6f 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -16,8 +16,7 @@ import {
16 ServerInfo, 16 ServerInfo,
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 setDefaultVideoChannel, 18 setDefaultVideoChannel,
19 uploadVideo, 19 uploadVideo
20 userLogin
21} from '../../../../shared/extra-utils' 20} from '../../../../shared/extra-utils'
22import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 21import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
23import { User } from '../../../../shared/models/users' 22import { User } from '../../../../shared/models/users'
@@ -82,8 +81,8 @@ describe('Test video change ownership - nominal', function () {
82 videoQuota: videoQuota 81 videoQuota: videoQuota
83 }) 82 })
84 83
85 firstUserToken = await userLogin(servers[0], firstUser) 84 firstUserToken = await servers[0].loginCommand.getAccessToken(firstUser)
86 secondUserToken = await userLogin(servers[0], secondUser) 85 secondUserToken = await servers[0].loginCommand.getAccessToken(secondUser)
87 86
88 { 87 {
89 const res = await getMyUserInformation(servers[0].url, firstUserToken) 88 const res = await getMyUserInformation(servers[0].url, firstUserToken)
@@ -323,8 +322,8 @@ describe('Test video change ownership - quota too small', function () {
323 videoQuota: limitedVideoQuota 322 videoQuota: limitedVideoQuota
324 }) 323 })
325 324
326 firstUserToken = await userLogin(server, firstUser) 325 firstUserToken = await server.loginCommand.getAccessToken(firstUser)
327 secondUserToken = await userLogin(server, secondUser) 326 secondUserToken = await server.loginCommand.getAccessToken(secondUser)
328 327
329 // Upload some videos on the server 328 // Upload some videos on the server
330 const video1Attributes = { 329 const video1Attributes = {
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index e441ebbd4..83645640c 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -16,7 +16,6 @@ import {
16 testImage, 16 testImage,
17 updateVideo, 17 updateVideo,
18 uploadVideo, 18 uploadVideo,
19 userLogin,
20 wait 19 wait
21} from '../../../../shared/extra-utils' 20} from '../../../../shared/extra-utils'
22import { getMyUserInformation, ServerInfo, setAccessTokensToServers, viewVideo } from '../../../../shared/extra-utils/index' 21import { getMyUserInformation, ServerInfo, setAccessTokensToServers, viewVideo } from '../../../../shared/extra-utils/index'
@@ -391,7 +390,7 @@ describe('Test video channels', function () {
391 390
392 { 391 {
393 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'toto', password: 'password' }) 392 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'toto', password: 'password' })
394 const accessToken = await userLogin(servers[0], { username: 'toto', password: 'password' }) 393 const accessToken = await servers[0].loginCommand.getAccessToken({ username: 'toto', password: 'password' })
395 394
396 const res = await getMyUserInformation(servers[0].url, accessToken) 395 const res = await getMyUserInformation(servers[0].url, accessToken)
397 const videoChannel = res.body.videoChannels[0] 396 const videoChannel = res.body.videoChannels[0]
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 548d9fbf5..f9bd23646 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -8,7 +8,6 @@ import {
8 createUser, 8 createUser,
9 dateIsValid, 9 dateIsValid,
10 flushAndRunServer, 10 flushAndRunServer,
11 getAccessToken,
12 ServerInfo, 11 ServerInfo,
13 setAccessTokensToServers, 12 setAccessTokensToServers,
14 testImage, 13 testImage,
@@ -52,7 +51,7 @@ describe('Test video comments', function () {
52 username: 'user1', 51 username: 'user1',
53 password: 'password' 52 password: 'password'
54 }) 53 })
55 userAccessTokenServer1 = await getAccessToken(server.url, 'user1', 'password') 54 userAccessTokenServer1 = await server.loginCommand.getAccessToken('user1', 'password')
56 55
57 command = server.commentsCommand 56 command = server.commentsCommand
58 }) 57 })
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index c9c3792eb..a30b11ace 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -15,8 +15,7 @@ import {
15 ServerInfo, 15 ServerInfo,
16 setAccessTokensToServers, 16 setAccessTokensToServers,
17 updateMyUser, 17 updateMyUser,
18 uploadVideo, 18 uploadVideo
19 userLogin
20} from '@shared/extra-utils' 19} from '@shared/extra-utils'
21import { BooleanBothQuery, CustomConfig, ResultList, User, Video, VideosOverview } from '@shared/models' 20import { BooleanBothQuery, CustomConfig, ResultList, User, Video, VideosOverview } from '@shared/models'
22 21
@@ -151,7 +150,7 @@ describe('Test video NSFW policy', function () {
151 const password = 'my super password' 150 const password = 'my super password'
152 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) 151 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
153 152
154 userAccessToken = await userLogin(server, { username, password }) 153 userAccessToken = await server.loginCommand.getAccessToken({ username, password })
155 154
156 const res = await getMyUserInformation(server.url, userAccessToken) 155 const res = await getMyUserInformation(server.url, userAccessToken)
157 const user = res.body 156 const user = res.body
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 2bb019348..38133e2ce 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -10,7 +10,6 @@ import {
10 doubleFollow, 10 doubleFollow,
11 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
12 generateUserAccessToken, 12 generateUserAccessToken,
13 getAccessToken,
14 getMyUserInformation, 13 getMyUserInformation,
15 PlaylistsCommand, 14 PlaylistsCommand,
16 removeUser, 15 removeUser,
@@ -21,7 +20,6 @@ import {
21 updateVideo, 20 updateVideo,
22 uploadVideo, 21 uploadVideo,
23 uploadVideoAndGetId, 22 uploadVideoAndGetId,
24 userLogin,
25 wait, 23 wait,
26 waitJobs 24 waitJobs
27} from '@shared/extra-utils' 25} from '@shared/extra-utils'
@@ -122,7 +120,7 @@ describe('Test video playlists', function () {
122 username: 'user1', 120 username: 'user1',
123 password: 'password' 121 password: 'password'
124 }) 122 })
125 userTokenServer1 = await getAccessToken(servers[0].url, 'user1', 'password') 123 userTokenServer1 = await servers[0].loginCommand.getAccessToken('user1', 'password')
126 } 124 }
127 125
128 await waitJobs(servers) 126 await waitJobs(servers)
@@ -1129,7 +1127,7 @@ describe('Test video playlists', function () {
1129 }) 1127 })
1130 1128
1131 const userId = res.body.user.id 1129 const userId = res.body.user.id
1132 const userAccessToken = await userLogin(servers[0], user) 1130 const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
1133 1131
1134 const resChannel = await getMyUserInformation(servers[0].url, userAccessToken) 1132 const resChannel = await getMyUserInformation(servers[0].url, userAccessToken)
1135 const userChannel = (resChannel.body as User).videoChannels[0] 1133 const userChannel = (resChannel.body as User).videoChannels[0]
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index 950aeb7cf..f831dd8a9 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -2,23 +2,24 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '@shared/core-utils'
6import { Video, VideoCreateResult } from '@shared/models'
7import { 6import {
8 cleanupTests, 7 cleanupTests,
8 createUser,
9 doubleFollow,
9 flushAndRunServer, 10 flushAndRunServer,
11 getMyVideos,
12 getVideo,
10 getVideosList, 13 getVideosList,
11 getVideosListWithToken, 14 getVideosListWithToken,
15 getVideoWithToken,
12 ServerInfo, 16 ServerInfo,
13 setAccessTokensToServers, 17 setAccessTokensToServers,
14 uploadVideo 18 updateVideo,
15} from '../../../../shared/extra-utils/index' 19 uploadVideo,
16import { doubleFollow } from '../../../../shared/extra-utils/server/follows' 20 waitJobs
17import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 21} from '@shared/extra-utils'
18import { userLogin } from '../../../../shared/extra-utils/users/login' 22import { Video, VideoCreateResult, VideoPrivacy } from '@shared/models'
19import { createUser } from '../../../../shared/extra-utils/users/users'
20import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos'
21import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
22 23
23const expect = chai.expect 24const expect = chai.expect
24 25
@@ -126,7 +127,7 @@ describe('Test video privacy', function () {
126 } 127 }
127 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) 128 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
128 129
129 anotherUserToken = await userLogin(servers[0], user) 130 anotherUserToken = await servers[0].loginCommand.getAccessToken(user)
130 await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403) 131 await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403)
131 }) 132 })
132 133
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts
index 7428b82c5..519dad646 100644
--- a/server/tests/api/videos/videos-filter.ts
+++ b/server/tests/api/videos/videos-filter.ts
@@ -1,7 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
5import { 6import {
6 cleanupTests, 7 cleanupTests,
7 createUser, 8 createUser,
@@ -10,12 +11,10 @@ import {
10 makeGetRequest, 11 makeGetRequest,
11 ServerInfo, 12 ServerInfo,
12 setAccessTokensToServers, 13 setAccessTokensToServers,
13 uploadVideo, 14 uploadVideo
14 userLogin
15} from '../../../../shared/extra-utils' 15} from '../../../../shared/extra-utils'
16import { Video, VideoPrivacy } from '../../../../shared/models/videos'
17import { UserRole } from '../../../../shared/models/users' 16import { UserRole } from '../../../../shared/models/users'
18import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 17import { Video, VideoPrivacy } from '../../../../shared/models/videos'
19 18
20const expect = chai.expect 19const expect = chai.expect
21 20
@@ -72,7 +71,7 @@ describe('Test videos filter', function () {
72 role: UserRole.MODERATOR 71 role: UserRole.MODERATOR
73 } 72 }
74 ) 73 )
75 server['moderatorAccessToken'] = await userLogin(server, moderator) 74 server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator)
76 75
77 await uploadVideo(server.url, server.accessToken, { name: 'public ' + server.serverNumber }) 76 await uploadVideo(server.url, server.accessToken, { name: 'public ' + server.serverNumber })
78 77
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index 9a7635c35..256271bd0 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -16,7 +16,6 @@ import {
16 setAccessTokensToServers, 16 setAccessTokensToServers,
17 updateMyUser, 17 updateMyUser,
18 uploadVideo, 18 uploadVideo,
19 userLogin,
20 wait 19 wait
21} from '@shared/extra-utils' 20} from '@shared/extra-utils'
22import { Video, VideoDetails } from '@shared/models' 21import { Video, VideoDetails } from '@shared/models'
@@ -61,7 +60,7 @@ describe('Test videos history', function () {
61 password: 'super password' 60 password: 'super password'
62 } 61 }
63 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) 62 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
64 userAccessToken = await userLogin(server, user) 63 userAccessToken = await server.loginCommand.getAccessToken(user)
65 }) 64 })
66 65
67 it('Should get videos, without watching history', async function () { 66 it('Should get videos, without watching history', async function () {