diff options
Diffstat (limited to 'server/tests/api')
47 files changed, 175 insertions, 218 deletions
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts index d5e21404c..c1af23016 100644 --- a/server/tests/api/activitypub/fetch.ts +++ b/server/tests/api/activitypub/fetch.ts | |||
@@ -11,7 +11,6 @@ import { | |||
11 | ServerInfo, | 11 | ServerInfo, |
12 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
13 | uploadVideo, | 13 | uploadVideo, |
14 | userLogin, | ||
15 | waitJobs | 14 | waitJobs |
16 | } from '../../../../shared/extra-utils' | 15 | } from '../../../../shared/extra-utils' |
17 | import { Video } from '../../../../shared/models/videos' | 16 | import { Video } from '../../../../shared/models/videos' |
@@ -36,7 +35,7 @@ describe('Test ActivityPub fetcher', function () { | |||
36 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 35 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
37 | } | 36 | } |
38 | 37 | ||
39 | const userAccessToken = await userLogin(servers[0], user) | 38 | const userAccessToken = await servers[0].loginCommand.getAccessToken(user) |
40 | 39 | ||
41 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' }) | 40 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video root' }) |
42 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' }) | 41 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'bad video root' }) |
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts index e158e50dc..14949d301 100644 --- a/server/tests/api/check-params/abuses.ts +++ b/server/tests/api/check-params/abuses.ts | |||
@@ -18,7 +18,6 @@ import { | |||
18 | ServerInfo, | 18 | ServerInfo, |
19 | setAccessTokensToServers, | 19 | setAccessTokensToServers, |
20 | uploadVideo, | 20 | uploadVideo, |
21 | userLogin, | ||
22 | waitJobs | 21 | waitJobs |
23 | } from '@shared/extra-utils' | 22 | } from '@shared/extra-utils' |
24 | import { AbuseCreate, AbuseState } from '@shared/models' | 23 | import { AbuseCreate, AbuseState } from '@shared/models' |
@@ -47,7 +46,7 @@ describe('Test abuses API validators', function () { | |||
47 | const username = 'user1' | 46 | const username = 'user1' |
48 | const password = 'my super password' | 47 | const password = 'my super password' |
49 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) | 48 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) |
50 | userToken = await userLogin(server, { username, password }) | 49 | userToken = await server.loginCommand.getAccessToken({ username, password }) |
51 | 50 | ||
52 | userToken2 = await generateUserAccessToken(server, 'user_2') | 51 | userToken2 = await generateUserAccessToken(server, 'user_2') |
53 | 52 | ||
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts index 5ed8810ce..11a79387f 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/server/tests/api/check-params/blocklist.ts | |||
@@ -11,8 +11,7 @@ import { | |||
11 | makeGetRequest, | 11 | makeGetRequest, |
12 | makePostBodyRequest, | 12 | makePostBodyRequest, |
13 | ServerInfo, | 13 | ServerInfo, |
14 | setAccessTokensToServers, | 14 | setAccessTokensToServers |
15 | userLogin | ||
16 | } from '../../../../shared/extra-utils' | 15 | } from '../../../../shared/extra-utils' |
17 | import { | 16 | import { |
18 | checkBadCountPagination, | 17 | checkBadCountPagination, |
@@ -37,7 +36,7 @@ describe('Test blocklist API validators', function () { | |||
37 | const user = { username: 'user1', password: 'password' } | 36 | const user = { username: 'user1', password: 'password' } |
38 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 37 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
39 | 38 | ||
40 | userAccessToken = await userLogin(server, user) | 39 | userAccessToken = await server.loginCommand.getAccessToken(user) |
41 | 40 | ||
42 | await doubleFollow(servers[0], servers[1]) | 41 | await doubleFollow(servers[0], servers[1]) |
43 | }) | 42 | }) |
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts index 07b920ba7..85520b3bd 100644 --- a/server/tests/api/check-params/bulk.ts +++ b/server/tests/api/check-params/bulk.ts | |||
@@ -6,8 +6,7 @@ import { | |||
6 | createUser, | 6 | createUser, |
7 | flushAndRunServer, | 7 | flushAndRunServer, |
8 | ServerInfo, | 8 | ServerInfo, |
9 | setAccessTokensToServers, | 9 | setAccessTokensToServers |
10 | userLogin | ||
11 | } from '../../../../shared/extra-utils' | 10 | } from '../../../../shared/extra-utils' |
12 | import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests' | 11 | import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests' |
13 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 12 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
@@ -27,7 +26,7 @@ describe('Test bulk API validators', function () { | |||
27 | const user = { username: 'user1', password: 'password' } | 26 | const user = { username: 'user1', password: 'password' } |
28 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 27 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
29 | 28 | ||
30 | userAccessToken = await userLogin(server, user) | 29 | userAccessToken = await server.loginCommand.getAccessToken(user) |
31 | }) | 30 | }) |
32 | 31 | ||
33 | describe('When removing comments of', function () { | 32 | describe('When removing comments of', function () { |
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 291de93ea..e93523e4b 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -11,8 +11,7 @@ import { | |||
11 | makeGetRequest, | 11 | makeGetRequest, |
12 | makePutBodyRequest, | 12 | makePutBodyRequest, |
13 | ServerInfo, | 13 | ServerInfo, |
14 | setAccessTokensToServers, | 14 | setAccessTokensToServers |
15 | userLogin | ||
16 | } from '@shared/extra-utils' | 15 | } from '@shared/extra-utils' |
17 | import { CustomConfig } from '@shared/models' | 16 | import { CustomConfig } from '@shared/models' |
18 | 17 | ||
@@ -208,7 +207,7 @@ describe('Test config API validators', function () { | |||
208 | password: 'password' | 207 | password: 'password' |
209 | } | 208 | } |
210 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 209 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
211 | userAccessToken = await userLogin(server, user) | 210 | userAccessToken = await server.loginCommand.getAccessToken(user) |
212 | }) | 211 | }) |
213 | 212 | ||
214 | describe('When getting the configuration', function () { | 213 | describe('When getting the configuration', function () { |
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts index 74ca3384c..c1dd258aa 100644 --- a/server/tests/api/check-params/custom-pages.ts +++ b/server/tests/api/check-params/custom-pages.ts | |||
@@ -7,8 +7,7 @@ import { | |||
7 | createUser, | 7 | createUser, |
8 | flushAndRunServer, | 8 | flushAndRunServer, |
9 | ServerInfo, | 9 | ServerInfo, |
10 | setAccessTokensToServers, | 10 | setAccessTokensToServers |
11 | userLogin | ||
12 | } from '../../../../shared/extra-utils' | 11 | } from '../../../../shared/extra-utils' |
13 | import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests' | 12 | import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests' |
14 | 13 | ||
@@ -29,7 +28,7 @@ describe('Test custom pages validators', function () { | |||
29 | const user = { username: 'user1', password: 'password' } | 28 | const user = { username: 'user1', password: 'password' } |
30 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 29 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
31 | 30 | ||
32 | userAccessToken = await userLogin(server, user) | 31 | userAccessToken = await server.loginCommand.getAccessToken(user) |
33 | }) | 32 | }) |
34 | 33 | ||
35 | describe('When updating instance homepage', function () { | 34 | describe('When updating instance homepage', function () { |
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts index 37bf0f99b..dc033a441 100644 --- a/server/tests/api/check-params/debug.ts +++ b/server/tests/api/check-params/debug.ts | |||
@@ -7,8 +7,7 @@ import { | |||
7 | createUser, | 7 | createUser, |
8 | flushAndRunServer, | 8 | flushAndRunServer, |
9 | ServerInfo, | 9 | ServerInfo, |
10 | setAccessTokensToServers, | 10 | setAccessTokensToServers |
11 | userLogin | ||
12 | } from '../../../../shared/extra-utils' | 11 | } from '../../../../shared/extra-utils' |
13 | import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' | 12 | import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' |
14 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 13 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
@@ -32,7 +31,7 @@ describe('Test debug API validators', function () { | |||
32 | password: 'my super password' | 31 | password: 'my super password' |
33 | } | 32 | } |
34 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 33 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
35 | userAccessToken = await userLogin(server, user) | 34 | userAccessToken = await server.loginCommand.getAccessToken(user) |
36 | }) | 35 | }) |
37 | 36 | ||
38 | describe('When getting debug endpoint', function () { | 37 | describe('When getting debug endpoint', function () { |
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index c03dd5c9c..8cf5b130e 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts | |||
@@ -9,8 +9,7 @@ import { | |||
9 | makeDeleteRequest, makeGetRequest, | 9 | makeDeleteRequest, makeGetRequest, |
10 | makePostBodyRequest, | 10 | makePostBodyRequest, |
11 | ServerInfo, | 11 | ServerInfo, |
12 | setAccessTokensToServers, | 12 | setAccessTokensToServers |
13 | userLogin | ||
14 | } from '../../../../shared/extra-utils' | 13 | } from '../../../../shared/extra-utils' |
15 | import { | 14 | import { |
16 | checkBadCountPagination, | 15 | checkBadCountPagination, |
@@ -42,7 +41,7 @@ describe('Test server follows API validators', function () { | |||
42 | } | 41 | } |
43 | 42 | ||
44 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 43 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
45 | userAccessToken = await userLogin(server, user) | 44 | userAccessToken = await server.loginCommand.getAccessToken(user) |
46 | }) | 45 | }) |
47 | 46 | ||
48 | describe('When adding follows', function () { | 47 | describe('When adding follows', function () { |
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts index 3c1d2049b..cbe6a28b8 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/server/tests/api/check-params/jobs.ts | |||
@@ -7,8 +7,7 @@ import { | |||
7 | createUser, | 7 | createUser, |
8 | flushAndRunServer, | 8 | flushAndRunServer, |
9 | ServerInfo, | 9 | ServerInfo, |
10 | setAccessTokensToServers, | 10 | setAccessTokensToServers |
11 | userLogin | ||
12 | } from '../../../../shared/extra-utils' | 11 | } from '../../../../shared/extra-utils' |
13 | import { | 12 | import { |
14 | checkBadCountPagination, | 13 | checkBadCountPagination, |
@@ -37,7 +36,7 @@ describe('Test jobs API validators', function () { | |||
37 | password: 'my super password' | 36 | password: 'my super password' |
38 | } | 37 | } |
39 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 38 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
40 | userAccessToken = await userLogin(server, user) | 39 | userAccessToken = await server.loginCommand.getAccessToken(user) |
41 | }) | 40 | }) |
42 | 41 | ||
43 | describe('When listing jobs', function () { | 42 | describe('When listing jobs', function () { |
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index 394967285..045f3a1b1 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts | |||
@@ -17,8 +17,7 @@ import { | |||
17 | ServerInfo, | 17 | ServerInfo, |
18 | setAccessTokensToServers, | 18 | setAccessTokensToServers, |
19 | stopFfmpeg, | 19 | stopFfmpeg, |
20 | uploadVideoAndGetId, | 20 | uploadVideoAndGetId |
21 | userLogin | ||
22 | } from '../../../../shared/extra-utils' | 21 | } from '../../../../shared/extra-utils' |
23 | 22 | ||
24 | describe('Test video lives API validator', function () { | 23 | describe('Test video lives API validator', function () { |
@@ -53,7 +52,7 @@ describe('Test video lives API validator', function () { | |||
53 | const username = 'user1' | 52 | const username = 'user1' |
54 | const password = 'my super password' | 53 | const password = 'my super password' |
55 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) | 54 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) |
56 | userAccessToken = await userLogin(server, { username, password }) | 55 | userAccessToken = await server.loginCommand.getAccessToken({ username, password }) |
57 | 56 | ||
58 | { | 57 | { |
59 | const res = await getMyUserInformation(server.url, server.accessToken) | 58 | const res = await getMyUserInformation(server.url, server.accessToken) |
@@ -150,7 +149,7 @@ describe('Test video lives API validator', function () { | |||
150 | } | 149 | } |
151 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 150 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
152 | 151 | ||
153 | const accessTokenUser = await userLogin(server, user) | 152 | const accessTokenUser = await server.loginCommand.getAccessToken(user) |
154 | const res = await getMyUserInformation(server.url, accessTokenUser) | 153 | const res = await getMyUserInformation(server.url, accessTokenUser) |
155 | const customChannelId = res.body.videoChannels[0].id | 154 | const customChannelId = res.body.videoChannels[0].id |
156 | 155 | ||
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts index dac1e6b98..83ecfec93 100644 --- a/server/tests/api/check-params/logs.ts +++ b/server/tests/api/check-params/logs.ts | |||
@@ -7,8 +7,7 @@ import { | |||
7 | createUser, | 7 | createUser, |
8 | flushAndRunServer, | 8 | flushAndRunServer, |
9 | ServerInfo, | 9 | ServerInfo, |
10 | setAccessTokensToServers, | 10 | setAccessTokensToServers |
11 | userLogin | ||
12 | } from '../../../../shared/extra-utils' | 11 | } from '../../../../shared/extra-utils' |
13 | import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' | 12 | import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' |
14 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 13 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
@@ -32,7 +31,7 @@ describe('Test logs API validators', function () { | |||
32 | password: 'my super password' | 31 | password: 'my super password' |
33 | } | 32 | } |
34 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 33 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
35 | userAccessToken = await userLogin(server, user) | 34 | userAccessToken = await server.loginCommand.getAccessToken(user) |
36 | }) | 35 | }) |
37 | 36 | ||
38 | describe('When getting logs', function () { | 37 | describe('When getting logs', function () { |
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts index 8509b8ac5..130cf6869 100644 --- a/server/tests/api/check-params/plugins.ts +++ b/server/tests/api/check-params/plugins.ts | |||
@@ -13,8 +13,7 @@ import { | |||
13 | makePostBodyRequest, | 13 | makePostBodyRequest, |
14 | makePutBodyRequest, | 14 | makePutBodyRequest, |
15 | ServerInfo, | 15 | ServerInfo, |
16 | setAccessTokensToServers, | 16 | setAccessTokensToServers |
17 | userLogin | ||
18 | } from '@shared/extra-utils' | 17 | } from '@shared/extra-utils' |
19 | import { PeerTubePlugin, PluginType } from '@shared/models' | 18 | import { PeerTubePlugin, PluginType } from '@shared/models' |
20 | 19 | ||
@@ -45,7 +44,7 @@ describe('Test server plugins API validators', function () { | |||
45 | } | 44 | } |
46 | 45 | ||
47 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 46 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
48 | userAccessToken = await userLogin(server, user) | 47 | userAccessToken = await server.loginCommand.getAccessToken(user) |
49 | 48 | ||
50 | { | 49 | { |
51 | const res = await server.pluginsCommand.install({ npmName: npmPlugin }) | 50 | const res = await server.pluginsCommand.install({ npmName: npmPlugin }) |
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts index dac6938de..2e10e378a 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/server/tests/api/check-params/redundancy.ts | |||
@@ -19,7 +19,6 @@ import { | |||
19 | ServerInfo, | 19 | ServerInfo, |
20 | setAccessTokensToServers, | 20 | setAccessTokensToServers, |
21 | uploadVideoAndGetId, | 21 | uploadVideoAndGetId, |
22 | userLogin, | ||
23 | waitJobs | 22 | waitJobs |
24 | } from '../../../../shared/extra-utils' | 23 | } from '../../../../shared/extra-utils' |
25 | 24 | ||
@@ -45,7 +44,7 @@ describe('Test server redundancy API validators', function () { | |||
45 | } | 44 | } |
46 | 45 | ||
47 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 46 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
48 | userAccessToken = await userLogin(servers[0], user) | 47 | userAccessToken = await servers[0].loginCommand.getAccessToken(user) |
49 | 48 | ||
50 | videoIdLocal = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video' })).id | 49 | videoIdLocal = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video' })).id |
51 | 50 | ||
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts index c444663b8..3dc6cf2b4 100644 --- a/server/tests/api/check-params/upload-quota.ts +++ b/server/tests/api/check-params/upload-quota.ts | |||
@@ -15,7 +15,6 @@ import { | |||
15 | setDefaultVideoChannel, | 15 | setDefaultVideoChannel, |
16 | updateUser, | 16 | updateUser, |
17 | uploadVideo, | 17 | uploadVideo, |
18 | userLogin, | ||
19 | waitJobs | 18 | waitJobs |
20 | } from '../../../../shared/extra-utils' | 19 | } from '../../../../shared/extra-utils' |
21 | 20 | ||
@@ -50,7 +49,7 @@ describe('Test upload quota', function () { | |||
50 | 49 | ||
51 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } | 50 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } |
52 | await registerUser(server.url, user.username, user.password) | 51 | await registerUser(server.url, user.username, user.password) |
53 | const userAccessToken = await userLogin(server, user) | 52 | const userAccessToken = await server.loginCommand.getAccessToken(user) |
54 | 53 | ||
55 | const videoAttributes = { fixture: 'video_short2.webm' } | 54 | const videoAttributes = { fixture: 'video_short2.webm' } |
56 | for (let i = 0; i < 5; i++) { | 55 | for (let i = 0; i < 5; i++) { |
@@ -65,7 +64,7 @@ describe('Test upload quota', function () { | |||
65 | 64 | ||
66 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } | 65 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } |
67 | await registerUser(server.url, user.username, user.password) | 66 | await registerUser(server.url, user.username, user.password) |
68 | const userAccessToken = await userLogin(server, user) | 67 | const userAccessToken = await server.loginCommand.getAccessToken(user) |
69 | 68 | ||
70 | const videoAttributes = { fixture: 'video_short2.webm' } | 69 | const videoAttributes = { fixture: 'video_short2.webm' } |
71 | for (let i = 0; i < 5; i++) { | 70 | for (let i = 0; i < 5; i++) { |
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index 538201647..64e2703b9 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts | |||
@@ -10,8 +10,7 @@ import { | |||
10 | makeGetRequest, | 10 | makeGetRequest, |
11 | makePostBodyRequest, | 11 | makePostBodyRequest, |
12 | ServerInfo, | 12 | ServerInfo, |
13 | setAccessTokensToServers, | 13 | setAccessTokensToServers |
14 | userLogin | ||
15 | } from '../../../../shared/extra-utils' | 14 | } from '../../../../shared/extra-utils' |
16 | 15 | ||
17 | import { | 16 | import { |
@@ -41,7 +40,7 @@ describe('Test user subscriptions API validators', function () { | |||
41 | password: 'my super password' | 40 | password: 'my super password' |
42 | } | 41 | } |
43 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 42 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
44 | userAccessToken = await userLogin(server, user) | 43 | userAccessToken = await server.loginCommand.getAccessToken(user) |
45 | }) | 44 | }) |
46 | 45 | ||
47 | describe('When listing my subscriptions', function () { | 46 | describe('When listing my subscriptions', function () { |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index fda7e9640..54baeebe1 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -27,8 +27,7 @@ import { | |||
27 | ServerInfo, | 27 | ServerInfo, |
28 | setAccessTokensToServers, | 28 | setAccessTokensToServers, |
29 | unblockUser, | 29 | unblockUser, |
30 | uploadVideo, | 30 | uploadVideo |
31 | userLogin | ||
32 | } from '../../../../shared/extra-utils' | 31 | } from '../../../../shared/extra-utils' |
33 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' | 32 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' |
34 | import { | 33 | import { |
@@ -87,7 +86,7 @@ describe('Test users API validators', function () { | |||
87 | password: user.password, | 86 | password: user.password, |
88 | videoQuota: videoQuota | 87 | videoQuota: videoQuota |
89 | }) | 88 | }) |
90 | userAccessToken = await userLogin(server, user) | 89 | userAccessToken = await server.loginCommand.getAccessToken(user) |
91 | } | 90 | } |
92 | 91 | ||
93 | { | 92 | { |
@@ -104,7 +103,7 @@ describe('Test users API validators', function () { | |||
104 | role: UserRole.MODERATOR | 103 | role: UserRole.MODERATOR |
105 | }) | 104 | }) |
106 | 105 | ||
107 | moderatorAccessToken = await userLogin(server, moderator) | 106 | moderatorAccessToken = await server.loginCommand.getAccessToken(moderator) |
108 | } | 107 | } |
109 | 108 | ||
110 | { | 109 | { |
@@ -394,7 +393,7 @@ describe('Test users API validators', function () { | |||
394 | username: 'user1', | 393 | username: 'user1', |
395 | password: 'my super password' | 394 | password: 'my super password' |
396 | } | 395 | } |
397 | userAccessToken = await userLogin(server, user) | 396 | userAccessToken = await server.loginCommand.getAccessToken(user) |
398 | 397 | ||
399 | const fields = { | 398 | const fields = { |
400 | username: 'user3', | 399 | username: 'user3', |
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index 98cf2e11a..c33bc196d 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts | |||
@@ -19,7 +19,6 @@ import { | |||
19 | ServerInfo, | 19 | ServerInfo, |
20 | setAccessTokensToServers, | 20 | setAccessTokensToServers, |
21 | uploadVideo, | 21 | uploadVideo, |
22 | userLogin, | ||
23 | waitJobs | 22 | waitJobs |
24 | } from '@shared/extra-utils' | 23 | } from '@shared/extra-utils' |
25 | import { VideoBlacklistType, VideoDetails } from '@shared/models' | 24 | import { VideoBlacklistType, VideoDetails } from '@shared/models' |
@@ -46,14 +45,14 @@ describe('Test video blacklist API validators', function () { | |||
46 | const username = 'user1' | 45 | const username = 'user1' |
47 | const password = 'my super password' | 46 | const password = 'my super password' |
48 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password }) | 47 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password }) |
49 | userAccessToken1 = await userLogin(servers[0], { username, password }) | 48 | userAccessToken1 = await servers[0].loginCommand.getAccessToken({ username, password }) |
50 | } | 49 | } |
51 | 50 | ||
52 | { | 51 | { |
53 | const username = 'user2' | 52 | const username = 'user2' |
54 | const password = 'my super password' | 53 | const password = 'my super password' |
55 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password }) | 54 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: username, password: password }) |
56 | userAccessToken2 = await userLogin(servers[0], { username, password }) | 55 | userAccessToken2 = await servers[0].loginCommand.getAccessToken({ username, password }) |
57 | } | 56 | } |
58 | 57 | ||
59 | { | 58 | { |
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index baab0f276..f2fd61b91 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts | |||
@@ -12,8 +12,7 @@ import { | |||
12 | makeUploadRequest, | 12 | makeUploadRequest, |
13 | ServerInfo, | 13 | ServerInfo, |
14 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
15 | uploadVideo, | 15 | uploadVideo |
16 | userLogin | ||
17 | } from '@shared/extra-utils' | 16 | } from '@shared/extra-utils' |
18 | import { VideoCreateResult } from '@shared/models' | 17 | import { VideoCreateResult } from '@shared/models' |
19 | 18 | ||
@@ -44,7 +43,7 @@ describe('Test video captions API validator', function () { | |||
44 | password: 'my super password' | 43 | password: 'my super password' |
45 | } | 44 | } |
46 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 45 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
47 | userAccessToken = await userLogin(server, user) | 46 | userAccessToken = await server.loginCommand.getAccessToken(user) |
48 | } | 47 | } |
49 | }) | 48 | }) |
50 | 49 | ||
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index 3b72d3796..5361f6917 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts | |||
@@ -18,8 +18,7 @@ import { | |||
18 | makePutBodyRequest, | 18 | makePutBodyRequest, |
19 | makeUploadRequest, | 19 | makeUploadRequest, |
20 | ServerInfo, | 20 | ServerInfo, |
21 | setAccessTokensToServers, | 21 | setAccessTokensToServers |
22 | userLogin | ||
23 | } from '@shared/extra-utils' | 22 | } from '@shared/extra-utils' |
24 | import { VideoChannelUpdate } from '@shared/models' | 23 | import { VideoChannelUpdate } from '@shared/models' |
25 | 24 | ||
@@ -47,7 +46,7 @@ describe('Test video channels API validator', function () { | |||
47 | 46 | ||
48 | { | 47 | { |
49 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 48 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
50 | accessTokenUser = await userLogin(server, user) | 49 | accessTokenUser = await server.loginCommand.getAccessToken(user) |
51 | } | 50 | } |
52 | 51 | ||
53 | command = server.channelsCommand | 52 | command = server.channelsCommand |
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index 0f8c81392..c21aebaae 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts | |||
@@ -15,8 +15,7 @@ import { | |||
15 | makePostBodyRequest, | 15 | makePostBodyRequest, |
16 | ServerInfo, | 16 | ServerInfo, |
17 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
18 | uploadVideo, | 18 | uploadVideo |
19 | userLogin | ||
20 | } from '@shared/extra-utils' | 19 | } from '@shared/extra-utils' |
21 | import { VideoCreateResult } from '@shared/models' | 20 | import { VideoCreateResult } from '@shared/models' |
22 | 21 | ||
@@ -55,13 +54,13 @@ describe('Test video comments API validator', function () { | |||
55 | { | 54 | { |
56 | const user = { username: 'user1', password: 'my super password' } | 55 | const user = { username: 'user1', password: 'my super password' } |
57 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 56 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
58 | userAccessToken = await userLogin(server, user) | 57 | userAccessToken = await server.loginCommand.getAccessToken(user) |
59 | } | 58 | } |
60 | 59 | ||
61 | { | 60 | { |
62 | const user = { username: 'user2', password: 'my super password' } | 61 | const user = { username: 'user2', password: 'my super password' } |
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 | userAccessToken2 = await userLogin(server, user) | 63 | userAccessToken2 = await server.loginCommand.getAccessToken(user) |
65 | } | 64 | } |
66 | }) | 65 | }) |
67 | 66 | ||
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 2cc124cc1..51260affa 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -17,8 +17,7 @@ import { | |||
17 | makePostBodyRequest, | 17 | makePostBodyRequest, |
18 | makeUploadRequest, | 18 | makeUploadRequest, |
19 | ServerInfo, | 19 | ServerInfo, |
20 | setAccessTokensToServers, | 20 | setAccessTokensToServers |
21 | userLogin | ||
22 | } from '@shared/extra-utils' | 21 | } from '@shared/extra-utils' |
23 | import { VideoPrivacy } from '@shared/models' | 22 | import { VideoPrivacy } from '@shared/models' |
24 | 23 | ||
@@ -40,7 +39,7 @@ describe('Test video imports API validator', function () { | |||
40 | const username = 'user1' | 39 | const username = 'user1' |
41 | const password = 'my super password' | 40 | const password = 'my super password' |
42 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) | 41 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) |
43 | userAccessToken = await userLogin(server, { username, password }) | 42 | userAccessToken = await server.loginCommand.getAccessToken({ username, password }) |
44 | 43 | ||
45 | { | 44 | { |
46 | const res = await getMyUserInformation(server.url, server.accessToken) | 45 | const res = await getMyUserInformation(server.url, server.accessToken) |
@@ -167,7 +166,7 @@ describe('Test video imports API validator', function () { | |||
167 | } | 166 | } |
168 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 167 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
169 | 168 | ||
170 | const accessTokenUser = await userLogin(server, user) | 169 | const accessTokenUser = await server.loginCommand.getAccessToken(user) |
171 | const res = await getMyUserInformation(server.url, accessTokenUser) | 170 | const res = await getMyUserInformation(server.url, accessTokenUser) |
172 | const customChannelId = res.body.videoChannels[0].id | 171 | const customChannelId = res.body.videoChannels[0].id |
173 | 172 | ||
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts index 4d54a4fd0..095b94656 100644 --- a/server/tests/api/check-params/videos-filter.ts +++ b/server/tests/api/check-params/videos-filter.ts | |||
@@ -8,8 +8,7 @@ import { | |||
8 | makeGetRequest, | 8 | makeGetRequest, |
9 | ServerInfo, | 9 | ServerInfo, |
10 | setAccessTokensToServers, | 10 | setAccessTokensToServers, |
11 | setDefaultVideoChannel, | 11 | setDefaultVideoChannel |
12 | userLogin | ||
13 | } from '../../../../shared/extra-utils' | 12 | } from '../../../../shared/extra-utils' |
14 | import { UserRole } from '../../../../shared/models/users' | 13 | import { UserRole } from '../../../../shared/models/users' |
15 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 14 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
@@ -52,7 +51,7 @@ describe('Test video filters validators', function () { | |||
52 | 51 | ||
53 | const user = { username: 'user1', password: 'my super password' } | 52 | const user = { username: 'user1', password: 'my super password' } |
54 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 53 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
55 | userAccessToken = await userLogin(server, user) | 54 | userAccessToken = await server.loginCommand.getAccessToken(user) |
56 | 55 | ||
57 | const moderator = { username: 'moderator', password: 'my super password' } | 56 | const moderator = { username: 'moderator', password: 'my super password' } |
58 | await createUser( | 57 | await createUser( |
@@ -66,7 +65,7 @@ describe('Test video filters validators', function () { | |||
66 | role: UserRole.MODERATOR | 65 | role: UserRole.MODERATOR |
67 | } | 66 | } |
68 | ) | 67 | ) |
69 | moderatorAccessToken = await userLogin(server, moderator) | 68 | moderatorAccessToken = await server.loginCommand.getAccessToken(moderator) |
70 | }) | 69 | }) |
71 | 70 | ||
72 | describe('When setting a video filter', function () { | 71 | describe('When setting a video filter', function () { |
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 6549063b1..8e11232bd 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -22,8 +22,7 @@ import { | |||
22 | removeVideo, | 22 | removeVideo, |
23 | root, | 23 | root, |
24 | ServerInfo, | 24 | ServerInfo, |
25 | setAccessTokensToServers, | 25 | setAccessTokensToServers |
26 | userLogin | ||
27 | } from '../../../../shared/extra-utils' | 26 | } from '../../../../shared/extra-utils' |
28 | import { | 27 | import { |
29 | checkBadCountPagination, | 28 | checkBadCountPagination, |
@@ -55,7 +54,7 @@ describe('Test videos API validator', function () { | |||
55 | const username = 'user1' | 54 | const username = 'user1' |
56 | const password = 'my super password' | 55 | const password = 'my super password' |
57 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) | 56 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) |
58 | userAccessToken = await userLogin(server, { username, password }) | 57 | userAccessToken = await server.loginCommand.getAccessToken({ username, password }) |
59 | 58 | ||
60 | { | 59 | { |
61 | const res = await getMyUserInformation(server.url, server.accessToken) | 60 | const res = await getMyUserInformation(server.url, server.accessToken) |
@@ -286,7 +285,7 @@ describe('Test videos API validator', function () { | |||
286 | } | 285 | } |
287 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 286 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
288 | 287 | ||
289 | const accessTokenUser = await userLogin(server, user) | 288 | const accessTokenUser = await server.loginCommand.getAccessToken(user) |
290 | const res = await getMyUserInformation(server.url, accessTokenUser) | 289 | const res = await getMyUserInformation(server.url, accessTokenUser) |
291 | const customChannelId = res.body.videoChannels[0].id | 290 | const customChannelId = res.body.videoChannels[0].id |
292 | 291 | ||
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts index e428cf1a8..d7462f38f 100644 --- a/server/tests/api/moderation/abuses.ts +++ b/server/tests/api/moderation/abuses.ts | |||
@@ -17,7 +17,6 @@ import { | |||
17 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
18 | uploadVideo, | 18 | uploadVideo, |
19 | uploadVideoAndGetId, | 19 | uploadVideoAndGetId, |
20 | userLogin, | ||
21 | waitJobs | 20 | waitJobs |
22 | } from '@shared/extra-utils' | 21 | } from '@shared/extra-utils' |
23 | import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models' | 22 | import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models' |
@@ -280,7 +279,7 @@ describe('Test abuses', function () { | |||
280 | // register a second user to have two reporters/reportees | 279 | // register a second user to have two reporters/reportees |
281 | const user = { username: 'user2', password: 'password' } | 280 | const user = { username: 'user2', password: 'password' } |
282 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, ...user }) | 281 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, ...user }) |
283 | const userAccessToken = await userLogin(servers[0], user) | 282 | const userAccessToken = await servers[0].loginCommand.getAccessToken(user) |
284 | 283 | ||
285 | // upload a third video via this user | 284 | // upload a third video via this user |
286 | const video3Attributes = { | 285 | const video3Attributes = { |
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts index b676a4db4..4f2be6198 100644 --- a/server/tests/api/moderation/blocklist-notification.ts +++ b/server/tests/api/moderation/blocklist-notification.ts | |||
@@ -10,7 +10,6 @@ import { | |||
10 | ServerInfo, | 10 | ServerInfo, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | uploadVideo, | 12 | uploadVideo, |
13 | userLogin, | ||
14 | waitJobs | 13 | waitJobs |
15 | } from '@shared/extra-utils' | 14 | } from '@shared/extra-utils' |
16 | import { UserNotificationType } from '@shared/models' | 15 | import { UserNotificationType } from '@shared/models' |
@@ -86,7 +85,7 @@ describe('Test blocklist', function () { | |||
86 | videoQuotaDaily: -1 | 85 | videoQuotaDaily: -1 |
87 | }) | 86 | }) |
88 | 87 | ||
89 | userToken1 = await userLogin(servers[0], user) | 88 | userToken1 = await servers[0].loginCommand.getAccessToken(user) |
90 | await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' }) | 89 | await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' }) |
91 | } | 90 | } |
92 | 91 | ||
@@ -94,14 +93,14 @@ describe('Test blocklist', function () { | |||
94 | const user = { username: 'user2', password: 'password' } | 93 | const user = { username: 'user2', password: 'password' } |
95 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 94 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
96 | 95 | ||
97 | userToken2 = await userLogin(servers[0], user) | 96 | userToken2 = await servers[0].loginCommand.getAccessToken(user) |
98 | } | 97 | } |
99 | 98 | ||
100 | { | 99 | { |
101 | const user = { username: 'user3', password: 'password' } | 100 | const user = { username: 'user3', password: 'password' } |
102 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) | 101 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) |
103 | 102 | ||
104 | remoteUserToken = await userLogin(servers[1], user) | 103 | remoteUserToken = await servers[1].loginCommand.getAccessToken(user) |
105 | } | 104 | } |
106 | 105 | ||
107 | await doubleFollow(servers[0], servers[1]) | 106 | await doubleFollow(servers[0], servers[1]) |
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index 44e3de4e4..c38a7dad4 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts | |||
@@ -14,7 +14,6 @@ import { | |||
14 | ServerInfo, | 14 | ServerInfo, |
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
16 | uploadVideo, | 16 | uploadVideo, |
17 | userLogin, | ||
18 | waitJobs | 17 | waitJobs |
19 | } from '@shared/extra-utils' | 18 | } from '@shared/extra-utils' |
20 | import { UserNotificationType, Video } from '@shared/models' | 19 | import { UserNotificationType, Video } from '@shared/models' |
@@ -94,7 +93,7 @@ describe('Test blocklist', function () { | |||
94 | const user = { username: 'user1', password: 'password' } | 93 | const user = { username: 'user1', password: 'password' } |
95 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 94 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
96 | 95 | ||
97 | userToken1 = await userLogin(servers[0], user) | 96 | userToken1 = await servers[0].loginCommand.getAccessToken(user) |
98 | await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' }) | 97 | await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' }) |
99 | } | 98 | } |
100 | 99 | ||
@@ -102,14 +101,14 @@ describe('Test blocklist', function () { | |||
102 | const user = { username: 'moderator', password: 'password' } | 101 | const user = { username: 'moderator', password: 'password' } |
103 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 102 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
104 | 103 | ||
105 | userModeratorToken = await userLogin(servers[0], user) | 104 | userModeratorToken = await servers[0].loginCommand.getAccessToken(user) |
106 | } | 105 | } |
107 | 106 | ||
108 | { | 107 | { |
109 | const user = { username: 'user2', password: 'password' } | 108 | const user = { username: 'user2', password: 'password' } |
110 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) | 109 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) |
111 | 110 | ||
112 | userToken2 = await userLogin(servers[1], user) | 111 | userToken2 = await servers[1].loginCommand.getAccessToken(user) |
113 | await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' }) | 112 | await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' }) |
114 | } | 113 | } |
115 | 114 | ||
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts index 8b4723a2b..b61effc57 100644 --- a/server/tests/api/moderation/video-blacklist.ts +++ b/server/tests/api/moderation/video-blacklist.ts | |||
@@ -19,7 +19,6 @@ import { | |||
19 | setAccessTokensToServers, | 19 | setAccessTokensToServers, |
20 | updateVideo, | 20 | updateVideo, |
21 | uploadVideo, | 21 | uploadVideo, |
22 | userLogin, | ||
23 | waitJobs | 22 | waitJobs |
24 | } from '@shared/extra-utils' | 23 | } from '@shared/extra-utils' |
25 | import { User, UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models' | 24 | import { User, UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models' |
@@ -366,7 +365,7 @@ describe('Test video blacklist', function () { | |||
366 | role: UserRole.USER | 365 | role: UserRole.USER |
367 | }) | 366 | }) |
368 | 367 | ||
369 | userWithoutFlag = await userLogin(servers[0], user) | 368 | userWithoutFlag = await servers[0].loginCommand.getAccessToken(user) |
370 | 369 | ||
371 | const res = await getMyUserInformation(servers[0].url, userWithoutFlag) | 370 | const res = await getMyUserInformation(servers[0].url, userWithoutFlag) |
372 | const body: User = res.body | 371 | const body: User = res.body |
@@ -384,7 +383,7 @@ describe('Test video blacklist', function () { | |||
384 | role: UserRole.USER | 383 | role: UserRole.USER |
385 | }) | 384 | }) |
386 | 385 | ||
387 | userWithFlag = await userLogin(servers[0], user) | 386 | userWithFlag = await servers[0].loginCommand.getAccessToken(user) |
388 | } | 387 | } |
389 | 388 | ||
390 | await waitJobs(servers) | 389 | await waitJobs(servers) |
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index 83be9cd1e..3cba2b019 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts | |||
@@ -13,7 +13,6 @@ import { | |||
13 | updateMyUser, | 13 | updateMyUser, |
14 | updateVideo, | 14 | updateVideo, |
15 | uploadVideo, | 15 | uploadVideo, |
16 | userLogin, | ||
17 | wait, | 16 | wait, |
18 | waitJobs | 17 | waitJobs |
19 | } from '@shared/extra-utils' | 18 | } from '@shared/extra-utils' |
@@ -47,7 +46,7 @@ describe('Test ActivityPub video channels search', function () { | |||
47 | { | 46 | { |
48 | const user = { username: 'user1_server2', password: 'password' } | 47 | const user = { username: 'user1_server2', password: 'password' } |
49 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) | 48 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) |
50 | userServer2Token = await userLogin(servers[1], user) | 49 | userServer2Token = await servers[1].loginCommand.getAccessToken(user) |
51 | 50 | ||
52 | const channel = { | 51 | const channel = { |
53 | name: 'channel1_server2', | 52 | name: 'channel1_server2', |
diff --git a/server/tests/api/server/bulk.ts b/server/tests/api/server/bulk.ts index 5c8673e00..a09c21228 100644 --- a/server/tests/api/server/bulk.ts +++ b/server/tests/api/server/bulk.ts | |||
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { Video } from '@shared/models' | ||
6 | import { | 5 | import { |
7 | BulkCommand, | 6 | BulkCommand, |
8 | cleanupTests, | 7 | cleanupTests, |
@@ -13,9 +12,9 @@ import { | |||
13 | ServerInfo, | 12 | ServerInfo, |
14 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
15 | uploadVideo, | 14 | uploadVideo, |
16 | userLogin, | ||
17 | waitJobs | 15 | waitJobs |
18 | } from '../../../../shared/extra-utils/index' | 16 | } from '@shared/extra-utils' |
17 | import { Video } from '@shared/models' | ||
19 | 18 | ||
20 | const expect = chai.expect | 19 | const expect = chai.expect |
21 | 20 | ||
@@ -41,21 +40,21 @@ describe('Test bulk actions', function () { | |||
41 | const user = { username: 'user1', password: 'password' } | 40 | const user = { username: 'user1', password: 'password' } |
42 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 41 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
43 | 42 | ||
44 | user1Token = await userLogin(servers[0], user) | 43 | user1Token = await servers[0].loginCommand.getAccessToken(user) |
45 | } | 44 | } |
46 | 45 | ||
47 | { | 46 | { |
48 | const user = { username: 'user2', password: 'password' } | 47 | const user = { username: 'user2', password: 'password' } |
49 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 48 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
50 | 49 | ||
51 | user2Token = await userLogin(servers[0], user) | 50 | user2Token = await servers[0].loginCommand.getAccessToken(user) |
52 | } | 51 | } |
53 | 52 | ||
54 | { | 53 | { |
55 | const user = { username: 'user3', password: 'password' } | 54 | const user = { username: 'user3', password: 'password' } |
56 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) | 55 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) |
57 | 56 | ||
58 | user3Token = await userLogin(servers[1], user) | 57 | user3Token = await servers[1].loginCommand.getAccessToken(user) |
59 | } | 58 | } |
60 | 59 | ||
61 | await doubleFollow(servers[0], servers[1]) | 60 | await doubleFollow(servers[0], servers[1]) |
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index 5d997713b..c64c120e3 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts | |||
@@ -15,7 +15,6 @@ import { | |||
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
16 | unblockUser, | 16 | unblockUser, |
17 | uploadVideo, | 17 | uploadVideo, |
18 | userLogin, | ||
19 | verifyEmail | 18 | verifyEmail |
20 | } from '../../../../shared/extra-utils' | 19 | } from '../../../../shared/extra-utils' |
21 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' | 20 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' |
@@ -62,7 +61,7 @@ describe('Test emails', function () { | |||
62 | const res = await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 61 | const res = await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
63 | userId = res.body.user.id | 62 | userId = res.body.user.id |
64 | 63 | ||
65 | userAccessToken = await userLogin(server, user) | 64 | userAccessToken = await server.loginCommand.getAccessToken(user) |
66 | } | 65 | } |
67 | 66 | ||
68 | { | 67 | { |
@@ -128,7 +127,7 @@ describe('Test emails', function () { | |||
128 | it('Should login with this new password', async function () { | 127 | it('Should login with this new password', async function () { |
129 | user.password = 'super_password2' | 128 | user.password = 'super_password2' |
130 | 129 | ||
131 | await userLogin(server, user) | 130 | await server.loginCommand.getAccessToken(user) |
132 | }) | 131 | }) |
133 | }) | 132 | }) |
134 | 133 | ||
@@ -175,7 +174,7 @@ describe('Test emails', function () { | |||
175 | }) | 174 | }) |
176 | 175 | ||
177 | it('Should login with this new password', async function () { | 176 | it('Should login with this new password', async function () { |
178 | await userLogin(server, { | 177 | await server.loginCommand.getAccessToken({ |
179 | username: 'create_password', | 178 | username: 'create_password', |
180 | password: 'newly_created_password' | 179 | password: 'newly_created_password' |
181 | }) | 180 | }) |
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts index 0f1c6264d..74cdf353b 100644 --- a/server/tests/api/server/follow-constraints.ts +++ b/server/tests/api/server/follow-constraints.ts | |||
@@ -15,8 +15,7 @@ import { | |||
15 | getVideoWithToken, | 15 | getVideoWithToken, |
16 | ServerInfo, | 16 | ServerInfo, |
17 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
18 | uploadVideo, | 18 | uploadVideo |
19 | userLogin | ||
20 | } from '../../../../shared/extra-utils' | 19 | } from '../../../../shared/extra-utils' |
21 | 20 | ||
22 | const expect = chai.expect | 21 | const expect = chai.expect |
@@ -49,7 +48,7 @@ describe('Test follow constraints', function () { | |||
49 | password: 'super_password' | 48 | password: 'super_password' |
50 | } | 49 | } |
51 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 50 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
52 | userAccessToken = await userLogin(servers[0], user) | 51 | userAccessToken = await servers[0].loginCommand.getAccessToken(user) |
53 | 52 | ||
54 | await doubleFollow(servers[0], servers[1]) | 53 | await doubleFollow(servers[0], servers[1]) |
55 | }) | 54 | }) |
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index 4a9ed2d05..c2a0620a5 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -16,7 +16,6 @@ import { | |||
16 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
17 | testCaptionFile, | 17 | testCaptionFile, |
18 | uploadVideo, | 18 | uploadVideo, |
19 | userLogin, | ||
20 | waitJobs | 19 | waitJobs |
21 | } from '@shared/extra-utils' | 20 | } from '@shared/extra-utils' |
22 | import { Video, VideoPrivacy } from '@shared/models' | 21 | import { Video, VideoPrivacy } from '@shared/models' |
@@ -330,7 +329,7 @@ describe('Test follows', function () { | |||
330 | { | 329 | { |
331 | const user = { username: 'captain', password: 'password' } | 330 | const user = { username: 'captain', password: 'password' } |
332 | await createUser({ url: servers[2].url, accessToken: servers[2].accessToken, username: user.username, password: user.password }) | 331 | await createUser({ url: servers[2].url, accessToken: servers[2].accessToken, username: user.username, password: user.password }) |
333 | const userAccessToken = await userLogin(servers[2], user) | 332 | const userAccessToken = await servers[2].loginCommand.getAccessToken(user) |
334 | 333 | ||
335 | const resVideos = await getVideosList(servers[2].url) | 334 | const resVideos = await getVideosList(servers[2].url) |
336 | video4 = resVideos.body.data.find(v => v.name === 'server3-4') | 335 | video4 = resVideos.body.data.find(v => v.name === 'server3-4') |
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts index 17d1ee4a5..d9c669571 100644 --- a/server/tests/api/server/reverse-proxy.ts +++ b/server/tests/api/server/reverse-proxy.ts | |||
@@ -1,12 +1,17 @@ | |||
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 'mocha' | 3 | import { expect } from 'chai' |
4 | import * as chai from 'chai' | 4 | import { HttpStatusCode } from '@shared/core-utils' |
5 | import { cleanupTests, getVideo, registerUser, uploadVideo, userLogin, viewVideo, wait } from '../../../../shared/extra-utils' | 5 | import { |
6 | import { flushAndRunServer, setAccessTokensToServers } from '../../../../shared/extra-utils/index' | 6 | cleanupTests, |
7 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 7 | flushAndRunServer, |
8 | 8 | getVideo, | |
9 | const expect = chai.expect | 9 | registerUser, |
10 | setAccessTokensToServers, | ||
11 | uploadVideo, | ||
12 | viewVideo, | ||
13 | wait | ||
14 | } from '@shared/extra-utils' | ||
10 | 15 | ||
11 | describe('Test application behind a reverse proxy', function () { | 16 | describe('Test application behind a reverse proxy', function () { |
12 | let server = null | 17 | let server = null |
@@ -97,10 +102,10 @@ describe('Test application behind a reverse proxy', function () { | |||
97 | const user = { username: 'root', password: 'fail' } | 102 | const user = { username: 'root', password: 'fail' } |
98 | 103 | ||
99 | for (let i = 0; i < 19; i++) { | 104 | for (let i = 0; i < 19; i++) { |
100 | await userLogin(server, user, HttpStatusCode.BAD_REQUEST_400) | 105 | await server.loginCommand.getAccessToken(user, HttpStatusCode.BAD_REQUEST_400) |
101 | } | 106 | } |
102 | 107 | ||
103 | await userLogin(server, user, HttpStatusCode.TOO_MANY_REQUESTS_429) | 108 | await server.loginCommand.getAccessToken(user, HttpStatusCode.TOO_MANY_REQUESTS_429) |
104 | }) | 109 | }) |
105 | 110 | ||
106 | it('Should rate limit signup', async function () { | 111 | it('Should rate limit signup', async function () { |
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index ded305899..aa26f978d 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts | |||
@@ -10,7 +10,6 @@ import { | |||
10 | ServerInfo, | 10 | ServerInfo, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | uploadVideo, | 12 | uploadVideo, |
13 | userLogin, | ||
14 | viewVideo, | 13 | viewVideo, |
15 | wait, | 14 | wait, |
16 | waitJobs | 15 | waitJobs |
@@ -119,7 +118,7 @@ describe('Test stats (excluding redundancy)', function () { | |||
119 | } | 118 | } |
120 | 119 | ||
121 | { | 120 | { |
122 | await userLogin(server, user) | 121 | await server.loginCommand.getAccessToken(user) |
123 | 122 | ||
124 | const data = await server.statsCommand.get() | 123 | const data = await server.statsCommand.get() |
125 | 124 | ||
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index c119622ad..1d0fc35f1 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -13,7 +13,6 @@ import { | |||
13 | SubscriptionsCommand, | 13 | SubscriptionsCommand, |
14 | updateVideo, | 14 | updateVideo, |
15 | uploadVideo, | 15 | uploadVideo, |
16 | userLogin, | ||
17 | waitJobs | 16 | waitJobs |
18 | } from '@shared/extra-utils' | 17 | } from '@shared/extra-utils' |
19 | 18 | ||
@@ -42,7 +41,7 @@ describe('Test users subscriptions', function () { | |||
42 | const user = { username: 'user' + server.serverNumber, password: 'password' } | 41 | const user = { username: 'user' + server.serverNumber, password: 'password' } |
43 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 42 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) |
44 | 43 | ||
45 | const accessToken = await userLogin(server, user) | 44 | const accessToken = await server.loginCommand.getAccessToken(user) |
46 | users.push({ accessToken }) | 45 | users.push({ accessToken }) |
47 | 46 | ||
48 | const videoName1 = 'video 1-' + server.serverNumber | 47 | const videoName1 = 'video 1-' + server.serverNumber |
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 7b650cb8f..99fa08fe2 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -19,7 +19,6 @@ import { | |||
19 | updateMyAvatar, | 19 | updateMyAvatar, |
20 | updateMyUser, | 20 | updateMyUser, |
21 | uploadVideo, | 21 | uploadVideo, |
22 | userLogin, | ||
23 | waitJobs | 22 | waitJobs |
24 | } from '@shared/extra-utils' | 23 | } from '@shared/extra-utils' |
25 | import { User } from '@shared/models' | 24 | import { User } from '@shared/models' |
@@ -64,7 +63,7 @@ describe('Test users with multiple servers', function () { | |||
64 | password: user.password | 63 | password: user.password |
65 | }) | 64 | }) |
66 | userId = res.body.user.id | 65 | userId = res.body.user.id |
67 | userAccessToken = await userLogin(servers[0], user) | 66 | userAccessToken = await servers[0].loginCommand.getAccessToken(user) |
68 | } | 67 | } |
69 | 68 | ||
70 | { | 69 | { |
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts index 23f81d804..ade730323 100644 --- a/server/tests/api/users/users-verification.ts +++ b/server/tests/api/users/users-verification.ts | |||
@@ -2,23 +2,21 @@ | |||
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 { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | flushAndRunServer, | 8 | flushAndRunServer, |
9 | getMyUserInformation, | 9 | getMyUserInformation, |
10 | getUserInformation, | 10 | getUserInformation, |
11 | login, | 11 | MockSmtpServer, |
12 | registerUser, | 12 | registerUser, |
13 | ServerInfo, | 13 | ServerInfo, |
14 | setAccessTokensToServers, | ||
14 | updateMyUser, | 15 | updateMyUser, |
15 | userLogin, | 16 | verifyEmail, |
16 | verifyEmail | 17 | waitJobs |
17 | } from '../../../../shared/extra-utils' | 18 | } from '@shared/extra-utils' |
18 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' | 19 | import { User } from '@shared/models' |
19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
20 | import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' | ||
21 | import { User } from '../../../../shared/models/users' | ||
22 | 20 | ||
23 | const expect = chai.expect | 21 | const expect = chai.expect |
24 | 22 | ||
@@ -91,15 +89,15 @@ describe('Test users account verification', function () { | |||
91 | }) | 89 | }) |
92 | 90 | ||
93 | it('Should not allow login for user with unverified email', async function () { | 91 | it('Should not allow login for user with unverified email', async function () { |
94 | const resLogin = await login(server.url, server.client, user1, HttpStatusCode.BAD_REQUEST_400) | 92 | const { detail } = await server.loginCommand.login({ user: user1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
95 | expect(resLogin.body.detail).to.contain('User email is not verified.') | 93 | expect(detail).to.contain('User email is not verified.') |
96 | }) | 94 | }) |
97 | 95 | ||
98 | it('Should verify the user via email and allow login', async function () { | 96 | it('Should verify the user via email and allow login', async function () { |
99 | await verifyEmail(server.url, userId, verificationString) | 97 | await verifyEmail(server.url, userId, verificationString) |
100 | 98 | ||
101 | const res = await login(server.url, server.client, user1) | 99 | const body = await server.loginCommand.login({ user: user1 }) |
102 | userAccessToken = res.body.access_token | 100 | userAccessToken = body.access_token |
103 | 101 | ||
104 | const resUserVerified = await getUserInformation(server.url, server.accessToken, userId) | 102 | const resUserVerified = await getUserInformation(server.url, server.accessToken, userId) |
105 | expect(resUserVerified.body.emailVerified).to.be.true | 103 | expect(resUserVerified.body.emailVerified).to.be.true |
@@ -164,7 +162,7 @@ describe('Test users account verification', function () { | |||
164 | await waitJobs(server) | 162 | await waitJobs(server) |
165 | expect(emails).to.have.lengthOf(expectedEmailsLength) | 163 | expect(emails).to.have.lengthOf(expectedEmailsLength) |
166 | 164 | ||
167 | const accessToken = await userLogin(server, user2) | 165 | const accessToken = await server.loginCommand.getAccessToken(user2) |
168 | 166 | ||
169 | const resMyUserInfo = await getMyUserInformation(server.url, accessToken) | 167 | const resMyUserInfo = await getMyUserInformation(server.url, accessToken) |
170 | expect(resMyUserInfo.body.emailVerified).to.be.null | 168 | expect(resMyUserInfo.body.emailVerified).to.be.null |
@@ -181,7 +179,7 @@ describe('Test users account verification', function () { | |||
181 | } | 179 | } |
182 | }) | 180 | }) |
183 | 181 | ||
184 | await userLogin(server, user2) | 182 | await server.loginCommand.getAccessToken(user2) |
185 | }) | 183 | }) |
186 | 184 | ||
187 | after(async function () { | 185 | after(async function () { |
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 69a8dba34..608bedb8b 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -18,11 +18,8 @@ import { | |||
18 | getUsersListPaginationAndSort, | 18 | getUsersListPaginationAndSort, |
19 | getVideosList, | 19 | getVideosList, |
20 | killallServers, | 20 | killallServers, |
21 | login, | ||
22 | logout, | ||
23 | makePutBodyRequest, | 21 | makePutBodyRequest, |
24 | rateVideo, | 22 | rateVideo, |
25 | refreshToken, | ||
26 | registerUserWithChannel, | 23 | registerUserWithChannel, |
27 | removeUser, | 24 | removeUser, |
28 | removeVideo, | 25 | removeVideo, |
@@ -35,7 +32,6 @@ import { | |||
35 | updateMyUser, | 32 | updateMyUser, |
36 | updateUser, | 33 | updateUser, |
37 | uploadVideo, | 34 | uploadVideo, |
38 | userLogin, | ||
39 | waitJobs | 35 | waitJobs |
40 | } from '@shared/extra-utils' | 36 | } from '@shared/extra-utils' |
41 | import { AbuseState, MyUser, OAuth2ErrorCode, User, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models' | 37 | import { AbuseState, MyUser, OAuth2ErrorCode, User, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models' |
@@ -78,22 +74,22 @@ describe('Test users', function () { | |||
78 | 74 | ||
79 | it('Should not login with an invalid client id', async function () { | 75 | it('Should not login with an invalid client id', async function () { |
80 | const client = { id: 'client', secret: server.client.secret } | 76 | const client = { id: 'client', secret: server.client.secret } |
81 | const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400) | 77 | const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
82 | 78 | ||
83 | expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT) | 79 | expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT) |
84 | expect(res.body.error).to.contain('client is invalid') | 80 | expect(body.error).to.contain('client is invalid') |
85 | expect(res.body.type.startsWith('https://')).to.be.true | 81 | expect(body.type.startsWith('https://')).to.be.true |
86 | expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT) | 82 | expect(body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT) |
87 | }) | 83 | }) |
88 | 84 | ||
89 | it('Should not login with an invalid client secret', async function () { | 85 | it('Should not login with an invalid client secret', async function () { |
90 | const client = { id: server.client.id, secret: 'coucou' } | 86 | const client = { id: server.client.id, secret: 'coucou' } |
91 | const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400) | 87 | const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
92 | 88 | ||
93 | expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT) | 89 | expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT) |
94 | expect(res.body.error).to.contain('client is invalid') | 90 | expect(body.error).to.contain('client is invalid') |
95 | expect(res.body.type.startsWith('https://')).to.be.true | 91 | expect(body.type.startsWith('https://')).to.be.true |
96 | expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT) | 92 | expect(body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT) |
97 | }) | 93 | }) |
98 | }) | 94 | }) |
99 | 95 | ||
@@ -101,22 +97,22 @@ describe('Test users', function () { | |||
101 | 97 | ||
102 | it('Should not login with an invalid username', async function () { | 98 | it('Should not login with an invalid username', async function () { |
103 | const user = { username: 'captain crochet', password: server.user.password } | 99 | const user = { username: 'captain crochet', password: server.user.password } |
104 | const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400) | 100 | const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
105 | 101 | ||
106 | expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT) | 102 | expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT) |
107 | expect(res.body.error).to.contain('credentials are invalid') | 103 | expect(body.error).to.contain('credentials are invalid') |
108 | expect(res.body.type.startsWith('https://')).to.be.true | 104 | expect(body.type.startsWith('https://')).to.be.true |
109 | expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT) | 105 | expect(body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT) |
110 | }) | 106 | }) |
111 | 107 | ||
112 | it('Should not login with an invalid password', async function () { | 108 | it('Should not login with an invalid password', async function () { |
113 | const user = { username: server.user.username, password: 'mew_three' } | 109 | const user = { username: server.user.username, password: 'mew_three' } |
114 | const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400) | 110 | const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
115 | 111 | ||
116 | expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT) | 112 | expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT) |
117 | expect(res.body.error).to.contain('credentials are invalid') | 113 | expect(body.error).to.contain('credentials are invalid') |
118 | expect(res.body.type.startsWith('https://')).to.be.true | 114 | expect(body.type.startsWith('https://')).to.be.true |
119 | expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT) | 115 | expect(body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT) |
120 | }) | 116 | }) |
121 | 117 | ||
122 | it('Should not be able to upload a video', async function () { | 118 | it('Should not be able to upload a video', async function () { |
@@ -139,20 +135,20 @@ describe('Test users', function () { | |||
139 | it('Should not be able to unfollow') | 135 | it('Should not be able to unfollow') |
140 | 136 | ||
141 | it('Should be able to login', async function () { | 137 | it('Should be able to login', async function () { |
142 | const res = await login(server.url, server.client, server.user, HttpStatusCode.OK_200) | 138 | const body = await server.loginCommand.login({ expectedStatus: HttpStatusCode.OK_200 }) |
143 | 139 | ||
144 | accessToken = res.body.access_token | 140 | accessToken = body.access_token |
145 | }) | 141 | }) |
146 | 142 | ||
147 | it('Should be able to login with an insensitive username', async function () { | 143 | it('Should be able to login with an insensitive username', async function () { |
148 | const user = { username: 'RoOt', password: server.user.password } | 144 | const user = { username: 'RoOt', password: server.user.password } |
149 | await login(server.url, server.client, user, HttpStatusCode.OK_200) | 145 | await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.OK_200 }) |
150 | 146 | ||
151 | const user2 = { username: 'rOoT', password: server.user.password } | 147 | const user2 = { username: 'rOoT', password: server.user.password } |
152 | await login(server.url, server.client, user2, HttpStatusCode.OK_200) | 148 | await server.loginCommand.login({ user: user2, expectedStatus: HttpStatusCode.OK_200 }) |
153 | 149 | ||
154 | const user3 = { username: 'ROOt', password: server.user.password } | 150 | const user3 = { username: 'ROOt', password: server.user.password } |
155 | await login(server.url, server.client, user3, HttpStatusCode.OK_200) | 151 | await server.loginCommand.login({ user: user3, expectedStatus: HttpStatusCode.OK_200 }) |
156 | }) | 152 | }) |
157 | }) | 153 | }) |
158 | 154 | ||
@@ -222,7 +218,7 @@ describe('Test users', function () { | |||
222 | 218 | ||
223 | describe('Logout', function () { | 219 | describe('Logout', function () { |
224 | it('Should logout (revoke token)', async function () { | 220 | it('Should logout (revoke token)', async function () { |
225 | await logout(server.url, server.accessToken) | 221 | await server.loginCommand.logout({ token: server.accessToken }) |
226 | }) | 222 | }) |
227 | 223 | ||
228 | it('Should not be able to get the user information', async function () { | 224 | it('Should not be able to get the user information', async function () { |
@@ -250,9 +246,9 @@ describe('Test users', function () { | |||
250 | }) | 246 | }) |
251 | 247 | ||
252 | it('Should be able to login again', async function () { | 248 | it('Should be able to login again', async function () { |
253 | const res = await login(server.url, server.client, server.user) | 249 | const body = await server.loginCommand.login() |
254 | server.accessToken = res.body.access_token | 250 | server.accessToken = body.access_token |
255 | server.refreshToken = res.body.refresh_token | 251 | server.refreshToken = body.refresh_token |
256 | }) | 252 | }) |
257 | 253 | ||
258 | it('Should be able to get my user information again', async function () { | 254 | it('Should be able to get my user information again', async function () { |
@@ -268,11 +264,11 @@ describe('Test users', function () { | |||
268 | await killallServers([ server ]) | 264 | await killallServers([ server ]) |
269 | await reRunServer(server) | 265 | await reRunServer(server) |
270 | 266 | ||
271 | await getMyUserInformation(server.url, server.accessToken, 401) | 267 | await getMyUserInformation(server.url, server.accessToken, HttpStatusCode.UNAUTHORIZED_401) |
272 | }) | 268 | }) |
273 | 269 | ||
274 | it('Should not be able to refresh an access token with an expired refresh token', async function () { | 270 | it('Should not be able to refresh an access token with an expired refresh token', async function () { |
275 | await refreshToken(server, server.refreshToken, 400) | 271 | await server.loginCommand.refreshToken({ refreshToken: server.refreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
276 | }) | 272 | }) |
277 | 273 | ||
278 | it('Should refresh the token', async function () { | 274 | it('Should refresh the token', async function () { |
@@ -284,7 +280,7 @@ describe('Test users', function () { | |||
284 | await killallServers([ server ]) | 280 | await killallServers([ server ]) |
285 | await reRunServer(server) | 281 | await reRunServer(server) |
286 | 282 | ||
287 | const res = await refreshToken(server, server.refreshToken) | 283 | const res = await server.loginCommand.refreshToken({ refreshToken: server.refreshToken }) |
288 | server.accessToken = res.body.access_token | 284 | server.accessToken = res.body.access_token |
289 | server.refreshToken = res.body.refresh_token | 285 | server.refreshToken = res.body.refresh_token |
290 | }) | 286 | }) |
@@ -308,7 +304,7 @@ describe('Test users', function () { | |||
308 | }) | 304 | }) |
309 | 305 | ||
310 | it('Should be able to login with this user', async function () { | 306 | it('Should be able to login with this user', async function () { |
311 | accessTokenUser = await userLogin(server, user) | 307 | accessTokenUser = await server.loginCommand.getAccessToken(user) |
312 | }) | 308 | }) |
313 | 309 | ||
314 | it('Should be able to get user information', async function () { | 310 | it('Should be able to get user information', async function () { |
@@ -562,6 +558,7 @@ describe('Test users', function () { | |||
562 | }) | 558 | }) |
563 | 559 | ||
564 | describe('Update my account', function () { | 560 | describe('Update my account', function () { |
561 | |||
565 | it('Should update my password', async function () { | 562 | it('Should update my password', async function () { |
566 | await updateMyUser({ | 563 | await updateMyUser({ |
567 | url: server.url, | 564 | url: server.url, |
@@ -571,7 +568,7 @@ describe('Test users', function () { | |||
571 | }) | 568 | }) |
572 | user.password = 'new password' | 569 | user.password = 'new password' |
573 | 570 | ||
574 | await userLogin(server, user, HttpStatusCode.OK_200) | 571 | await server.loginCommand.login({ user }) |
575 | }) | 572 | }) |
576 | 573 | ||
577 | it('Should be able to change the NSFW display attribute', async function () { | 574 | it('Should be able to change the NSFW display attribute', async function () { |
@@ -781,7 +778,7 @@ describe('Test users', function () { | |||
781 | it('Should have removed the user token', async function () { | 778 | it('Should have removed the user token', async function () { |
782 | await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401) | 779 | await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401) |
783 | 780 | ||
784 | accessTokenUser = await userLogin(server, user) | 781 | accessTokenUser = await server.loginCommand.getAccessToken(user) |
785 | }) | 782 | }) |
786 | 783 | ||
787 | it('Should be able to update another user password', async function () { | 784 | it('Should be able to update another user password', async function () { |
@@ -794,10 +791,10 @@ describe('Test users', function () { | |||
794 | 791 | ||
795 | await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401) | 792 | await getMyUserVideoQuotaUsed(server.url, accessTokenUser, HttpStatusCode.UNAUTHORIZED_401) |
796 | 793 | ||
797 | await userLogin(server, user, HttpStatusCode.BAD_REQUEST_400) | 794 | await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
798 | 795 | ||
799 | user.password = 'password updated' | 796 | user.password = 'password updated' |
800 | accessTokenUser = await userLogin(server, user) | 797 | accessTokenUser = await server.loginCommand.getAccessToken(user) |
801 | }) | 798 | }) |
802 | }) | 799 | }) |
803 | 800 | ||
@@ -813,7 +810,7 @@ describe('Test users', function () { | |||
813 | }) | 810 | }) |
814 | 811 | ||
815 | it('Should not be able to login with this user', async function () { | 812 | it('Should not be able to login with this user', async function () { |
816 | await userLogin(server, user, HttpStatusCode.BAD_REQUEST_400) | 813 | await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
817 | }) | 814 | }) |
818 | 815 | ||
819 | it('Should not have videos of this user', async function () { | 816 | it('Should not have videos of this user', async function () { |
@@ -842,7 +839,7 @@ describe('Test users', function () { | |||
842 | password: 'my super password' | 839 | password: 'my super password' |
843 | } | 840 | } |
844 | 841 | ||
845 | user15AccessToken = await userLogin(server, user15) | 842 | user15AccessToken = await server.loginCommand.getAccessToken(user15) |
846 | }) | 843 | }) |
847 | 844 | ||
848 | it('Should have the correct display name', async function () { | 845 | it('Should have the correct display name', async function () { |
@@ -897,13 +894,13 @@ describe('Test users', function () { | |||
897 | }) | 894 | }) |
898 | user16Id = resUser.body.user.id | 895 | user16Id = resUser.body.user.id |
899 | 896 | ||
900 | user16AccessToken = await userLogin(server, user16) | 897 | user16AccessToken = await server.loginCommand.getAccessToken(user16) |
901 | 898 | ||
902 | await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200) | 899 | await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200) |
903 | await blockUser(server.url, user16Id, server.accessToken) | 900 | await blockUser(server.url, user16Id, server.accessToken) |
904 | 901 | ||
905 | await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.UNAUTHORIZED_401) | 902 | await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.UNAUTHORIZED_401) |
906 | await userLogin(server, user16, HttpStatusCode.BAD_REQUEST_400) | 903 | await server.loginCommand.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
907 | }) | 904 | }) |
908 | 905 | ||
909 | it('Should search user by banned status', async function () { | 906 | it('Should search user by banned status', async function () { |
@@ -930,7 +927,7 @@ describe('Test users', function () { | |||
930 | 927 | ||
931 | it('Should unblock a user', async function () { | 928 | it('Should unblock a user', async function () { |
932 | await unblockUser(server.url, user16Id, server.accessToken) | 929 | await unblockUser(server.url, user16Id, server.accessToken) |
933 | user16AccessToken = await userLogin(server, user16) | 930 | user16AccessToken = await server.loginCommand.getAccessToken(user16) |
934 | await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200) | 931 | await getMyUserInformation(server.url, user16AccessToken, HttpStatusCode.OK_200) |
935 | }) | 932 | }) |
936 | }) | 933 | }) |
@@ -952,7 +949,7 @@ describe('Test users', function () { | |||
952 | }) | 949 | }) |
953 | 950 | ||
954 | user17Id = resUser.body.user.id | 951 | user17Id = resUser.body.user.id |
955 | user17AccessToken = await userLogin(server, user17) | 952 | user17AccessToken = await server.loginCommand.getAccessToken(user17) |
956 | 953 | ||
957 | const res = await getUserInformation(server.url, server.accessToken, user17Id, true) | 954 | const res = await getUserInformation(server.url, server.accessToken, user17Id, true) |
958 | const user: User = res.body | 955 | const user: User = res.body |
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 () { |