diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-13 14:23:01 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (patch) | |
tree | 7a166515e4d57a06eb3c08be569f106ed049988b /server/tests/feeds/feeds.ts | |
parent | d0a0fa429d4651710ed951a3c11af0219e408964 (diff) | |
download | PeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.tar.gz PeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.tar.zst PeerTube-7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0.zip |
Introduce user command
Diffstat (limited to 'server/tests/feeds/feeds.ts')
-rw-r--r-- | server/tests/feeds/feeds.ts | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 9c78ae0e8..18ce8f7c5 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts | |||
@@ -6,21 +6,16 @@ import * as xmlParser from 'fast-xml-parser' | |||
6 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/core-utils' |
7 | import { | 7 | import { |
8 | cleanupTests, | 8 | cleanupTests, |
9 | createUser, | ||
10 | doubleFollow, | 9 | doubleFollow, |
11 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
12 | flushAndRunServer, | 11 | flushAndRunServer, |
13 | getMyUserInformation, | ||
14 | getUserScopedTokens, | ||
15 | renewUserScopedTokens, | ||
16 | ServerInfo, | 12 | ServerInfo, |
17 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
18 | uploadVideo, | 14 | uploadVideo, |
19 | uploadVideoAndGetId, | 15 | uploadVideoAndGetId, |
20 | waitJobs | 16 | waitJobs |
21 | } from '@shared/extra-utils' | 17 | } from '@shared/extra-utils' |
22 | import { User, VideoPrivacy } from '@shared/models' | 18 | import { VideoPrivacy } from '@shared/models' |
23 | import { ScopedToken } from '@shared/models/users/user-scoped-token' | ||
24 | 19 | ||
25 | chai.use(require('chai-xml')) | 20 | chai.use(require('chai-xml')) |
26 | chai.use(require('chai-json-schema')) | 21 | chai.use(require('chai-json-schema')) |
@@ -54,24 +49,21 @@ describe('Test syndication feeds', () => { | |||
54 | await doubleFollow(servers[0], servers[1]) | 49 | await doubleFollow(servers[0], servers[1]) |
55 | 50 | ||
56 | { | 51 | { |
57 | const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) | 52 | const user = await servers[0].usersCommand.getMyInfo() |
58 | const user: User = res.body | ||
59 | rootAccountId = user.account.id | 53 | rootAccountId = user.account.id |
60 | rootChannelId = user.videoChannels[0].id | 54 | rootChannelId = user.videoChannels[0].id |
61 | } | 55 | } |
62 | 56 | ||
63 | { | 57 | { |
64 | const attr = { username: 'john', password: 'password' } | 58 | const attr = { username: 'john', password: 'password' } |
65 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password }) | 59 | await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) |
66 | userAccessToken = await servers[0].loginCommand.getAccessToken(attr) | 60 | userAccessToken = await servers[0].loginCommand.getAccessToken(attr) |
67 | 61 | ||
68 | const res = await getMyUserInformation(servers[0].url, userAccessToken) | 62 | const user = await servers[0].usersCommand.getMyInfo({ token: userAccessToken }) |
69 | const user: User = res.body | ||
70 | userAccountId = user.account.id | 63 | userAccountId = user.account.id |
71 | userChannelId = user.videoChannels[0].id | 64 | userChannelId = user.videoChannels[0].id |
72 | 65 | ||
73 | const res2 = await getUserScopedTokens(servers[0].url, userAccessToken) | 66 | const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) |
74 | const token: ScopedToken = res2.body | ||
75 | userFeedToken = token.feedToken | 67 | userFeedToken = token.feedToken |
76 | } | 68 | } |
77 | 69 | ||
@@ -299,18 +291,16 @@ describe('Test syndication feeds', () => { | |||
299 | 291 | ||
300 | it('Should list no videos for a user with no videos and no subscriptions', async function () { | 292 | it('Should list no videos for a user with no videos and no subscriptions', async function () { |
301 | const attr = { username: 'feeduser', password: 'password' } | 293 | const attr = { username: 'feeduser', password: 'password' } |
302 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password }) | 294 | await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) |
303 | const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr) | 295 | const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr) |
304 | 296 | ||
305 | { | 297 | { |
306 | const res = await getMyUserInformation(servers[0].url, feeduserAccessToken) | 298 | const user = await servers[0].usersCommand.getMyInfo({ token: feeduserAccessToken }) |
307 | const user: User = res.body | ||
308 | feeduserAccountId = user.account.id | 299 | feeduserAccountId = user.account.id |
309 | } | 300 | } |
310 | 301 | ||
311 | { | 302 | { |
312 | const res = await getUserScopedTokens(servers[0].url, feeduserAccessToken) | 303 | const token = await servers[0].usersCommand.getMyScopedTokens({ token: feeduserAccessToken }) |
313 | const token: ScopedToken = res.body | ||
314 | feeduserFeedToken = token.feedToken | 304 | feeduserFeedToken = token.feedToken |
315 | } | 305 | } |
316 | 306 | ||
@@ -381,15 +371,14 @@ describe('Test syndication feeds', () => { | |||
381 | }) | 371 | }) |
382 | 372 | ||
383 | it('Should renew the token, and so have an invalid old token', async function () { | 373 | it('Should renew the token, and so have an invalid old token', async function () { |
384 | await renewUserScopedTokens(servers[0].url, userAccessToken) | 374 | await servers[0].usersCommand.renewMyScopedTokens({ token: userAccessToken }) |
385 | 375 | ||
386 | const query = { accountId: userAccountId, token: userFeedToken, version: 3 } | 376 | const query = { accountId: userAccountId, token: userFeedToken, version: 3 } |
387 | await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 377 | await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
388 | }) | 378 | }) |
389 | 379 | ||
390 | it('Should succeed with the new token', async function () { | 380 | it('Should succeed with the new token', async function () { |
391 | const res2 = await getUserScopedTokens(servers[0].url, userAccessToken) | 381 | const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) |
392 | const token: ScopedToken = res2.body | ||
393 | userFeedToken = token.feedToken | 382 | userFeedToken = token.feedToken |
394 | 383 | ||
395 | const query = { accountId: userAccountId, token: userFeedToken, version: 4 } | 384 | const query = { accountId: userAccountId, token: userFeedToken, version: 4 } |