diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-28 14:29:57 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-28 14:29:57 +0100 |
commit | eec63bbc0f4fdb39e56f37127b35c449f90a135f (patch) | |
tree | 2403f5efea3e281698ae4a6b550fea9dfc52e390 /server/tests/api | |
parent | c5d31dba56d669c0df0209761c43c5a6ac7cec4a (diff) | |
download | PeerTube-eec63bbc0f4fdb39e56f37127b35c449f90a135f.tar.gz PeerTube-eec63bbc0f4fdb39e56f37127b35c449f90a135f.tar.zst PeerTube-eec63bbc0f4fdb39e56f37127b35c449f90a135f.zip |
Improve check follow params tests
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/follows.ts | 196 | ||||
-rw-r--r-- | server/tests/api/check-params/jobs.ts | 4 | ||||
-rw-r--r-- | server/tests/api/check-params/users.ts | 10 | ||||
-rw-r--r-- | server/tests/api/check-params/video-abuses.ts | 4 | ||||
-rw-r--r-- | server/tests/api/check-params/video-blacklist.ts | 4 | ||||
-rw-r--r-- | server/tests/api/check-params/video-channels.ts | 4 | ||||
-rw-r--r-- | server/tests/api/check-params/videos.ts | 4 | ||||
-rw-r--r-- | server/tests/api/server/follows.ts | 4 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 6 | ||||
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 4 | ||||
-rw-r--r-- | server/tests/api/videos/video-privacy.ts | 4 |
11 files changed, 115 insertions, 129 deletions
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index cdd2783df..d5fcb7477 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts | |||
@@ -4,14 +4,10 @@ import 'mocha' | |||
4 | import * as request from 'supertest' | 4 | import * as request from 'supertest' |
5 | 5 | ||
6 | import { | 6 | import { |
7 | createUser, | 7 | createUser, flushTests, killallServers, makeDeleteRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers, |
8 | flushTests, | 8 | userLogin |
9 | killallServers, | ||
10 | loginAndGetAccessToken, | ||
11 | runServer, | ||
12 | ServerInfo, | ||
13 | setAccessTokensToServers | ||
14 | } from '../../utils' | 9 | } from '../../utils' |
10 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' | ||
15 | 11 | ||
16 | describe('Test server follows API validators', function () { | 12 | describe('Test server follows API validators', function () { |
17 | let server: ServerInfo | 13 | let server: ServerInfo |
@@ -19,7 +15,7 @@ describe('Test server follows API validators', function () { | |||
19 | // --------------------------------------------------------------- | 15 | // --------------------------------------------------------------- |
20 | 16 | ||
21 | before(async function () { | 17 | before(async function () { |
22 | this.timeout(45000) | 18 | this.timeout(20000) |
23 | 19 | ||
24 | await flushTests() | 20 | await flushTests() |
25 | server = await runServer(1) | 21 | server = await runServer(1) |
@@ -31,81 +27,85 @@ describe('Test server follows API validators', function () { | |||
31 | let userAccessToken = null | 27 | let userAccessToken = null |
32 | 28 | ||
33 | before(async function () { | 29 | before(async function () { |
34 | await createUser(server.url, server.accessToken, 'user1', 'password') | 30 | const user = { |
35 | server.user = { | ||
36 | username: 'user1', | 31 | username: 'user1', |
37 | password: 'password' | 32 | password: 'password' |
38 | } | 33 | } |
39 | 34 | ||
40 | userAccessToken = await loginAndGetAccessToken(server) | 35 | await createUser(server.url, server.accessToken, user.username, user.password) |
36 | userAccessToken = await userLogin(server, user) | ||
41 | }) | 37 | }) |
42 | 38 | ||
43 | describe('When adding follows', function () { | 39 | describe('When adding follows', function () { |
44 | const path = '/api/v1/server/following' | 40 | const path = '/api/v1/server/following' |
45 | const body = { | ||
46 | hosts: [ 'localhost:9002' ] | ||
47 | } | ||
48 | 41 | ||
49 | it('Should fail without hosts', async function () { | 42 | it('Should fail without hosts', async function () { |
50 | await request(server.url) | 43 | await makePostBodyRequest({ |
51 | .post(path) | 44 | url: server.url, |
52 | .set('Authorization', 'Bearer ' + server.accessToken) | 45 | path, |
53 | .set('Accept', 'application/json') | 46 | token: server.accessToken, |
54 | .expect(400) | 47 | statusCodeExpected: 400 |
48 | }) | ||
55 | }) | 49 | }) |
56 | 50 | ||
57 | it('Should fail if hosts is not an array', async function () { | 51 | it('Should fail if hosts is not an array', async function () { |
58 | await request(server.url) | 52 | await makePostBodyRequest({ |
59 | .post(path) | 53 | url: server.url, |
60 | .send({ hosts: 'localhost:9002' }) | 54 | path, |
61 | .set('Authorization', 'Bearer ' + server.accessToken) | 55 | token: server.accessToken, |
62 | .set('Accept', 'application/json') | 56 | fields: { hosts: 'localhost:9002' }, |
63 | .expect(400) | 57 | statusCodeExpected: 400 |
58 | }) | ||
64 | }) | 59 | }) |
65 | 60 | ||
66 | it('Should fail if the array is not composed by hosts', async function () { | 61 | it('Should fail if the array is not composed by hosts', async function () { |
67 | await request(server.url) | 62 | await makePostBodyRequest({ |
68 | .post(path) | 63 | url: server.url, |
69 | .send({ hosts: [ 'localhost:9002', 'localhost:coucou' ] }) | 64 | path, |
70 | .set('Authorization', 'Bearer ' + server.accessToken) | 65 | fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, |
71 | .set('Accept', 'application/json') | 66 | token: server.accessToken, |
72 | .expect(400) | 67 | statusCodeExpected: 400 |
68 | }) | ||
73 | }) | 69 | }) |
74 | 70 | ||
75 | it('Should fail if the array is composed with http schemes', async function () { | 71 | it('Should fail if the array is composed with http schemes', async function () { |
76 | await request(server.url) | 72 | await makePostBodyRequest({ |
77 | .post(path) | 73 | url: server.url, |
78 | .send({ hosts: [ 'localhost:9002', 'http://localhost:9003' ] }) | 74 | path, |
79 | .set('Authorization', 'Bearer ' + server.accessToken) | 75 | fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, |
80 | .set('Accept', 'application/json') | 76 | token: server.accessToken, |
81 | .expect(400) | 77 | statusCodeExpected: 400 |
78 | }) | ||
82 | }) | 79 | }) |
83 | 80 | ||
84 | it('Should fail if hosts are not unique', async function () { | 81 | it('Should fail if hosts are not unique', async function () { |
85 | await request(server.url) | 82 | await makePostBodyRequest({ |
86 | .post(path) | 83 | url: server.url, |
87 | .send({ urls: [ 'localhost:9002', 'localhost:9002' ] }) | 84 | path, |
88 | .set('Authorization', 'Bearer ' + server.accessToken) | 85 | fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, |
89 | .set('Accept', 'application/json') | 86 | token: server.accessToken, |
90 | .expect(400) | 87 | statusCodeExpected: 400 |
88 | }) | ||
91 | }) | 89 | }) |
92 | 90 | ||
93 | it('Should fail with an invalid token', async function () { | 91 | it('Should fail with an invalid token', async function () { |
94 | await request(server.url) | 92 | await makePostBodyRequest({ |
95 | .post(path) | 93 | url: server.url, |
96 | .send(body) | 94 | path, |
97 | .set('Authorization', 'Bearer fake_token') | 95 | fields: { hosts: [ 'localhost:9002' ] }, |
98 | .set('Accept', 'application/json') | 96 | token: 'fake_token', |
99 | .expect(401) | 97 | statusCodeExpected: 401 |
98 | }) | ||
100 | }) | 99 | }) |
101 | 100 | ||
102 | it('Should fail if the user is not an administrator', async function () { | 101 | it('Should fail if the user is not an administrator', async function () { |
103 | await request(server.url) | 102 | await makePostBodyRequest({ |
104 | .post(path) | 103 | url: server.url, |
105 | .send(body) | 104 | path, |
106 | .set('Authorization', 'Bearer ' + userAccessToken) | 105 | fields: { hosts: [ 'localhost:9002' ] }, |
107 | .set('Accept', 'application/json') | 106 | token: userAccessToken, |
108 | .expect(403) | 107 | statusCodeExpected: 403 |
108 | }) | ||
109 | }) | 109 | }) |
110 | }) | 110 | }) |
111 | 111 | ||
@@ -113,27 +113,15 @@ describe('Test server follows API validators', function () { | |||
113 | const path = '/api/v1/server/following' | 113 | const path = '/api/v1/server/following' |
114 | 114 | ||
115 | it('Should fail with a bad start pagination', async function () { | 115 | it('Should fail with a bad start pagination', async function () { |
116 | await request(server.url) | 116 | await checkBadStartPagination(server.url, path) |
117 | .get(path) | ||
118 | .query({ start: 'hello' }) | ||
119 | .set('Accept', 'application/json') | ||
120 | .expect(400) | ||
121 | }) | 117 | }) |
122 | 118 | ||
123 | it('Should fail with a bad count pagination', async function () { | 119 | it('Should fail with a bad count pagination', async function () { |
124 | await request(server.url) | 120 | await checkBadCountPagination(server.url, path) |
125 | .get(path) | ||
126 | .query({ count: 'hello' }) | ||
127 | .set('Accept', 'application/json') | ||
128 | .expect(400) | ||
129 | }) | 121 | }) |
130 | 122 | ||
131 | it('Should fail with an incorrect sort', async function () { | 123 | it('Should fail with an incorrect sort', async function () { |
132 | await request(server.url) | 124 | await checkBadSortPagination(server.url, path) |
133 | .get(path) | ||
134 | .query({ sort: 'hello' }) | ||
135 | .set('Accept', 'application/json') | ||
136 | .expect(400) | ||
137 | }) | 125 | }) |
138 | }) | 126 | }) |
139 | 127 | ||
@@ -141,27 +129,15 @@ describe('Test server follows API validators', function () { | |||
141 | const path = '/api/v1/server/followers' | 129 | const path = '/api/v1/server/followers' |
142 | 130 | ||
143 | it('Should fail with a bad start pagination', async function () { | 131 | it('Should fail with a bad start pagination', async function () { |
144 | await request(server.url) | 132 | await checkBadStartPagination(server.url, path) |
145 | .get(path) | ||
146 | .query({ start: 'hello' }) | ||
147 | .set('Accept', 'application/json') | ||
148 | .expect(400) | ||
149 | }) | 133 | }) |
150 | 134 | ||
151 | it('Should fail with a bad count pagination', async function () { | 135 | it('Should fail with a bad count pagination', async function () { |
152 | await request(server.url) | 136 | await checkBadCountPagination(server.url, path) |
153 | .get(path) | ||
154 | .query({ count: 'hello' }) | ||
155 | .set('Accept', 'application/json') | ||
156 | .expect(400) | ||
157 | }) | 137 | }) |
158 | 138 | ||
159 | it('Should fail with an incorrect sort', async function () { | 139 | it('Should fail with an incorrect sort', async function () { |
160 | await request(server.url) | 140 | await checkBadSortPagination(server.url, path) |
161 | .get(path) | ||
162 | .query({ sort: 'hello' }) | ||
163 | .set('Accept', 'application/json') | ||
164 | .expect(400) | ||
165 | }) | 141 | }) |
166 | }) | 142 | }) |
167 | 143 | ||
@@ -169,30 +145,40 @@ describe('Test server follows API validators', function () { | |||
169 | const path = '/api/v1/server/following' | 145 | const path = '/api/v1/server/following' |
170 | 146 | ||
171 | it('Should fail with an invalid token', async function () { | 147 | it('Should fail with an invalid token', async function () { |
172 | await request(server.url) | 148 | await makeDeleteRequest({ |
173 | .delete(path + '/1') | 149 | url: server.url, |
174 | .set('Authorization', 'Bearer faketoken') | 150 | path: path + '/localhost:9002', |
175 | .set('Accept', 'application/json') | 151 | token: 'fake_token', |
176 | .expect(401) | 152 | statusCodeExpected: 401 |
153 | }) | ||
177 | }) | 154 | }) |
178 | 155 | ||
179 | it('Should fail if the user is not an administrator', async function () { | 156 | it('Should fail if the user is not an administrator', async function () { |
180 | await request(server.url) | 157 | await makeDeleteRequest({ |
181 | .delete(path + '/1') | 158 | url: server.url, |
182 | .set('Authorization', 'Bearer ' + userAccessToken) | 159 | path: path + '/localhost:9002', |
183 | .set('Accept', 'application/json') | 160 | token: userAccessToken, |
184 | .expect(403) | 161 | statusCodeExpected: 403 |
185 | }) | 162 | }) |
186 | 163 | }) | |
187 | it('Should fail we do not follow this server', async function () { | 164 | |
188 | await request(server.url) | 165 | it('Should fail if we do not follow this server', async function () { |
189 | .delete(path + '/example.com') | 166 | await makeDeleteRequest({ |
190 | .set('Authorization', 'Bearer ' + server.accessToken) | 167 | url: server.url, |
191 | .set('Accept', 'application/json') | 168 | path: path + '/example.com', |
192 | .expect(404) | 169 | token: server.accessToken, |
170 | statusCodeExpected: 404 | ||
171 | }) | ||
172 | }) | ||
173 | |||
174 | it('Should succeed with the correct parameters', async function () { | ||
175 | await makeDeleteRequest({ | ||
176 | url: server.url, | ||
177 | path: path + '/localhost:9002', | ||
178 | token: server.accessToken, | ||
179 | statusCodeExpected: 404 | ||
180 | }) | ||
193 | }) | 181 | }) |
194 | |||
195 | it('Should succeed with the correct parameters') | ||
196 | }) | 182 | }) |
197 | }) | 183 | }) |
198 | 184 | ||
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts index 7a0dd6e8c..3795d1d64 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/server/tests/api/check-params/jobs.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as request from 'supertest' | 4 | import * as request from 'supertest' |
5 | 5 | ||
6 | import { createUser, flushTests, getUserAccessToken, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../utils' | 6 | import { createUser, flushTests, userLogin, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../utils' |
7 | 7 | ||
8 | describe('Test jobs API validators', function () { | 8 | describe('Test jobs API validators', function () { |
9 | const path = '/api/v1/jobs/' | 9 | const path = '/api/v1/jobs/' |
@@ -26,7 +26,7 @@ describe('Test jobs API validators', function () { | |||
26 | password: 'my super password' | 26 | password: 'my super password' |
27 | } | 27 | } |
28 | await createUser(server.url, server.accessToken, user.username, user.password) | 28 | await createUser(server.url, server.accessToken, user.username, user.password) |
29 | userAccessToken = await getUserAccessToken(server, user) | 29 | userAccessToken = await userLogin(server, user) |
30 | }) | 30 | }) |
31 | 31 | ||
32 | describe('When listing jobs', function () { | 32 | describe('When listing jobs', function () { |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 72488e5c4..b566a2f1e 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -11,13 +11,13 @@ import { | |||
11 | getVideosList, | 11 | getVideosList, |
12 | makePutBodyRequest, | 12 | makePutBodyRequest, |
13 | createUser, | 13 | createUser, |
14 | loginAndGetAccessToken, | 14 | serverLogin, |
15 | getUsersList, | 15 | getUsersList, |
16 | registerUser, | 16 | registerUser, |
17 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
18 | killallServers, | 18 | killallServers, |
19 | makePostBodyRequest, | 19 | makePostBodyRequest, |
20 | getUserAccessToken | 20 | userLogin |
21 | } from '../../utils' | 21 | } from '../../utils' |
22 | import { UserRole } from '../../../../shared' | 22 | import { UserRole } from '../../../../shared' |
23 | 23 | ||
@@ -58,7 +58,7 @@ describe('Test users API validators', function () { | |||
58 | username: 'user1', | 58 | username: 'user1', |
59 | password: 'my super password' | 59 | password: 'my super password' |
60 | } | 60 | } |
61 | userAccessToken = await getUserAccessToken(server, user) | 61 | userAccessToken = await userLogin(server, user) |
62 | }) | 62 | }) |
63 | 63 | ||
64 | describe('When listing users', function () { | 64 | describe('When listing users', function () { |
@@ -304,7 +304,7 @@ describe('Test users API validators', function () { | |||
304 | password: 'my super password' | 304 | password: 'my super password' |
305 | } | 305 | } |
306 | 306 | ||
307 | userAccessToken = await loginAndGetAccessToken(server) | 307 | userAccessToken = await serverLogin(server) |
308 | const fields = { | 308 | const fields = { |
309 | username: 'user3', | 309 | username: 'user3', |
310 | email: 'test@example.com', | 310 | email: 'test@example.com', |
@@ -675,7 +675,7 @@ describe('Test users API validators', function () { | |||
675 | email: 'test3@example.com', | 675 | email: 'test3@example.com', |
676 | password: 'my super password' | 676 | password: 'my super password' |
677 | } | 677 | } |
678 | userAccessToken = await loginAndGetAccessToken(server) | 678 | userAccessToken = await serverLogin(server) |
679 | 679 | ||
680 | const videoAttributes = { fixture: 'video_short2.webm' } | 680 | const videoAttributes = { fixture: 'video_short2.webm' } |
681 | await uploadVideo(server.url, userAccessToken, videoAttributes) | 681 | await uploadVideo(server.url, userAccessToken, videoAttributes) |
diff --git a/server/tests/api/check-params/video-abuses.ts b/server/tests/api/check-params/video-abuses.ts index eac12b6f0..e994ccd49 100644 --- a/server/tests/api/check-params/video-abuses.ts +++ b/server/tests/api/check-params/video-abuses.ts | |||
@@ -13,7 +13,7 @@ import { | |||
13 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
14 | killallServers, | 14 | killallServers, |
15 | makePostBodyRequest, | 15 | makePostBodyRequest, |
16 | getUserAccessToken | 16 | userLogin |
17 | } from '../../utils' | 17 | } from '../../utils' |
18 | 18 | ||
19 | describe('Test video abuses API validators', function () { | 19 | describe('Test video abuses API validators', function () { |
@@ -35,7 +35,7 @@ describe('Test video abuses API validators', function () { | |||
35 | const password = 'my super password' | 35 | const password = 'my super password' |
36 | await createUser(server.url, server.accessToken, username, password) | 36 | await createUser(server.url, server.accessToken, username, password) |
37 | 37 | ||
38 | userAccessToken = await getUserAccessToken(server, { username, password }) | 38 | userAccessToken = await userLogin(server, { username, password }) |
39 | 39 | ||
40 | // Upload a video | 40 | // Upload a video |
41 | const videoAttributes = {} | 41 | const videoAttributes = {} |
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index eb16b3af0..c8b457182 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts | |||
@@ -13,7 +13,7 @@ import { | |||
13 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
14 | killallServers, | 14 | killallServers, |
15 | makePostBodyRequest, | 15 | makePostBodyRequest, |
16 | getUserAccessToken | 16 | userLogin |
17 | } from '../../utils' | 17 | } from '../../utils' |
18 | 18 | ||
19 | describe('Test video blacklist API validators', function () { | 19 | describe('Test video blacklist API validators', function () { |
@@ -34,7 +34,7 @@ describe('Test video blacklist API validators', function () { | |||
34 | const username = 'user1' | 34 | const username = 'user1' |
35 | const password = 'my super password' | 35 | const password = 'my super password' |
36 | await createUser(server.url, server.accessToken, username, password) | 36 | await createUser(server.url, server.accessToken, username, password) |
37 | userAccessToken = await getUserAccessToken(server, { username, password }) | 37 | userAccessToken = await userLogin(server, { username, password }) |
38 | 38 | ||
39 | // Upload a video | 39 | // Upload a video |
40 | const videoAttributes = {} | 40 | const videoAttributes = {} |
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index 7103aec25..bf464152b 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts | |||
@@ -15,7 +15,7 @@ import { | |||
15 | makePostBodyRequest, | 15 | makePostBodyRequest, |
16 | getVideoChannelsList, | 16 | getVideoChannelsList, |
17 | createUser, | 17 | createUser, |
18 | getUserAccessToken | 18 | userLogin |
19 | } from '../../utils' | 19 | } from '../../utils' |
20 | 20 | ||
21 | describe('Test videos API validator', function () { | 21 | describe('Test videos API validator', function () { |
@@ -40,7 +40,7 @@ describe('Test videos API validator', function () { | |||
40 | } | 40 | } |
41 | await createUser(server.url, server.accessToken, user.username, user.password) | 41 | await createUser(server.url, server.accessToken, user.username, user.password) |
42 | 42 | ||
43 | accessTokenUser = await getUserAccessToken(server, user) | 43 | accessTokenUser = await userLogin(server, user) |
44 | }) | 44 | }) |
45 | 45 | ||
46 | describe('When listing a video channels', function () { | 46 | describe('When listing a video channels', function () { |
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 0aaa6e7c9..b0c850f0c 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -17,7 +17,7 @@ import { | |||
17 | makePostUploadRequest, | 17 | makePostUploadRequest, |
18 | getMyUserInformation, | 18 | getMyUserInformation, |
19 | createUser, | 19 | createUser, |
20 | getUserAccessToken | 20 | userLogin |
21 | } from '../../utils' | 21 | } from '../../utils' |
22 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | 22 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' |
23 | 23 | ||
@@ -260,7 +260,7 @@ describe('Test videos API validator', function () { | |||
260 | } | 260 | } |
261 | await createUser(server.url, server.accessToken, user.username, user.password) | 261 | await createUser(server.url, server.accessToken, user.username, user.password) |
262 | 262 | ||
263 | const accessTokenUser = await getUserAccessToken(server, user) | 263 | const accessTokenUser = await userLogin(server, user) |
264 | const res = await getMyUserInformation(server.url, accessTokenUser) | 264 | const res = await getMyUserInformation(server.url, accessTokenUser) |
265 | const customChannelId = res.body.videoChannels[0].id | 265 | const customChannelId = res.body.videoChannels[0].id |
266 | 266 | ||
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index f77c0c67c..6c815ace8 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | } from '../../utils/index' | 10 | } from '../../utils/index' |
11 | import { dateIsValid, webtorrentAdd } from '../../utils/miscs/miscs' | 11 | import { dateIsValid, webtorrentAdd } from '../../utils/miscs/miscs' |
12 | import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows' | 12 | import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows' |
13 | import { getUserAccessToken } from '../../utils/users/login' | 13 | import { userLogin } from '../../utils/users/login' |
14 | import { createUser } from '../../utils/users/users' | 14 | import { createUser } from '../../utils/users/users' |
15 | import { | 15 | import { |
16 | addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, | 16 | addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, |
@@ -183,7 +183,7 @@ describe('Test follows', function () { | |||
183 | { | 183 | { |
184 | const user = { username: 'captain', password: 'password' } | 184 | const user = { username: 'captain', password: 'password' } |
185 | await createUser(servers[2].url, servers[2].accessToken, user.username, user.password) | 185 | await createUser(servers[2].url, servers[2].accessToken, user.username, user.password) |
186 | const userAccessToken = await getUserAccessToken(servers[2], user) | 186 | const userAccessToken = await userLogin(servers[2], user) |
187 | 187 | ||
188 | const resVideos = await getVideosList(servers[ 2 ].url) | 188 | const resVideos = await getVideosList(servers[ 2 ].url) |
189 | const video4 = resVideos.body.data.find(v => v.name === 'server3-4') | 189 | const video4 = resVideos.body.data.find(v => v.name === 'server3-4') |
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 2e3a0b94f..298dbce2c 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -15,7 +15,7 @@ import { | |||
15 | getVideosList, | 15 | getVideosList, |
16 | killallServers, | 16 | killallServers, |
17 | login, | 17 | login, |
18 | loginAndGetAccessToken, | 18 | serverLogin, |
19 | makePutBodyRequest, | 19 | makePutBodyRequest, |
20 | rateVideo, | 20 | rateVideo, |
21 | registerUser, | 21 | registerUser, |
@@ -193,7 +193,7 @@ describe('Test users', function () { | |||
193 | password: 'super password' | 193 | password: 'super password' |
194 | } | 194 | } |
195 | 195 | ||
196 | accessTokenUser = await loginAndGetAccessToken(server) | 196 | accessTokenUser = await serverLogin(server) |
197 | }) | 197 | }) |
198 | 198 | ||
199 | it('Should be able to get the user information', async function () { | 199 | it('Should be able to get the user information', async function () { |
@@ -511,7 +511,7 @@ describe('Test users', function () { | |||
511 | password: 'my super password' | 511 | password: 'my super password' |
512 | } | 512 | } |
513 | 513 | ||
514 | accessToken = await loginAndGetAccessToken(server) | 514 | accessToken = await serverLogin(server) |
515 | }) | 515 | }) |
516 | 516 | ||
517 | it('Should have the correct video quota', async function () { | 517 | it('Should have the correct video quota', async function () { |
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 84f730a8e..0c6508e71 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -7,7 +7,7 @@ import * as request from 'supertest' | |||
7 | import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' | 7 | import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' |
8 | 8 | ||
9 | import { | 9 | import { |
10 | addVideoChannel, dateIsValid, doubleFollow, flushAndRunMultipleServers, flushTests, getUserAccessToken, getVideo, | 10 | addVideoChannel, dateIsValid, doubleFollow, flushAndRunMultipleServers, flushTests, userLogin, getVideo, |
11 | getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testVideoImage, | 11 | getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testVideoImage, |
12 | updateVideo, uploadVideo, wait, webtorrentAdd | 12 | updateVideo, uploadVideo, wait, webtorrentAdd |
13 | } from '../../utils/index' | 13 | } from '../../utils/index' |
@@ -152,7 +152,7 @@ describe('Test multiple servers', function () { | |||
152 | password: 'super_password' | 152 | password: 'super_password' |
153 | } | 153 | } |
154 | await createUser(servers[1].url, servers[1].accessToken, user.username, user.password) | 154 | await createUser(servers[1].url, servers[1].accessToken, user.username, user.password) |
155 | const userAccessToken = await getUserAccessToken(servers[1], user) | 155 | const userAccessToken = await userLogin(servers[1], user) |
156 | 156 | ||
157 | const videoAttributes = { | 157 | const videoAttributes = { |
158 | name: 'my super name for server 2', | 158 | name: 'my super name for server 2', |
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index de709f8f1..469274921 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts | |||
@@ -14,7 +14,7 @@ import { | |||
14 | wait | 14 | wait |
15 | } from '../../utils/index' | 15 | } from '../../utils/index' |
16 | import { doubleFollow } from '../../utils/server/follows' | 16 | import { doubleFollow } from '../../utils/server/follows' |
17 | import { getUserAccessToken } from '../../utils/users/login' | 17 | import { userLogin } from '../../utils/users/login' |
18 | import { createUser } from '../../utils/users/users' | 18 | import { createUser } from '../../utils/users/users' |
19 | import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../utils/videos/videos' | 19 | import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../utils/videos/videos' |
20 | 20 | ||
@@ -78,7 +78,7 @@ describe('Test video privacy', function () { | |||
78 | } | 78 | } |
79 | await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) | 79 | await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) |
80 | 80 | ||
81 | const token = await getUserAccessToken(servers[0], user) | 81 | const token = await userLogin(servers[0], user) |
82 | await getVideoWithToken(servers[0].url, token, privateVideoUUID, 403) | 82 | await getVideoWithToken(servers[0].url, token, privateVideoUUID, 403) |
83 | }) | 83 | }) |
84 | 84 | ||