diff options
Diffstat (limited to 'server/tests/feeds')
-rw-r--r-- | server/tests/feeds/feeds.ts | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index c66cdde1b..8bdafc644 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts | |||
@@ -47,26 +47,26 @@ describe('Test syndication feeds', () => { | |||
47 | await doubleFollow(servers[0], servers[1]) | 47 | await doubleFollow(servers[0], servers[1]) |
48 | 48 | ||
49 | { | 49 | { |
50 | const user = await servers[0].usersCommand.getMyInfo() | 50 | const user = await servers[0].users.getMyInfo() |
51 | rootAccountId = user.account.id | 51 | rootAccountId = user.account.id |
52 | rootChannelId = user.videoChannels[0].id | 52 | rootChannelId = user.videoChannels[0].id |
53 | } | 53 | } |
54 | 54 | ||
55 | { | 55 | { |
56 | const attr = { username: 'john', password: 'password' } | 56 | const attr = { username: 'john', password: 'password' } |
57 | await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) | 57 | await servers[0].users.create({ username: attr.username, password: attr.password }) |
58 | userAccessToken = await servers[0].loginCommand.getAccessToken(attr) | 58 | userAccessToken = await servers[0].login.getAccessToken(attr) |
59 | 59 | ||
60 | const user = await servers[0].usersCommand.getMyInfo({ token: userAccessToken }) | 60 | const user = await servers[0].users.getMyInfo({ token: userAccessToken }) |
61 | userAccountId = user.account.id | 61 | userAccountId = user.account.id |
62 | userChannelId = user.videoChannels[0].id | 62 | userChannelId = user.videoChannels[0].id |
63 | 63 | ||
64 | const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) | 64 | const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken }) |
65 | userFeedToken = token.feedToken | 65 | userFeedToken = token.feedToken |
66 | } | 66 | } |
67 | 67 | ||
68 | { | 68 | { |
69 | await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'user video' } }) | 69 | await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'user video' } }) |
70 | } | 70 | } |
71 | 71 | ||
72 | { | 72 | { |
@@ -75,17 +75,17 @@ describe('Test syndication feeds', () => { | |||
75 | description: 'my super description for server 1', | 75 | description: 'my super description for server 1', |
76 | fixture: 'video_short.webm' | 76 | fixture: 'video_short.webm' |
77 | } | 77 | } |
78 | const { id } = await servers[0].videosCommand.upload({ attributes }) | 78 | const { id } = await servers[0].videos.upload({ attributes }) |
79 | 79 | ||
80 | await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 1' }) | 80 | await servers[0].comments.createThread({ videoId: id, text: 'super comment 1' }) |
81 | await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 2' }) | 81 | await servers[0].comments.createThread({ videoId: id, text: 'super comment 2' }) |
82 | } | 82 | } |
83 | 83 | ||
84 | { | 84 | { |
85 | const attributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED } | 85 | const attributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED } |
86 | const { id } = await servers[0].videosCommand.upload({ attributes }) | 86 | const { id } = await servers[0].videos.upload({ attributes }) |
87 | 87 | ||
88 | await servers[0].commentsCommand.createThread({ videoId: id, text: 'comment on unlisted video' }) | 88 | await servers[0].comments.createThread({ videoId: id, text: 'comment on unlisted video' }) |
89 | } | 89 | } |
90 | 90 | ||
91 | await waitJobs(servers) | 91 | await waitJobs(servers) |
@@ -95,17 +95,17 @@ describe('Test syndication feeds', () => { | |||
95 | 95 | ||
96 | it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () { | 96 | it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () { |
97 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { | 97 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { |
98 | const rss = await servers[0].feedCommand.getXML({ feed }) | 98 | const rss = await servers[0].feed.getXML({ feed }) |
99 | expect(rss).xml.to.be.valid() | 99 | expect(rss).xml.to.be.valid() |
100 | 100 | ||
101 | const atom = await servers[0].feedCommand.getXML({ feed, format: 'atom' }) | 101 | const atom = await servers[0].feed.getXML({ feed, format: 'atom' }) |
102 | expect(atom).xml.to.be.valid() | 102 | expect(atom).xml.to.be.valid() |
103 | } | 103 | } |
104 | }) | 104 | }) |
105 | 105 | ||
106 | it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () { | 106 | it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () { |
107 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { | 107 | for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { |
108 | const jsonText = await servers[0].feedCommand.getJSON({ feed }) | 108 | const jsonText = await servers[0].feed.getJSON({ feed }) |
109 | expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' }) | 109 | expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' }) |
110 | } | 110 | } |
111 | }) | 111 | }) |
@@ -115,7 +115,7 @@ describe('Test syndication feeds', () => { | |||
115 | 115 | ||
116 | it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () { | 116 | it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () { |
117 | for (const server of servers) { | 117 | for (const server of servers) { |
118 | const rss = await server.feedCommand.getXML({ feed: 'videos' }) | 118 | const rss = await server.feed.getXML({ feed: 'videos' }) |
119 | expect(xmlParser.validate(rss)).to.be.true | 119 | expect(xmlParser.validate(rss)).to.be.true |
120 | 120 | ||
121 | const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false }) | 121 | const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false }) |
@@ -130,7 +130,7 @@ describe('Test syndication feeds', () => { | |||
130 | 130 | ||
131 | it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', async function () { | 131 | it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', async function () { |
132 | for (const server of servers) { | 132 | for (const server of servers) { |
133 | const json = await server.feedCommand.getJSON({ feed: 'videos' }) | 133 | const json = await server.feed.getJSON({ feed: 'videos' }) |
134 | const jsonObj = JSON.parse(json) | 134 | const jsonObj = JSON.parse(json) |
135 | expect(jsonObj.items.length).to.be.equal(2) | 135 | expect(jsonObj.items.length).to.be.equal(2) |
136 | expect(jsonObj.items[0].attachments).to.exist | 136 | expect(jsonObj.items[0].attachments).to.exist |
@@ -143,7 +143,7 @@ describe('Test syndication feeds', () => { | |||
143 | 143 | ||
144 | it('Should filter by account', async function () { | 144 | it('Should filter by account', async function () { |
145 | { | 145 | { |
146 | const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: rootAccountId } }) | 146 | const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: rootAccountId } }) |
147 | const jsonObj = JSON.parse(json) | 147 | const jsonObj = JSON.parse(json) |
148 | expect(jsonObj.items.length).to.be.equal(1) | 148 | expect(jsonObj.items.length).to.be.equal(1) |
149 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') | 149 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
@@ -151,7 +151,7 @@ describe('Test syndication feeds', () => { | |||
151 | } | 151 | } |
152 | 152 | ||
153 | { | 153 | { |
154 | const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: userAccountId } }) | 154 | const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: userAccountId } }) |
155 | const jsonObj = JSON.parse(json) | 155 | const jsonObj = JSON.parse(json) |
156 | expect(jsonObj.items.length).to.be.equal(1) | 156 | expect(jsonObj.items.length).to.be.equal(1) |
157 | expect(jsonObj.items[0].title).to.equal('user video') | 157 | expect(jsonObj.items[0].title).to.equal('user video') |
@@ -160,14 +160,14 @@ describe('Test syndication feeds', () => { | |||
160 | 160 | ||
161 | for (const server of servers) { | 161 | for (const server of servers) { |
162 | { | 162 | { |
163 | const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } }) | 163 | const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } }) |
164 | const jsonObj = JSON.parse(json) | 164 | const jsonObj = JSON.parse(json) |
165 | expect(jsonObj.items.length).to.be.equal(1) | 165 | expect(jsonObj.items.length).to.be.equal(1) |
166 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') | 166 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
167 | } | 167 | } |
168 | 168 | ||
169 | { | 169 | { |
170 | const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } }) | 170 | const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } }) |
171 | const jsonObj = JSON.parse(json) | 171 | const jsonObj = JSON.parse(json) |
172 | expect(jsonObj.items.length).to.be.equal(1) | 172 | expect(jsonObj.items.length).to.be.equal(1) |
173 | expect(jsonObj.items[0].title).to.equal('user video') | 173 | expect(jsonObj.items[0].title).to.equal('user video') |
@@ -177,7 +177,7 @@ describe('Test syndication feeds', () => { | |||
177 | 177 | ||
178 | it('Should filter by video channel', async function () { | 178 | it('Should filter by video channel', async function () { |
179 | { | 179 | { |
180 | const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } }) | 180 | const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } }) |
181 | const jsonObj = JSON.parse(json) | 181 | const jsonObj = JSON.parse(json) |
182 | expect(jsonObj.items.length).to.be.equal(1) | 182 | expect(jsonObj.items.length).to.be.equal(1) |
183 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') | 183 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
@@ -185,7 +185,7 @@ describe('Test syndication feeds', () => { | |||
185 | } | 185 | } |
186 | 186 | ||
187 | { | 187 | { |
188 | const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } }) | 188 | const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } }) |
189 | const jsonObj = JSON.parse(json) | 189 | const jsonObj = JSON.parse(json) |
190 | expect(jsonObj.items.length).to.be.equal(1) | 190 | expect(jsonObj.items.length).to.be.equal(1) |
191 | expect(jsonObj.items[0].title).to.equal('user video') | 191 | expect(jsonObj.items[0].title).to.equal('user video') |
@@ -195,7 +195,7 @@ describe('Test syndication feeds', () => { | |||
195 | for (const server of servers) { | 195 | for (const server of servers) { |
196 | { | 196 | { |
197 | const query = { videoChannelName: 'root_channel@localhost:' + servers[0].port } | 197 | const query = { videoChannelName: 'root_channel@localhost:' + servers[0].port } |
198 | const json = await server.feedCommand.getJSON({ feed: 'videos', query }) | 198 | const json = await server.feed.getJSON({ feed: 'videos', query }) |
199 | const jsonObj = JSON.parse(json) | 199 | const jsonObj = JSON.parse(json) |
200 | expect(jsonObj.items.length).to.be.equal(1) | 200 | expect(jsonObj.items.length).to.be.equal(1) |
201 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') | 201 | expect(jsonObj.items[0].title).to.equal('my super name for server 1') |
@@ -203,7 +203,7 @@ describe('Test syndication feeds', () => { | |||
203 | 203 | ||
204 | { | 204 | { |
205 | const query = { videoChannelName: 'john_channel@localhost:' + servers[0].port } | 205 | const query = { videoChannelName: 'john_channel@localhost:' + servers[0].port } |
206 | const json = await server.feedCommand.getJSON({ feed: 'videos', query }) | 206 | const json = await server.feed.getJSON({ feed: 'videos', query }) |
207 | const jsonObj = JSON.parse(json) | 207 | const jsonObj = JSON.parse(json) |
208 | expect(jsonObj.items.length).to.be.equal(1) | 208 | expect(jsonObj.items.length).to.be.equal(1) |
209 | expect(jsonObj.items[0].title).to.equal('user video') | 209 | expect(jsonObj.items[0].title).to.equal('user video') |
@@ -214,11 +214,11 @@ describe('Test syndication feeds', () => { | |||
214 | it('Should correctly have videos feed with HLS only', async function () { | 214 | it('Should correctly have videos feed with HLS only', async function () { |
215 | this.timeout(120000) | 215 | this.timeout(120000) |
216 | 216 | ||
217 | await serverHLSOnly.videosCommand.upload({ attributes: { name: 'hls only video' } }) | 217 | await serverHLSOnly.videos.upload({ attributes: { name: 'hls only video' } }) |
218 | 218 | ||
219 | await waitJobs([ serverHLSOnly ]) | 219 | await waitJobs([ serverHLSOnly ]) |
220 | 220 | ||
221 | const json = await serverHLSOnly.feedCommand.getJSON({ feed: 'videos' }) | 221 | const json = await serverHLSOnly.feed.getJSON({ feed: 'videos' }) |
222 | const jsonObj = JSON.parse(json) | 222 | const jsonObj = JSON.parse(json) |
223 | expect(jsonObj.items.length).to.be.equal(1) | 223 | expect(jsonObj.items.length).to.be.equal(1) |
224 | expect(jsonObj.items[0].attachments).to.exist | 224 | expect(jsonObj.items[0].attachments).to.exist |
@@ -236,7 +236,7 @@ describe('Test syndication feeds', () => { | |||
236 | 236 | ||
237 | it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () { | 237 | it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () { |
238 | for (const server of servers) { | 238 | for (const server of servers) { |
239 | const json = await server.feedCommand.getJSON({ feed: 'video-comments' }) | 239 | const json = await server.feed.getJSON({ feed: 'video-comments' }) |
240 | 240 | ||
241 | const jsonObj = JSON.parse(json) | 241 | const jsonObj = JSON.parse(json) |
242 | expect(jsonObj.items.length).to.be.equal(2) | 242 | expect(jsonObj.items.length).to.be.equal(2) |
@@ -250,31 +250,31 @@ describe('Test syndication feeds', () => { | |||
250 | 250 | ||
251 | const remoteHandle = 'root@localhost:' + servers[0].port | 251 | const remoteHandle = 'root@localhost:' + servers[0].port |
252 | 252 | ||
253 | await servers[1].blocklistCommand.addToServerBlocklist({ account: remoteHandle }) | 253 | await servers[1].blocklist.addToServerBlocklist({ account: remoteHandle }) |
254 | 254 | ||
255 | { | 255 | { |
256 | const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 2 } }) | 256 | const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 2 } }) |
257 | const jsonObj = JSON.parse(json) | 257 | const jsonObj = JSON.parse(json) |
258 | expect(jsonObj.items.length).to.be.equal(0) | 258 | expect(jsonObj.items.length).to.be.equal(0) |
259 | } | 259 | } |
260 | 260 | ||
261 | await servers[1].blocklistCommand.removeFromServerBlocklist({ account: remoteHandle }) | 261 | await servers[1].blocklist.removeFromServerBlocklist({ account: remoteHandle }) |
262 | 262 | ||
263 | { | 263 | { |
264 | const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid | 264 | const videoUUID = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid |
265 | await waitJobs(servers) | 265 | await waitJobs(servers) |
266 | await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'super comment' }) | 266 | await servers[0].comments.createThread({ videoId: videoUUID, text: 'super comment' }) |
267 | await waitJobs(servers) | 267 | await waitJobs(servers) |
268 | 268 | ||
269 | const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 3 } }) | 269 | const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 3 } }) |
270 | const jsonObj = JSON.parse(json) | 270 | const jsonObj = JSON.parse(json) |
271 | expect(jsonObj.items.length).to.be.equal(3) | 271 | expect(jsonObj.items.length).to.be.equal(3) |
272 | } | 272 | } |
273 | 273 | ||
274 | await servers[1].blocklistCommand.addToMyBlocklist({ account: remoteHandle }) | 274 | await servers[1].blocklist.addToMyBlocklist({ account: remoteHandle }) |
275 | 275 | ||
276 | { | 276 | { |
277 | const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 4 } }) | 277 | const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 4 } }) |
278 | const jsonObj = JSON.parse(json) | 278 | const jsonObj = JSON.parse(json) |
279 | expect(jsonObj.items.length).to.be.equal(2) | 279 | expect(jsonObj.items.length).to.be.equal(2) |
280 | } | 280 | } |
@@ -287,25 +287,25 @@ describe('Test syndication feeds', () => { | |||
287 | 287 | ||
288 | it('Should list no videos for a user with no videos and no subscriptions', async function () { | 288 | it('Should list no videos for a user with no videos and no subscriptions', async function () { |
289 | const attr = { username: 'feeduser', password: 'password' } | 289 | const attr = { username: 'feeduser', password: 'password' } |
290 | await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) | 290 | await servers[0].users.create({ username: attr.username, password: attr.password }) |
291 | const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr) | 291 | const feeduserAccessToken = await servers[0].login.getAccessToken(attr) |
292 | 292 | ||
293 | { | 293 | { |
294 | const user = await servers[0].usersCommand.getMyInfo({ token: feeduserAccessToken }) | 294 | const user = await servers[0].users.getMyInfo({ token: feeduserAccessToken }) |
295 | feeduserAccountId = user.account.id | 295 | feeduserAccountId = user.account.id |
296 | } | 296 | } |
297 | 297 | ||
298 | { | 298 | { |
299 | const token = await servers[0].usersCommand.getMyScopedTokens({ token: feeduserAccessToken }) | 299 | const token = await servers[0].users.getMyScopedTokens({ token: feeduserAccessToken }) |
300 | feeduserFeedToken = token.feedToken | 300 | feeduserFeedToken = token.feedToken |
301 | } | 301 | } |
302 | 302 | ||
303 | { | 303 | { |
304 | const body = await servers[0].subscriptionsCommand.listVideos({ token: feeduserAccessToken }) | 304 | const body = await servers[0].subscriptions.listVideos({ token: feeduserAccessToken }) |
305 | expect(body.total).to.equal(0) | 305 | expect(body.total).to.equal(0) |
306 | 306 | ||
307 | const query = { accountId: feeduserAccountId, token: feeduserFeedToken } | 307 | const query = { accountId: feeduserAccountId, token: feeduserFeedToken } |
308 | const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) | 308 | const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query }) |
309 | const jsonObj = JSON.parse(json) | 309 | const jsonObj = JSON.parse(json) |
310 | expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos | 310 | expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos |
311 | } | 311 | } |
@@ -313,20 +313,20 @@ describe('Test syndication feeds', () => { | |||
313 | 313 | ||
314 | it('Should fail with an invalid token', async function () { | 314 | it('Should fail with an invalid token', async function () { |
315 | const query = { accountId: feeduserAccountId, token: 'toto' } | 315 | const query = { accountId: feeduserAccountId, token: 'toto' } |
316 | await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 316 | await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
317 | }) | 317 | }) |
318 | 318 | ||
319 | it('Should fail with a token of another user', async function () { | 319 | it('Should fail with a token of another user', async function () { |
320 | const query = { accountId: feeduserAccountId, token: userFeedToken } | 320 | const query = { accountId: feeduserAccountId, token: userFeedToken } |
321 | await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 321 | await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
322 | }) | 322 | }) |
323 | 323 | ||
324 | it('Should list no videos for a user with videos but no subscriptions', async function () { | 324 | it('Should list no videos for a user with videos but no subscriptions', async function () { |
325 | const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) | 325 | const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) |
326 | expect(body.total).to.equal(0) | 326 | expect(body.total).to.equal(0) |
327 | 327 | ||
328 | const query = { accountId: userAccountId, token: userFeedToken } | 328 | const query = { accountId: userAccountId, token: userFeedToken } |
329 | const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) | 329 | const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query }) |
330 | const jsonObj = JSON.parse(json) | 330 | const jsonObj = JSON.parse(json) |
331 | expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos | 331 | expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos |
332 | }) | 332 | }) |
@@ -334,16 +334,16 @@ describe('Test syndication feeds', () => { | |||
334 | it('Should list self videos for a user with a subscription to themselves', async function () { | 334 | it('Should list self videos for a user with a subscription to themselves', async function () { |
335 | this.timeout(30000) | 335 | this.timeout(30000) |
336 | 336 | ||
337 | await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port }) | 337 | await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port }) |
338 | await waitJobs(servers) | 338 | await waitJobs(servers) |
339 | 339 | ||
340 | { | 340 | { |
341 | const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) | 341 | const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) |
342 | expect(body.total).to.equal(1) | 342 | expect(body.total).to.equal(1) |
343 | expect(body.data[0].name).to.equal('user video') | 343 | expect(body.data[0].name).to.equal('user video') |
344 | 344 | ||
345 | const query = { accountId: userAccountId, token: userFeedToken, version: 1 } | 345 | const query = { accountId: userAccountId, token: userFeedToken, version: 1 } |
346 | const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) | 346 | const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query }) |
347 | const jsonObj = JSON.parse(json) | 347 | const jsonObj = JSON.parse(json) |
348 | expect(jsonObj.items.length).to.be.equal(1) // subscribed to self, it should not list the instance's videos but list john's | 348 | expect(jsonObj.items.length).to.be.equal(1) // subscribed to self, it should not list the instance's videos but list john's |
349 | } | 349 | } |
@@ -352,33 +352,33 @@ describe('Test syndication feeds', () => { | |||
352 | it('Should list videos of a user\'s subscription', async function () { | 352 | it('Should list videos of a user\'s subscription', async function () { |
353 | this.timeout(30000) | 353 | this.timeout(30000) |
354 | 354 | ||
355 | await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) | 355 | await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) |
356 | await waitJobs(servers) | 356 | await waitJobs(servers) |
357 | 357 | ||
358 | { | 358 | { |
359 | const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) | 359 | const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) |
360 | expect(body.total).to.equal(2, "there should be 2 videos part of the subscription") | 360 | expect(body.total).to.equal(2, "there should be 2 videos part of the subscription") |
361 | 361 | ||
362 | const query = { accountId: userAccountId, token: userFeedToken, version: 2 } | 362 | const query = { accountId: userAccountId, token: userFeedToken, version: 2 } |
363 | const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) | 363 | const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query }) |
364 | const jsonObj = JSON.parse(json) | 364 | const jsonObj = JSON.parse(json) |
365 | expect(jsonObj.items.length).to.be.equal(2) // subscribed to root, it should not list the instance's videos but list root/john's | 365 | expect(jsonObj.items.length).to.be.equal(2) // subscribed to root, it should not list the instance's videos but list root/john's |
366 | } | 366 | } |
367 | }) | 367 | }) |
368 | 368 | ||
369 | it('Should renew the token, and so have an invalid old token', async function () { | 369 | it('Should renew the token, and so have an invalid old token', async function () { |
370 | await servers[0].usersCommand.renewMyScopedTokens({ token: userAccessToken }) | 370 | await servers[0].users.renewMyScopedTokens({ token: userAccessToken }) |
371 | 371 | ||
372 | const query = { accountId: userAccountId, token: userFeedToken, version: 3 } | 372 | const query = { accountId: userAccountId, token: userFeedToken, version: 3 } |
373 | await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 373 | await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
374 | }) | 374 | }) |
375 | 375 | ||
376 | it('Should succeed with the new token', async function () { | 376 | it('Should succeed with the new token', async function () { |
377 | const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) | 377 | const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken }) |
378 | userFeedToken = token.feedToken | 378 | userFeedToken = token.feedToken |
379 | 379 | ||
380 | const query = { accountId: userAccountId, token: userFeedToken, version: 4 } | 380 | const query = { accountId: userAccountId, token: userFeedToken, version: 4 } |
381 | await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) | 381 | await servers[0].feed.getJSON({ feed: 'subscriptions', query }) |
382 | }) | 382 | }) |
383 | 383 | ||
384 | }) | 384 | }) |