diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-13 11:05:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 41d1d075011174e73dccb74006181a92a618d7b4 (patch) | |
tree | 4dc1af0e266977f062cf9716837d04de1cdd628d /server/tests/api/videos | |
parent | 6c5065a011b099618681a37bd77eaa7bd3db752e (diff) | |
download | PeerTube-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.ts | 3 | ||||
-rw-r--r-- | server/tests/api/videos/video-change-ownership.ts | 11 | ||||
-rw-r--r-- | server/tests/api/videos/video-channels.ts | 3 | ||||
-rw-r--r-- | server/tests/api/videos/video-comments.ts | 3 | ||||
-rw-r--r-- | server/tests/api/videos/video-nsfw.ts | 5 | ||||
-rw-r--r-- | server/tests/api/videos/video-playlists.ts | 6 | ||||
-rw-r--r-- | server/tests/api/videos/video-privacy.ts | 23 | ||||
-rw-r--r-- | server/tests/api/videos/videos-filter.ts | 11 | ||||
-rw-r--r-- | server/tests/api/videos/videos-history.ts | 3 |
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' |
22 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 21 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
23 | import { User } from '../../../../shared/models/users' | 22 | import { 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' |
22 | import { getMyUserInformation, ServerInfo, setAccessTokensToServers, viewVideo } from '../../../../shared/extra-utils/index' | 21 | import { 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' |
21 | import { BooleanBothQuery, CustomConfig, ResultList, User, Video, VideosOverview } from '@shared/models' | 20 | import { 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 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 5 | import { HttpStatusCode } from '@shared/core-utils' |
6 | import { Video, VideoCreateResult } from '@shared/models' | ||
7 | import { | 6 | import { |
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, |
16 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | 20 | waitJobs |
17 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 21 | } from '@shared/extra-utils' |
18 | import { userLogin } from '../../../../shared/extra-utils/users/login' | 22 | import { Video, VideoCreateResult, VideoPrivacy } from '@shared/models' |
19 | import { createUser } from '../../../../shared/extra-utils/users/users' | ||
20 | import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos' | ||
21 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | ||
22 | 23 | ||
23 | const expect = chai.expect | 24 | const 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 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
5 | import { | 6 | import { |
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' |
16 | import { Video, VideoPrivacy } from '../../../../shared/models/videos' | ||
17 | import { UserRole } from '../../../../shared/models/users' | 16 | import { UserRole } from '../../../../shared/models/users' |
18 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 17 | import { Video, VideoPrivacy } from '../../../../shared/models/videos' |
19 | 18 | ||
20 | const expect = chai.expect | 19 | const 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' |
22 | import { Video, VideoDetails } from '@shared/models' | 21 | import { 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 () { |