diff options
author | buoyantair <buoyantair@protonmail.com> | 2018-11-18 21:55:52 +0530 |
---|---|---|
committer | buoyantair <buoyantair@protonmail.com> | 2018-11-18 21:55:52 +0530 |
commit | b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13 (patch) | |
tree | dcdf451ac431ec7953bee58e814f642d1c370d1b /server/tests | |
parent | 92e07c3b5d9dbf2febedb1b5b87ec676eb6d1ac8 (diff) | |
parent | 9d0b856e930ee1c676d16a56408a3e4a18f8f978 (diff) | |
download | PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.tar.gz PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.tar.zst PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.zip |
Merge branch 'develop' of https://github.com/Chocobozzz/PeerTube into move-utils-to-shared
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/user-subscriptions.ts | 6 | ||||
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 6 | ||||
-rw-r--r-- | server/tests/api/server/follow-constraints.ts | 215 | ||||
-rw-r--r-- | server/tests/api/server/index.ts | 1 |
4 files changed, 226 insertions, 2 deletions
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index 2cf5a2415..8a9ced7c1 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts | |||
@@ -14,11 +14,13 @@ import { | |||
14 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
15 | userLogin | 15 | userLogin |
16 | } from '../../../../shared/utils' | 16 | } from '../../../../shared/utils' |
17 | |||
17 | import { | 18 | import { |
18 | checkBadCountPagination, | 19 | checkBadCountPagination, |
19 | checkBadSortPagination, | 20 | checkBadSortPagination, |
20 | checkBadStartPagination | 21 | checkBadStartPagination |
21 | } from '../../../../shared/utils/requests/check-api-params' | 22 | } from '../../../../shared/utils/requests/check-api-params' |
23 | import { waitJobs } from '../../../../shared/utils/server/jobs' | ||
22 | 24 | ||
23 | describe('Test user subscriptions API validators', function () { | 25 | describe('Test user subscriptions API validators', function () { |
24 | const path = '/api/v1/users/me/subscriptions' | 26 | const path = '/api/v1/users/me/subscriptions' |
@@ -145,6 +147,8 @@ describe('Test user subscriptions API validators', function () { | |||
145 | }) | 147 | }) |
146 | 148 | ||
147 | it('Should succeed with the correct parameters', async function () { | 149 | it('Should succeed with the correct parameters', async function () { |
150 | this.timeout(20000) | ||
151 | |||
148 | await makePostBodyRequest({ | 152 | await makePostBodyRequest({ |
149 | url: server.url, | 153 | url: server.url, |
150 | path, | 154 | path, |
@@ -152,6 +156,8 @@ describe('Test user subscriptions API validators', function () { | |||
152 | fields: { uri: 'user1_channel@localhost:9001' }, | 156 | fields: { uri: 'user1_channel@localhost:9001' }, |
153 | statusCodeExpected: 204 | 157 | statusCodeExpected: 204 |
154 | }) | 158 | }) |
159 | |||
160 | await waitJobs([ server ]) | ||
155 | }) | 161 | }) |
156 | }) | 162 | }) |
157 | 163 | ||
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 663e31ead..2bc1b60ce 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -17,9 +17,10 @@ import { | |||
17 | viewVideo, | 17 | viewVideo, |
18 | wait, | 18 | wait, |
19 | waitUntilLog, | 19 | waitUntilLog, |
20 | checkVideoFilesWereRemoved, removeVideo | 20 | checkVideoFilesWereRemoved, removeVideo, getVideoWithToken |
21 | } from '../../../../shared/utils' | 21 | } from '../../../../shared/utils' |
22 | import { waitJobs } from '../../../../shared/utils/server/jobs' | 22 | import { waitJobs } from '../../../../shared/utils/server/jobs' |
23 | |||
23 | import * as magnetUtil from 'magnet-uri' | 24 | import * as magnetUtil from 'magnet-uri' |
24 | import { updateRedundancy } from '../../../../shared/utils/server/redundancy' | 25 | import { updateRedundancy } from '../../../../shared/utils/server/redundancy' |
25 | import { ActorFollow } from '../../../../shared/models/actors' | 26 | import { ActorFollow } from '../../../../shared/models/actors' |
@@ -93,7 +94,8 @@ async function check1WebSeed (strategy: VideoRedundancyStrategy, videoUUID?: str | |||
93 | 94 | ||
94 | for (const server of servers) { | 95 | for (const server of servers) { |
95 | { | 96 | { |
96 | const res = await getVideo(server.url, videoUUID) | 97 | // With token to avoid issues with video follow constraints |
98 | const res = await getVideoWithToken(server.url, server.accessToken, videoUUID) | ||
97 | 99 | ||
98 | const video: VideoDetails = res.body | 100 | const video: VideoDetails = res.body |
99 | for (const f of video.files) { | 101 | for (const f of video.files) { |
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts new file mode 100644 index 000000000..3135fc568 --- /dev/null +++ b/server/tests/api/server/follow-constraints.ts | |||
@@ -0,0 +1,215 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | ||
5 | import { doubleFollow, getAccountVideos, getVideo, getVideoChannelVideos, getVideoWithToken } from '../../utils' | ||
6 | import { flushAndRunMultipleServers, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index' | ||
7 | import { unfollow } from '../../utils/server/follows' | ||
8 | import { userLogin } from '../../utils/users/login' | ||
9 | import { createUser } from '../../utils/users/users' | ||
10 | |||
11 | const expect = chai.expect | ||
12 | |||
13 | describe('Test follow constraints', function () { | ||
14 | let servers: ServerInfo[] = [] | ||
15 | let video1UUID: string | ||
16 | let video2UUID: string | ||
17 | let userAccessToken: string | ||
18 | |||
19 | before(async function () { | ||
20 | this.timeout(30000) | ||
21 | |||
22 | servers = await flushAndRunMultipleServers(2) | ||
23 | |||
24 | // Get the access tokens | ||
25 | await setAccessTokensToServers(servers) | ||
26 | |||
27 | { | ||
28 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video server 1' }) | ||
29 | video1UUID = res.body.video.uuid | ||
30 | } | ||
31 | { | ||
32 | const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video server 2' }) | ||
33 | video2UUID = res.body.video.uuid | ||
34 | } | ||
35 | |||
36 | const user = { | ||
37 | username: 'user1', | ||
38 | password: 'super_password' | ||
39 | } | ||
40 | await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) | ||
41 | userAccessToken = await userLogin(servers[0], user) | ||
42 | |||
43 | await doubleFollow(servers[0], servers[1]) | ||
44 | }) | ||
45 | |||
46 | describe('With a followed instance', function () { | ||
47 | |||
48 | describe('With an unlogged user', function () { | ||
49 | |||
50 | it('Should get the local video', async function () { | ||
51 | await getVideo(servers[0].url, video1UUID, 200) | ||
52 | }) | ||
53 | |||
54 | it('Should get the remote video', async function () { | ||
55 | await getVideo(servers[0].url, video2UUID, 200) | ||
56 | }) | ||
57 | |||
58 | it('Should list local account videos', async function () { | ||
59 | const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9001', 0, 5) | ||
60 | |||
61 | expect(res.body.total).to.equal(1) | ||
62 | expect(res.body.data).to.have.lengthOf(1) | ||
63 | }) | ||
64 | |||
65 | it('Should list remote account videos', async function () { | ||
66 | const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9002', 0, 5) | ||
67 | |||
68 | expect(res.body.total).to.equal(1) | ||
69 | expect(res.body.data).to.have.lengthOf(1) | ||
70 | }) | ||
71 | |||
72 | it('Should list local channel videos', async function () { | ||
73 | const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9001', 0, 5) | ||
74 | |||
75 | expect(res.body.total).to.equal(1) | ||
76 | expect(res.body.data).to.have.lengthOf(1) | ||
77 | }) | ||
78 | |||
79 | it('Should list remote channel videos', async function () { | ||
80 | const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9002', 0, 5) | ||
81 | |||
82 | expect(res.body.total).to.equal(1) | ||
83 | expect(res.body.data).to.have.lengthOf(1) | ||
84 | }) | ||
85 | }) | ||
86 | |||
87 | describe('With a logged user', function () { | ||
88 | it('Should get the local video', async function () { | ||
89 | await getVideoWithToken(servers[0].url, userAccessToken, video1UUID, 200) | ||
90 | }) | ||
91 | |||
92 | it('Should get the remote video', async function () { | ||
93 | await getVideoWithToken(servers[0].url, userAccessToken, video2UUID, 200) | ||
94 | }) | ||
95 | |||
96 | it('Should list local account videos', async function () { | ||
97 | const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9001', 0, 5) | ||
98 | |||
99 | expect(res.body.total).to.equal(1) | ||
100 | expect(res.body.data).to.have.lengthOf(1) | ||
101 | }) | ||
102 | |||
103 | it('Should list remote account videos', async function () { | ||
104 | const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9002', 0, 5) | ||
105 | |||
106 | expect(res.body.total).to.equal(1) | ||
107 | expect(res.body.data).to.have.lengthOf(1) | ||
108 | }) | ||
109 | |||
110 | it('Should list local channel videos', async function () { | ||
111 | const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9001', 0, 5) | ||
112 | |||
113 | expect(res.body.total).to.equal(1) | ||
114 | expect(res.body.data).to.have.lengthOf(1) | ||
115 | }) | ||
116 | |||
117 | it('Should list remote channel videos', async function () { | ||
118 | const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9002', 0, 5) | ||
119 | |||
120 | expect(res.body.total).to.equal(1) | ||
121 | expect(res.body.data).to.have.lengthOf(1) | ||
122 | }) | ||
123 | }) | ||
124 | }) | ||
125 | |||
126 | describe('With a non followed instance', function () { | ||
127 | |||
128 | before(async function () { | ||
129 | this.timeout(30000) | ||
130 | |||
131 | await unfollow(servers[0].url, servers[0].accessToken, servers[1]) | ||
132 | }) | ||
133 | |||
134 | describe('With an unlogged user', function () { | ||
135 | |||
136 | it('Should get the local video', async function () { | ||
137 | await getVideo(servers[0].url, video1UUID, 200) | ||
138 | }) | ||
139 | |||
140 | it('Should not get the remote video', async function () { | ||
141 | await getVideo(servers[0].url, video2UUID, 403) | ||
142 | }) | ||
143 | |||
144 | it('Should list local account videos', async function () { | ||
145 | const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9001', 0, 5) | ||
146 | |||
147 | expect(res.body.total).to.equal(1) | ||
148 | expect(res.body.data).to.have.lengthOf(1) | ||
149 | }) | ||
150 | |||
151 | it('Should not list remote account videos', async function () { | ||
152 | const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9002', 0, 5) | ||
153 | |||
154 | expect(res.body.total).to.equal(0) | ||
155 | expect(res.body.data).to.have.lengthOf(0) | ||
156 | }) | ||
157 | |||
158 | it('Should list local channel videos', async function () { | ||
159 | const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9001', 0, 5) | ||
160 | |||
161 | expect(res.body.total).to.equal(1) | ||
162 | expect(res.body.data).to.have.lengthOf(1) | ||
163 | }) | ||
164 | |||
165 | it('Should not list remote channel videos', async function () { | ||
166 | const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9002', 0, 5) | ||
167 | |||
168 | expect(res.body.total).to.equal(0) | ||
169 | expect(res.body.data).to.have.lengthOf(0) | ||
170 | }) | ||
171 | }) | ||
172 | |||
173 | describe('With a logged user', function () { | ||
174 | it('Should get the local video', async function () { | ||
175 | await getVideoWithToken(servers[0].url, userAccessToken, video1UUID, 200) | ||
176 | }) | ||
177 | |||
178 | it('Should get the remote video', async function () { | ||
179 | await getVideoWithToken(servers[0].url, userAccessToken, video2UUID, 200) | ||
180 | }) | ||
181 | |||
182 | it('Should list local account videos', async function () { | ||
183 | const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9001', 0, 5) | ||
184 | |||
185 | expect(res.body.total).to.equal(1) | ||
186 | expect(res.body.data).to.have.lengthOf(1) | ||
187 | }) | ||
188 | |||
189 | it('Should list remote account videos', async function () { | ||
190 | const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9002', 0, 5) | ||
191 | |||
192 | expect(res.body.total).to.equal(1) | ||
193 | expect(res.body.data).to.have.lengthOf(1) | ||
194 | }) | ||
195 | |||
196 | it('Should list local channel videos', async function () { | ||
197 | const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9001', 0, 5) | ||
198 | |||
199 | expect(res.body.total).to.equal(1) | ||
200 | expect(res.body.data).to.have.lengthOf(1) | ||
201 | }) | ||
202 | |||
203 | it('Should list remote channel videos', async function () { | ||
204 | const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9002', 0, 5) | ||
205 | |||
206 | expect(res.body.total).to.equal(1) | ||
207 | expect(res.body.data).to.have.lengthOf(1) | ||
208 | }) | ||
209 | }) | ||
210 | }) | ||
211 | |||
212 | after(async function () { | ||
213 | killallServers(servers) | ||
214 | }) | ||
215 | }) | ||
diff --git a/server/tests/api/server/index.ts b/server/tests/api/server/index.ts index 78ab7e18b..6afcab1f9 100644 --- a/server/tests/api/server/index.ts +++ b/server/tests/api/server/index.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import './config' | 1 | import './config' |
2 | import './email' | 2 | import './email' |
3 | import './follow-constraints' | ||
3 | import './follows' | 4 | import './follows' |
4 | import './handle-down' | 5 | import './handle-down' |
5 | import './jobs' | 6 | import './jobs' |