]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
fe3a55b0 | 2 | |
479b2696 | 3 | import * as chai from 'chai' |
2d28b0c2 | 4 | import { XMLParser, XMLValidator } from 'fast-xml-parser' |
d0800f76 | 5 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' |
696d83fd | 6 | import { |
7c3b7976 | 7 | cleanupTests, |
254d3579 C |
8 | createMultipleServers, |
9 | createSingleServer, | |
4c7e60bc | 10 | doubleFollow, |
20bafcb6 | 11 | makeGetRequest, |
254d3579 | 12 | PeerTubeServer, |
fe3a55b0 | 13 | setAccessTokensToServers, |
d0800f76 | 14 | setDefaultChannelAvatar, |
7a5c3d77 | 15 | stopFfmpeg, |
5f8bd4cb | 16 | waitJobs |
bf54587a | 17 | } from '@shared/server-commands' |
fe3a55b0 C |
18 | |
19 | chai.use(require('chai-xml')) | |
20 | chai.use(require('chai-json-schema')) | |
21 | chai.config.includeStack = true | |
479b2696 | 22 | |
fe3a55b0 | 23 | describe('Test syndication feeds', () => { |
254d3579 C |
24 | let servers: PeerTubeServer[] = [] |
25 | let serverHLSOnly: PeerTubeServer | |
662fb3ab | 26 | let userAccessToken: string |
57cfff78 C |
27 | let rootAccountId: number |
28 | let rootChannelId: number | |
29 | let userAccountId: number | |
30 | let userChannelId: number | |
afff310e | 31 | let userFeedToken: string |
7a5c3d77 | 32 | let liveId: string |
fe3a55b0 C |
33 | |
34 | before(async function () { | |
35 | this.timeout(120000) | |
36 | ||
37 | // Run servers | |
254d3579 C |
38 | servers = await createMultipleServers(2) |
39 | serverHLSOnly = await createSingleServer(3, { | |
97816649 C |
40 | transcoding: { |
41 | enabled: true, | |
42 | webtorrent: { enabled: false }, | |
43 | hls: { enabled: true } | |
44 | } | |
45 | }) | |
fe3a55b0 | 46 | |
97816649 | 47 | await setAccessTokensToServers([ ...servers, serverHLSOnly ]) |
d0800f76 | 48 | await setDefaultChannelAvatar(servers[0]) |
fe3a55b0 C |
49 | await doubleFollow(servers[0], servers[1]) |
50 | ||
7a5c3d77 C |
51 | await servers[0].config.enableLive({ allowReplay: false, transcoding: false }) |
52 | ||
662fb3ab | 53 | { |
89d241a7 | 54 | const user = await servers[0].users.getMyInfo() |
57cfff78 C |
55 | rootAccountId = user.account.id |
56 | rootChannelId = user.videoChannels[0].id | |
fe3a55b0 | 57 | } |
fe3a55b0 | 58 | |
662fb3ab | 59 | { |
20bafcb6 | 60 | userAccessToken = await servers[0].users.generateUserAndToken('john') |
662fb3ab | 61 | |
89d241a7 | 62 | const user = await servers[0].users.getMyInfo({ token: userAccessToken }) |
57cfff78 C |
63 | userAccountId = user.account.id |
64 | userChannelId = user.videoChannels[0].id | |
afff310e | 65 | |
89d241a7 | 66 | const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken }) |
afff310e | 67 | userFeedToken = token.feedToken |
662fb3ab C |
68 | } |
69 | ||
70 | { | |
89d241a7 | 71 | await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'user video' } }) |
662fb3ab C |
72 | } |
73 | ||
74 | { | |
d23dd9fb | 75 | const attributes = { |
662fb3ab C |
76 | name: 'my super name for server 1', |
77 | description: 'my super description for server 1', | |
78 | fixture: 'video_short.webm' | |
79 | } | |
89d241a7 | 80 | const { id } = await servers[0].videos.upload({ attributes }) |
662fb3ab | 81 | |
89d241a7 C |
82 | await servers[0].comments.createThread({ videoId: id, text: 'super comment 1' }) |
83 | await servers[0].comments.createThread({ videoId: id, text: 'super comment 2' }) | |
662fb3ab | 84 | } |
fe3a55b0 | 85 | |
68b6fd21 | 86 | { |
d23dd9fb | 87 | const attributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED } |
89d241a7 | 88 | const { id } = await servers[0].videos.upload({ attributes }) |
68b6fd21 | 89 | |
89d241a7 | 90 | await servers[0].comments.createThread({ videoId: id, text: 'comment on unlisted video' }) |
68b6fd21 C |
91 | } |
92 | ||
3cd0734f | 93 | await waitJobs(servers) |
fe3a55b0 C |
94 | }) |
95 | ||
96 | describe('All feed', function () { | |
97 | ||
98 | it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () { | |
99 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { | |
41e74ec9 | 100 | const rss = await servers[0].feed.getXML({ feed, ignoreCache: true }) |
c1bc8ee4 | 101 | expect(rss).xml.to.be.valid() |
fe3a55b0 | 102 | |
41e74ec9 | 103 | const atom = await servers[0].feed.getXML({ feed, format: 'atom', ignoreCache: true }) |
c1bc8ee4 | 104 | expect(atom).xml.to.be.valid() |
fe3a55b0 C |
105 | } |
106 | }) | |
107 | ||
108 | it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () { | |
109 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { | |
41e74ec9 | 110 | const jsonText = await servers[0].feed.getJSON({ feed, ignoreCache: true }) |
c1bc8ee4 | 111 | expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' }) |
fe3a55b0 C |
112 | } |
113 | }) | |
20bafcb6 C |
114 | |
115 | it('Should serve the endpoint with a classic request', async function () { | |
116 | await makeGetRequest({ | |
117 | url: servers[0].url, | |
118 | path: '/feeds/videos.xml', | |
119 | accept: 'application/xml', | |
120 | expectedStatus: HttpStatusCode.OK_200 | |
121 | }) | |
122 | }) | |
123 | ||
124 | it('Should serve the endpoint as a cached request', async function () { | |
125 | const res = await makeGetRequest({ | |
126 | url: servers[0].url, | |
127 | path: '/feeds/videos.xml', | |
128 | accept: 'application/xml', | |
129 | expectedStatus: HttpStatusCode.OK_200 | |
130 | }) | |
131 | ||
132 | expect(res.headers['x-api-cache-cached']).to.equal('true') | |
133 | }) | |
134 | ||
135 | it('Should not serve the endpoint as a cached request', async function () { | |
136 | const res = await makeGetRequest({ | |
137 | url: servers[0].url, | |
138 | path: '/feeds/videos.xml?v=186', | |
139 | accept: 'application/xml', | |
140 | expectedStatus: HttpStatusCode.OK_200 | |
141 | }) | |
142 | ||
143 | expect(res.headers['x-api-cache-cached']).to.not.exist | |
144 | }) | |
145 | ||
146 | it('Should refuse to serve the endpoint without accept header', async function () { | |
147 | await makeGetRequest({ url: servers[0].url, path: '/feeds/videos.xml', expectedStatus: HttpStatusCode.NOT_ACCEPTABLE_406 }) | |
148 | }) | |
fe3a55b0 C |
149 | }) |
150 | ||
151 | describe('Videos feed', function () { | |
97816649 | 152 | |
fe3a55b0 C |
153 | it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () { |
154 | for (const server of servers) { | |
41e74ec9 | 155 | const rss = await server.feed.getXML({ feed: 'videos', ignoreCache: true }) |
2d28b0c2 | 156 | expect(XMLValidator.validate(rss)).to.be.true |
b70025bf | 157 | |
2d28b0c2 C |
158 | const parser = new XMLParser({ parseAttributeValue: true, ignoreAttributes: false }) |
159 | const xmlDoc = parser.parse(rss) | |
b70025bf C |
160 | |
161 | const enclosure = xmlDoc.rss.channel.item[0].enclosure | |
162 | expect(enclosure).to.exist | |
4393b255 C |
163 | |
164 | expect(enclosure['@_type']).to.equal('video/webm') | |
b70025bf | 165 | expect(enclosure['@_length']).to.equal(218910) |
4393b255 | 166 | expect(enclosure['@_url']).to.contain('-720.webm') |
fe3a55b0 C |
167 | } |
168 | }) | |
169 | ||
170 | it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', async function () { | |
171 | for (const server of servers) { | |
41e74ec9 | 172 | const json = await server.feed.getJSON({ feed: 'videos', ignoreCache: true }) |
c1bc8ee4 | 173 | const jsonObj = JSON.parse(json) |
662fb3ab | 174 | expect(jsonObj.items.length).to.be.equal(2) |
a1587156 C |
175 | expect(jsonObj.items[0].attachments).to.exist |
176 | expect(jsonObj.items[0].attachments.length).to.be.eq(1) | |
177 | expect(jsonObj.items[0].attachments[0].mime_type).to.be.eq('application/x-bittorrent') | |
178 | expect(jsonObj.items[0].attachments[0].size_in_bytes).to.be.eq(218910) | |
179 | expect(jsonObj.items[0].attachments[0].url).to.contain('720.torrent') | |
fe3a55b0 C |
180 | } |
181 | }) | |
662fb3ab C |
182 | |
183 | it('Should filter by account', async function () { | |
57cfff78 | 184 | { |
41e74ec9 | 185 | const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: rootAccountId }, ignoreCache: true }) |
c1bc8ee4 | 186 | const jsonObj = JSON.parse(json) |
57cfff78 | 187 | expect(jsonObj.items.length).to.be.equal(1) |
a1587156 C |
188 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
189 | expect(jsonObj.items[0].author.name).to.equal('root') | |
57cfff78 C |
190 | } |
191 | ||
192 | { | |
41e74ec9 | 193 | const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: userAccountId }, ignoreCache: true }) |
c1bc8ee4 | 194 | const jsonObj = JSON.parse(json) |
57cfff78 | 195 | expect(jsonObj.items.length).to.be.equal(1) |
a1587156 C |
196 | expect(jsonObj.items[0].title).to.equal('user video') |
197 | expect(jsonObj.items[0].author.name).to.equal('john') | |
57cfff78 C |
198 | } |
199 | ||
662fb3ab C |
200 | for (const server of servers) { |
201 | { | |
41e74ec9 | 202 | const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'root@' + servers[0].host }, ignoreCache: true }) |
c1bc8ee4 | 203 | const jsonObj = JSON.parse(json) |
662fb3ab | 204 | expect(jsonObj.items.length).to.be.equal(1) |
a1587156 | 205 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
662fb3ab C |
206 | } |
207 | ||
208 | { | |
41e74ec9 | 209 | const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'john@' + servers[0].host }, ignoreCache: true }) |
c1bc8ee4 | 210 | const jsonObj = JSON.parse(json) |
662fb3ab | 211 | expect(jsonObj.items.length).to.be.equal(1) |
a1587156 | 212 | expect(jsonObj.items[0].title).to.equal('user video') |
662fb3ab C |
213 | } |
214 | } | |
57cfff78 | 215 | }) |
662fb3ab | 216 | |
57cfff78 | 217 | it('Should filter by video channel', async function () { |
662fb3ab | 218 | { |
41e74ec9 | 219 | const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId }, ignoreCache: true }) |
c1bc8ee4 | 220 | const jsonObj = JSON.parse(json) |
662fb3ab | 221 | expect(jsonObj.items.length).to.be.equal(1) |
a1587156 C |
222 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
223 | expect(jsonObj.items[0].author.name).to.equal('root') | |
662fb3ab C |
224 | } |
225 | ||
226 | { | |
41e74ec9 | 227 | const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId }, ignoreCache: true }) |
c1bc8ee4 | 228 | const jsonObj = JSON.parse(json) |
662fb3ab | 229 | expect(jsonObj.items.length).to.be.equal(1) |
a1587156 C |
230 | expect(jsonObj.items[0].title).to.equal('user video') |
231 | expect(jsonObj.items[0].author.name).to.equal('john') | |
662fb3ab | 232 | } |
662fb3ab | 233 | |
662fb3ab C |
234 | for (const server of servers) { |
235 | { | |
41e74ec9 C |
236 | const query = { videoChannelName: 'root_channel@' + servers[0].host } |
237 | const json = await server.feed.getJSON({ feed: 'videos', query, ignoreCache: true }) | |
c1bc8ee4 | 238 | const jsonObj = JSON.parse(json) |
662fb3ab | 239 | expect(jsonObj.items.length).to.be.equal(1) |
a1587156 | 240 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
662fb3ab C |
241 | } |
242 | ||
243 | { | |
41e74ec9 C |
244 | const query = { videoChannelName: 'john_channel@' + servers[0].host } |
245 | const json = await server.feed.getJSON({ feed: 'videos', query, ignoreCache: true }) | |
c1bc8ee4 | 246 | const jsonObj = JSON.parse(json) |
662fb3ab | 247 | expect(jsonObj.items.length).to.be.equal(1) |
a1587156 | 248 | expect(jsonObj.items[0].title).to.equal('user video') |
662fb3ab C |
249 | } |
250 | } | |
662fb3ab | 251 | }) |
97816649 C |
252 | |
253 | it('Should correctly have videos feed with HLS only', async function () { | |
254 | this.timeout(120000) | |
255 | ||
89d241a7 | 256 | await serverHLSOnly.videos.upload({ attributes: { name: 'hls only video' } }) |
97816649 C |
257 | |
258 | await waitJobs([ serverHLSOnly ]) | |
259 | ||
41e74ec9 | 260 | const json = await serverHLSOnly.feed.getJSON({ feed: 'videos', ignoreCache: true }) |
c1bc8ee4 | 261 | const jsonObj = JSON.parse(json) |
97816649 C |
262 | expect(jsonObj.items.length).to.be.equal(1) |
263 | expect(jsonObj.items[0].attachments).to.exist | |
264 | expect(jsonObj.items[0].attachments.length).to.be.eq(4) | |
265 | ||
266 | for (let i = 0; i < 4; i++) { | |
267 | expect(jsonObj.items[0].attachments[i].mime_type).to.be.eq('application/x-bittorrent') | |
268 | expect(jsonObj.items[0].attachments[i].size_in_bytes).to.be.greaterThan(0) | |
269 | expect(jsonObj.items[0].attachments[i].url).to.exist | |
270 | } | |
271 | }) | |
7a5c3d77 C |
272 | |
273 | it('Should not display waiting live videos', async function () { | |
274 | const { uuid } = await servers[0].live.create({ | |
275 | fields: { | |
276 | name: 'live', | |
277 | privacy: VideoPrivacy.PUBLIC, | |
278 | channelId: rootChannelId | |
279 | } | |
280 | }) | |
281 | liveId = uuid | |
282 | ||
41e74ec9 | 283 | const json = await servers[0].feed.getJSON({ feed: 'videos', ignoreCache: true }) |
7a5c3d77 C |
284 | |
285 | const jsonObj = JSON.parse(json) | |
286 | expect(jsonObj.items.length).to.be.equal(2) | |
287 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') | |
288 | expect(jsonObj.items[1].title).to.equal('user video') | |
289 | }) | |
290 | ||
41e74ec9 | 291 | it('Should display published live videos', async function () { |
7a5c3d77 C |
292 | this.timeout(120000) |
293 | ||
294 | const ffmpeg = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveId, copyCodecs: true, fixtureName: 'video_short.mp4' }) | |
295 | await servers[0].live.waitUntilPublished({ videoId: liveId }) | |
296 | ||
41e74ec9 | 297 | const json = await servers[0].feed.getJSON({ feed: 'videos', ignoreCache: true }) |
7a5c3d77 C |
298 | |
299 | const jsonObj = JSON.parse(json) | |
300 | expect(jsonObj.items.length).to.be.equal(3) | |
41e74ec9 C |
301 | expect(jsonObj.items[0].title).to.equal('live') |
302 | expect(jsonObj.items[1].title).to.equal('my super name for server 1') | |
303 | expect(jsonObj.items[2].title).to.equal('user video') | |
7a5c3d77 C |
304 | |
305 | await stopFfmpeg(ffmpeg) | |
306 | }) | |
fe3a55b0 C |
307 | }) |
308 | ||
309 | describe('Video comments feed', function () { | |
68b6fd21 C |
310 | |
311 | it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () { | |
fe3a55b0 | 312 | for (const server of servers) { |
41e74ec9 | 313 | const json = await server.feed.getJSON({ feed: 'video-comments', ignoreCache: true }) |
fe3a55b0 | 314 | |
c1bc8ee4 | 315 | const jsonObj = JSON.parse(json) |
fe3a55b0 | 316 | expect(jsonObj.items.length).to.be.equal(2) |
4393b255 C |
317 | expect(jsonObj.items[0].content_html).to.contain('<p>super comment 2</p>') |
318 | expect(jsonObj.items[1].content_html).to.contain('<p>super comment 1</p>') | |
fe3a55b0 C |
319 | } |
320 | }) | |
1df8a4d7 C |
321 | |
322 | it('Should not list comments from muted accounts or instances', async function () { | |
696d83fd C |
323 | this.timeout(30000) |
324 | ||
41e74ec9 | 325 | const remoteHandle = 'root@' + servers[0].host |
696d83fd | 326 | |
89d241a7 | 327 | await servers[1].blocklist.addToServerBlocklist({ account: remoteHandle }) |
1df8a4d7 C |
328 | |
329 | { | |
41e74ec9 | 330 | const json = await servers[1].feed.getJSON({ feed: 'video-comments', ignoreCache: true }) |
c1bc8ee4 | 331 | const jsonObj = JSON.parse(json) |
1df8a4d7 C |
332 | expect(jsonObj.items.length).to.be.equal(0) |
333 | } | |
334 | ||
89d241a7 | 335 | await servers[1].blocklist.removeFromServerBlocklist({ account: remoteHandle }) |
696d83fd C |
336 | |
337 | { | |
89d241a7 | 338 | const videoUUID = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid |
696d83fd | 339 | await waitJobs(servers) |
89d241a7 | 340 | await servers[0].comments.createThread({ videoId: videoUUID, text: 'super comment' }) |
696d83fd C |
341 | await waitJobs(servers) |
342 | ||
41e74ec9 | 343 | const json = await servers[1].feed.getJSON({ feed: 'video-comments', ignoreCache: true }) |
c1bc8ee4 | 344 | const jsonObj = JSON.parse(json) |
696d83fd C |
345 | expect(jsonObj.items.length).to.be.equal(3) |
346 | } | |
347 | ||
89d241a7 | 348 | await servers[1].blocklist.addToMyBlocklist({ account: remoteHandle }) |
696d83fd C |
349 | |
350 | { | |
41e74ec9 | 351 | const json = await servers[1].feed.getJSON({ feed: 'video-comments', ignoreCache: true }) |
c1bc8ee4 | 352 | const jsonObj = JSON.parse(json) |
696d83fd C |
353 | expect(jsonObj.items.length).to.be.equal(2) |
354 | } | |
1df8a4d7 | 355 | }) |
fe3a55b0 C |
356 | }) |
357 | ||
afff310e | 358 | describe('Video feed from my subscriptions', function () { |
18490b07 C |
359 | let feeduserAccountId: number |
360 | let feeduserFeedToken: string | |
afff310e RK |
361 | |
362 | it('Should list no videos for a user with no videos and no subscriptions', async function () { | |
afff310e | 363 | const attr = { username: 'feeduser', password: 'password' } |
89d241a7 C |
364 | await servers[0].users.create({ username: attr.username, password: attr.password }) |
365 | const feeduserAccessToken = await servers[0].login.getAccessToken(attr) | |
afff310e RK |
366 | |
367 | { | |
89d241a7 | 368 | const user = await servers[0].users.getMyInfo({ token: feeduserAccessToken }) |
afff310e RK |
369 | feeduserAccountId = user.account.id |
370 | } | |
371 | ||
372 | { | |
89d241a7 | 373 | const token = await servers[0].users.getMyScopedTokens({ token: feeduserAccessToken }) |
afff310e RK |
374 | feeduserFeedToken = token.feedToken |
375 | } | |
376 | ||
377 | { | |
89d241a7 | 378 | const body = await servers[0].subscriptions.listVideos({ token: feeduserAccessToken }) |
2c27e704 | 379 | expect(body.total).to.equal(0) |
afff310e | 380 | |
c1bc8ee4 | 381 | const query = { accountId: feeduserAccountId, token: feeduserFeedToken } |
41e74ec9 | 382 | const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query, ignoreCache: true }) |
c1bc8ee4 | 383 | const jsonObj = JSON.parse(json) |
afff310e RK |
384 | expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos |
385 | } | |
386 | }) | |
387 | ||
18490b07 | 388 | it('Should fail with an invalid token', async function () { |
c1bc8ee4 | 389 | const query = { accountId: feeduserAccountId, token: 'toto' } |
41e74ec9 | 390 | await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403, ignoreCache: true }) |
18490b07 C |
391 | }) |
392 | ||
393 | it('Should fail with a token of another user', async function () { | |
c1bc8ee4 | 394 | const query = { accountId: feeduserAccountId, token: userFeedToken } |
41e74ec9 | 395 | await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403, ignoreCache: true }) |
18490b07 C |
396 | }) |
397 | ||
afff310e | 398 | it('Should list no videos for a user with videos but no subscriptions', async function () { |
89d241a7 | 399 | const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) |
2c27e704 | 400 | expect(body.total).to.equal(0) |
afff310e | 401 | |
c1bc8ee4 | 402 | const query = { accountId: userAccountId, token: userFeedToken } |
41e74ec9 | 403 | const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query, ignoreCache: true }) |
c1bc8ee4 | 404 | const jsonObj = JSON.parse(json) |
18490b07 | 405 | expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos |
afff310e RK |
406 | }) |
407 | ||
408 | it('Should list self videos for a user with a subscription to themselves', async function () { | |
409 | this.timeout(30000) | |
410 | ||
41e74ec9 | 411 | await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'john_channel@' + servers[0].host }) |
afff310e RK |
412 | await waitJobs(servers) |
413 | ||
414 | { | |
89d241a7 | 415 | const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) |
2c27e704 C |
416 | expect(body.total).to.equal(1) |
417 | expect(body.data[0].name).to.equal('user video') | |
afff310e | 418 | |
41e74ec9 C |
419 | const query = { accountId: userAccountId, token: userFeedToken } |
420 | const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query, ignoreCache: true }) | |
c1bc8ee4 | 421 | const jsonObj = JSON.parse(json) |
afff310e RK |
422 | expect(jsonObj.items.length).to.be.equal(1) // subscribed to self, it should not list the instance's videos but list john's |
423 | } | |
424 | }) | |
425 | ||
426 | it('Should list videos of a user\'s subscription', async function () { | |
427 | this.timeout(30000) | |
428 | ||
41e74ec9 | 429 | await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@' + servers[0].host }) |
afff310e RK |
430 | await waitJobs(servers) |
431 | ||
432 | { | |
89d241a7 | 433 | const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) |
7e0f50d6 | 434 | expect(body.total).to.equal(2, 'there should be 2 videos part of the subscription') |
afff310e | 435 | |
41e74ec9 C |
436 | const query = { accountId: userAccountId, token: userFeedToken } |
437 | const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query, ignoreCache: true }) | |
c1bc8ee4 | 438 | const jsonObj = JSON.parse(json) |
afff310e RK |
439 | expect(jsonObj.items.length).to.be.equal(2) // subscribed to root, it should not list the instance's videos but list root/john's |
440 | } | |
441 | }) | |
442 | ||
18490b07 | 443 | it('Should renew the token, and so have an invalid old token', async function () { |
89d241a7 | 444 | await servers[0].users.renewMyScopedTokens({ token: userAccessToken }) |
18490b07 | 445 | |
41e74ec9 C |
446 | const query = { accountId: userAccountId, token: userFeedToken } |
447 | await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403, ignoreCache: true }) | |
18490b07 C |
448 | }) |
449 | ||
450 | it('Should succeed with the new token', async function () { | |
89d241a7 | 451 | const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken }) |
18490b07 C |
452 | userFeedToken = token.feedToken |
453 | ||
41e74ec9 C |
454 | const query = { accountId: userAccountId, token: userFeedToken } |
455 | await servers[0].feed.getJSON({ feed: 'subscriptions', query, ignoreCache: true }) | |
18490b07 C |
456 | }) |
457 | ||
afff310e RK |
458 | }) |
459 | ||
7c3b7976 | 460 | after(async function () { |
97816649 | 461 | await cleanupTests([ ...servers, serverHLSOnly ]) |
fe3a55b0 C |
462 | }) |
463 | }) |