From c1bc8ee4783d6ce3102524e6c2a02b2f0f6aab6d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 10:21:35 +0200 Subject: Introduce feed command --- server/tests/feeds/feeds.ts | 122 ++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 62 deletions(-) (limited to 'server/tests/feeds/feeds.ts') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 7bad81751..4d29a2e39 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -11,16 +11,15 @@ import { import { addUserSubscription, listUserSubscriptionVideos } from '@shared/extra-utils/users/user-subscriptions' import { VideoPrivacy } from '@shared/models' import { ScopedToken } from '@shared/models/users/user-scoped-token' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { cleanupTests, createUser, doubleFollow, flushAndRunMultipleServers, flushAndRunServer, - getJSONfeed, getMyUserInformation, getUserScopedTokens, - getXMLfeed, renewUserScopedTokens, ServerInfo, setAccessTokensToServers, @@ -31,7 +30,6 @@ import { import { waitJobs } from '../../../shared/extra-utils/server/jobs' import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' import { User } from '../../../shared/models/users' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' chai.use(require('chai-xml')) chai.use(require('chai-json-schema')) @@ -118,18 +116,18 @@ describe('Test syndication feeds', () => { it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () { for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { - const rss = await getXMLfeed(servers[0].url, feed) - expect(rss.text).xml.to.be.valid() + const rss = await servers[0].feedCommand.getXML({ feed }) + expect(rss).xml.to.be.valid() - const atom = await getXMLfeed(servers[0].url, feed, 'atom') - expect(atom.text).xml.to.be.valid() + const atom = await servers[0].feedCommand.getXML({ feed, format: 'atom' }) + expect(atom).xml.to.be.valid() } }) it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () { for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { - const json = await getJSONfeed(servers[0].url, feed) - expect(JSON.parse(json.text)).to.be.jsonSchema({ type: 'object' }) + const jsonText = await servers[0].feedCommand.getJSON({ feed }) + expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' }) } }) }) @@ -138,10 +136,10 @@ describe('Test syndication feeds', () => { it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () { for (const server of servers) { - const rss = await getXMLfeed(server.url, 'videos') - expect(xmlParser.validate(rss.text)).to.be.true + const rss = await server.feedCommand.getXML({ feed: 'videos' }) + expect(xmlParser.validate(rss)).to.be.true - const xmlDoc = xmlParser.parse(rss.text, { parseAttributeValue: true, ignoreAttributes: false }) + const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false }) const enclosure = xmlDoc.rss.channel.item[0].enclosure expect(enclosure).to.exist @@ -153,8 +151,8 @@ describe('Test syndication feeds', () => { it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', async function () { for (const server of servers) { - const json = await getJSONfeed(server.url, 'videos') - const jsonObj = JSON.parse(json.text) + const json = await server.feedCommand.getJSON({ feed: 'videos' }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(2) expect(jsonObj.items[0].attachments).to.exist expect(jsonObj.items[0].attachments.length).to.be.eq(1) @@ -166,16 +164,16 @@ describe('Test syndication feeds', () => { it('Should filter by account', async function () { { - const json = await getJSONfeed(servers[0].url, 'videos', { accountId: rootAccountId }) - const jsonObj = JSON.parse(json.text) + const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: rootAccountId } }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('my super name for server 1') expect(jsonObj.items[0].author.name).to.equal('root') } { - const json = await getJSONfeed(servers[0].url, 'videos', { accountId: userAccountId }) - const jsonObj = JSON.parse(json.text) + const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: userAccountId } }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('user video') expect(jsonObj.items[0].author.name).to.equal('john') @@ -183,15 +181,15 @@ describe('Test syndication feeds', () => { for (const server of servers) { { - const json = await getJSONfeed(server.url, 'videos', { accountName: 'root@localhost:' + servers[0].port }) - const jsonObj = JSON.parse(json.text) + const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('my super name for server 1') } { - const json = await getJSONfeed(server.url, 'videos', { accountName: 'john@localhost:' + servers[0].port }) - const jsonObj = JSON.parse(json.text) + const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('user video') } @@ -200,16 +198,16 @@ describe('Test syndication feeds', () => { it('Should filter by video channel', async function () { { - const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: rootChannelId }) - const jsonObj = JSON.parse(json.text) + const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('my super name for server 1') expect(jsonObj.items[0].author.name).to.equal('root') } { - const json = await getJSONfeed(servers[0].url, 'videos', { videoChannelId: userChannelId }) - const jsonObj = JSON.parse(json.text) + const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('user video') expect(jsonObj.items[0].author.name).to.equal('john') @@ -217,15 +215,17 @@ describe('Test syndication feeds', () => { for (const server of servers) { { - const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'root_channel@localhost:' + servers[0].port }) - const jsonObj = JSON.parse(json.text) + const query = { videoChannelName: 'root_channel@localhost:' + servers[0].port } + const json = await server.feedCommand.getJSON({ feed: 'videos', query }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('my super name for server 1') } { - const json = await getJSONfeed(server.url, 'videos', { videoChannelName: 'john_channel@localhost:' + servers[0].port }) - const jsonObj = JSON.parse(json.text) + const query = { videoChannelName: 'john_channel@localhost:' + servers[0].port } + const json = await server.feedCommand.getJSON({ feed: 'videos', query }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('user video') } @@ -239,8 +239,8 @@ describe('Test syndication feeds', () => { await waitJobs([ serverHLSOnly ]) - const json = await getJSONfeed(serverHLSOnly.url, 'videos') - const jsonObj = JSON.parse(json.text) + const json = await serverHLSOnly.feedCommand.getJSON({ feed: 'videos' }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].attachments).to.exist expect(jsonObj.items[0].attachments.length).to.be.eq(4) @@ -257,9 +257,9 @@ describe('Test syndication feeds', () => { it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () { for (const server of servers) { - const json = await getJSONfeed(server.url, 'video-comments') + const json = await server.feedCommand.getJSON({ feed: 'video-comments' }) - const jsonObj = JSON.parse(json.text) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(2) expect(jsonObj.items[0].html_content).to.equal('super comment 2') expect(jsonObj.items[1].html_content).to.equal('super comment 1') @@ -274,8 +274,8 @@ describe('Test syndication feeds', () => { await addAccountToServerBlocklist(servers[1].url, servers[1].accessToken, remoteHandle) { - const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 2 }) - const jsonObj = JSON.parse(json.text) + const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 2 } }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(0) } @@ -287,16 +287,16 @@ describe('Test syndication feeds', () => { await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'super comment') await waitJobs(servers) - const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 3 }) - const jsonObj = JSON.parse(json.text) + const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 3 } }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(3) } await addAccountToAccountBlocklist(servers[1].url, servers[1].accessToken, remoteHandle) { - const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 4 }) - const jsonObj = JSON.parse(json.text) + const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 4 } }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(2) } }) @@ -327,31 +327,30 @@ describe('Test syndication feeds', () => { const res = await listUserSubscriptionVideos(servers[0].url, feeduserAccessToken) expect(res.body.total).to.equal(0) - const json = await getJSONfeed(servers[0].url, 'subscriptions', { accountId: feeduserAccountId, token: feeduserFeedToken }) - const jsonObj = JSON.parse(json.text) + const query = { accountId: feeduserAccountId, token: feeduserFeedToken } + const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos } }) it('Should fail with an invalid token', async function () { - await getJSONfeed(servers[0].url, 'subscriptions', { accountId: feeduserAccountId, token: 'toto' }, HttpStatusCode.FORBIDDEN_403) + const query = { accountId: feeduserAccountId, token: 'toto' } + await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should fail with a token of another user', async function () { - await getJSONfeed( - servers[0].url, - 'subscriptions', - { accountId: feeduserAccountId, token: userFeedToken }, - HttpStatusCode.FORBIDDEN_403 - ) + const query = { accountId: feeduserAccountId, token: userFeedToken } + await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should list no videos for a user with videos but no subscriptions', async function () { const res = await listUserSubscriptionVideos(servers[0].url, userAccessToken) expect(res.body.total).to.equal(0) - const json = await getJSONfeed(servers[0].url, 'subscriptions', { accountId: userAccountId, token: userFeedToken }) - const jsonObj = JSON.parse(json.text) + const query = { accountId: userAccountId, token: userFeedToken } + const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos }) @@ -366,8 +365,9 @@ describe('Test syndication feeds', () => { expect(res.body.total).to.equal(1) expect(res.body.data[0].name).to.equal('user video') - const json = await getJSONfeed(servers[0].url, 'subscriptions', { accountId: userAccountId, token: userFeedToken, version: 1 }) - const jsonObj = JSON.parse(json.text) + const query = { accountId: userAccountId, token: userFeedToken, version: 1 } + const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) // subscribed to self, it should not list the instance's videos but list john's } }) @@ -382,8 +382,9 @@ describe('Test syndication feeds', () => { const res = await listUserSubscriptionVideos(servers[0].url, userAccessToken) expect(res.body.total).to.equal(2, "there should be 2 videos part of the subscription") - const json = await getJSONfeed(servers[0].url, 'subscriptions', { accountId: userAccountId, token: userFeedToken, version: 2 }) - const jsonObj = JSON.parse(json.text) + const query = { accountId: userAccountId, token: userFeedToken, version: 2 } + const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) + const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(2) // subscribed to root, it should not list the instance's videos but list root/john's } }) @@ -391,12 +392,8 @@ describe('Test syndication feeds', () => { it('Should renew the token, and so have an invalid old token', async function () { await renewUserScopedTokens(servers[0].url, userAccessToken) - await getJSONfeed( - servers[0].url, - 'subscriptions', - { accountId: userAccountId, token: userFeedToken, version: 3 }, - HttpStatusCode.FORBIDDEN_403 - ) + const query = { accountId: userAccountId, token: userFeedToken, version: 3 } + await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should succeed with the new token', async function () { @@ -404,7 +401,8 @@ describe('Test syndication feeds', () => { const token: ScopedToken = res2.body userFeedToken = token.feedToken - await getJSONfeed(servers[0].url, 'subscriptions', { accountId: userAccountId, token: userFeedToken, version: 4 }) + const query = { accountId: userAccountId, token: userFeedToken, version: 4 } + await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) }) }) -- cgit v1.2.3 From 5f8bd4cbb178290da7d8f81e996f19f0eccc8e4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 16:02:46 +0200 Subject: Introduce blocklist command --- server/tests/feeds/feeds.ts | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'server/tests/feeds/feeds.ts') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 4d29a2e39..17efc666d 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -3,16 +3,10 @@ import 'mocha' import * as chai from 'chai' import * as xmlParser from 'fast-xml-parser' +import { HttpStatusCode } from '@shared/core-utils' import { - addAccountToAccountBlocklist, - addAccountToServerBlocklist, - removeAccountFromServerBlocklist -} from '@shared/extra-utils/users/blocklist' -import { addUserSubscription, listUserSubscriptionVideos } from '@shared/extra-utils/users/user-subscriptions' -import { VideoPrivacy } from '@shared/models' -import { ScopedToken } from '@shared/models/users/user-scoped-token' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' -import { + addUserSubscription, + addVideoCommentThread, cleanupTests, createUser, doubleFollow, @@ -20,16 +14,17 @@ import { flushAndRunServer, getMyUserInformation, getUserScopedTokens, + listUserSubscriptionVideos, renewUserScopedTokens, ServerInfo, setAccessTokensToServers, uploadVideo, uploadVideoAndGetId, - userLogin -} from '../../../shared/extra-utils' -import { waitJobs } from '../../../shared/extra-utils/server/jobs' -import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' -import { User } from '../../../shared/models/users' + userLogin, + waitJobs +} from '@shared/extra-utils' +import { User, VideoPrivacy } from '@shared/models' +import { ScopedToken } from '@shared/models/users/user-scoped-token' chai.use(require('chai-xml')) chai.use(require('chai-json-schema')) @@ -271,7 +266,7 @@ describe('Test syndication feeds', () => { const remoteHandle = 'root@localhost:' + servers[0].port - await addAccountToServerBlocklist(servers[1].url, servers[1].accessToken, remoteHandle) + await servers[1].blocklistCommand.addToServerBlocklist({ account: remoteHandle }) { const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 2 } }) @@ -279,7 +274,7 @@ describe('Test syndication feeds', () => { expect(jsonObj.items.length).to.be.equal(0) } - await removeAccountFromServerBlocklist(servers[1].url, servers[1].accessToken, remoteHandle) + await servers[1].blocklistCommand.removeFromServerBlocklist({ account: remoteHandle }) { const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'server 2' })).uuid @@ -292,7 +287,7 @@ describe('Test syndication feeds', () => { expect(jsonObj.items.length).to.be.equal(3) } - await addAccountToAccountBlocklist(servers[1].url, servers[1].accessToken, remoteHandle) + await servers[1].blocklistCommand.addToMyBlocklist({ account: remoteHandle }) { const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 4 } }) -- cgit v1.2.3 From 2c27e70471120c92e0bc8c8114141fbb31ff98ac Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 16:40:49 +0200 Subject: Introduce subscriptions command --- server/tests/feeds/feeds.ts | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'server/tests/feeds/feeds.ts') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 17efc666d..6ee22340b 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -5,7 +5,6 @@ import * as chai from 'chai' import * as xmlParser from 'fast-xml-parser' import { HttpStatusCode } from '@shared/core-utils' import { - addUserSubscription, addVideoCommentThread, cleanupTests, createUser, @@ -14,7 +13,6 @@ import { flushAndRunServer, getMyUserInformation, getUserScopedTokens, - listUserSubscriptionVideos, renewUserScopedTokens, ServerInfo, setAccessTokensToServers, @@ -319,8 +317,8 @@ describe('Test syndication feeds', () => { } { - const res = await listUserSubscriptionVideos(servers[0].url, feeduserAccessToken) - expect(res.body.total).to.equal(0) + const body = await servers[0].subscriptionsCommand.listVideos({ token: feeduserAccessToken }) + expect(body.total).to.equal(0) const query = { accountId: feeduserAccountId, token: feeduserFeedToken } const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) @@ -340,8 +338,8 @@ describe('Test syndication feeds', () => { }) it('Should list no videos for a user with videos but no subscriptions', async function () { - const res = await listUserSubscriptionVideos(servers[0].url, userAccessToken) - expect(res.body.total).to.equal(0) + const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) + expect(body.total).to.equal(0) const query = { accountId: userAccountId, token: userFeedToken } const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) @@ -352,13 +350,13 @@ describe('Test syndication feeds', () => { it('Should list self videos for a user with a subscription to themselves', async function () { this.timeout(30000) - await addUserSubscription(servers[0].url, userAccessToken, 'john_channel@localhost:' + servers[0].port) + await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port }) await waitJobs(servers) { - const res = await listUserSubscriptionVideos(servers[0].url, userAccessToken) - expect(res.body.total).to.equal(1) - expect(res.body.data[0].name).to.equal('user video') + const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) + expect(body.total).to.equal(1) + expect(body.data[0].name).to.equal('user video') const query = { accountId: userAccountId, token: userFeedToken, version: 1 } const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) @@ -370,12 +368,12 @@ describe('Test syndication feeds', () => { it('Should list videos of a user\'s subscription', async function () { this.timeout(30000) - await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[0].port) + await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) await waitJobs(servers) { - const res = await listUserSubscriptionVideos(servers[0].url, userAccessToken) - expect(res.body.total).to.equal(2, "there should be 2 videos part of the subscription") + const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) + expect(body.total).to.equal(2, "there should be 2 videos part of the subscription") const query = { accountId: userAccountId, token: userFeedToken, version: 2 } const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) -- cgit v1.2.3 From 12edc1495a36b2199f1bf1ba37f50c7b694be382 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 14:15:11 +0200 Subject: Introduce comments command --- server/tests/feeds/feeds.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'server/tests/feeds/feeds.ts') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 6ee22340b..610849105 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -5,7 +5,6 @@ import * as chai from 'chai' import * as xmlParser from 'fast-xml-parser' import { HttpStatusCode } from '@shared/core-utils' import { - addVideoCommentThread, cleanupTests, createUser, doubleFollow, @@ -90,8 +89,8 @@ describe('Test syndication feeds', () => { const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) const videoId = res.body.video.id - await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'super comment 1') - await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'super comment 2') + await servers[0].commentsCommand.createThread({ videoId, text: 'super comment 1' }) + await servers[0].commentsCommand.createThread({ videoId, text: 'super comment 2' }) } { @@ -99,7 +98,7 @@ describe('Test syndication feeds', () => { const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) const videoId = res.body.video.id - await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'comment on unlisted video') + await servers[0].commentsCommand.createThread({ videoId, text: 'comment on unlisted video' }) } await waitJobs(servers) @@ -277,7 +276,7 @@ describe('Test syndication feeds', () => { { const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'server 2' })).uuid await waitJobs(servers) - await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'super comment') + await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'super comment' }) await waitJobs(servers) const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 3 } }) -- cgit v1.2.3 From 41d1d075011174e73dccb74006181a92a618d7b4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 11:05:15 +0200 Subject: Introduce login command --- server/tests/feeds/feeds.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server/tests/feeds/feeds.ts') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 610849105..9c78ae0e8 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -17,7 +17,6 @@ import { setAccessTokensToServers, uploadVideo, uploadVideoAndGetId, - userLogin, waitJobs } from '@shared/extra-utils' import { User, VideoPrivacy } from '@shared/models' @@ -64,7 +63,7 @@ describe('Test syndication feeds', () => { { const attr = { username: 'john', password: 'password' } await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password }) - userAccessToken = await userLogin(servers[0], attr) + userAccessToken = await servers[0].loginCommand.getAccessToken(attr) const res = await getMyUserInformation(servers[0].url, userAccessToken) const user: User = res.body @@ -301,7 +300,7 @@ describe('Test syndication feeds', () => { it('Should list no videos for a user with no videos and no subscriptions', async function () { const attr = { username: 'feeduser', password: 'password' } await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password }) - const feeduserAccessToken = await userLogin(servers[0], attr) + const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr) { const res = await getMyUserInformation(servers[0].url, feeduserAccessToken) -- cgit v1.2.3 From 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 14:23:01 +0200 Subject: Introduce user command --- server/tests/feeds/feeds.ts | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'server/tests/feeds/feeds.ts') 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' import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, - createUser, doubleFollow, flushAndRunMultipleServers, flushAndRunServer, - getMyUserInformation, - getUserScopedTokens, - renewUserScopedTokens, ServerInfo, setAccessTokensToServers, uploadVideo, uploadVideoAndGetId, waitJobs } from '@shared/extra-utils' -import { User, VideoPrivacy } from '@shared/models' -import { ScopedToken } from '@shared/models/users/user-scoped-token' +import { VideoPrivacy } from '@shared/models' chai.use(require('chai-xml')) chai.use(require('chai-json-schema')) @@ -54,24 +49,21 @@ describe('Test syndication feeds', () => { await doubleFollow(servers[0], servers[1]) { - const res = await getMyUserInformation(servers[0].url, servers[0].accessToken) - const user: User = res.body + const user = await servers[0].usersCommand.getMyInfo() rootAccountId = user.account.id rootChannelId = user.videoChannels[0].id } { const attr = { username: 'john', password: 'password' } - await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password }) + await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) userAccessToken = await servers[0].loginCommand.getAccessToken(attr) - const res = await getMyUserInformation(servers[0].url, userAccessToken) - const user: User = res.body + const user = await servers[0].usersCommand.getMyInfo({ token: userAccessToken }) userAccountId = user.account.id userChannelId = user.videoChannels[0].id - const res2 = await getUserScopedTokens(servers[0].url, userAccessToken) - const token: ScopedToken = res2.body + const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) userFeedToken = token.feedToken } @@ -299,18 +291,16 @@ describe('Test syndication feeds', () => { it('Should list no videos for a user with no videos and no subscriptions', async function () { const attr = { username: 'feeduser', password: 'password' } - await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: attr.username, password: attr.password }) + await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr) { - const res = await getMyUserInformation(servers[0].url, feeduserAccessToken) - const user: User = res.body + const user = await servers[0].usersCommand.getMyInfo({ token: feeduserAccessToken }) feeduserAccountId = user.account.id } { - const res = await getUserScopedTokens(servers[0].url, feeduserAccessToken) - const token: ScopedToken = res.body + const token = await servers[0].usersCommand.getMyScopedTokens({ token: feeduserAccessToken }) feeduserFeedToken = token.feedToken } @@ -381,15 +371,14 @@ describe('Test syndication feeds', () => { }) it('Should renew the token, and so have an invalid old token', async function () { - await renewUserScopedTokens(servers[0].url, userAccessToken) + await servers[0].usersCommand.renewMyScopedTokens({ token: userAccessToken }) const query = { accountId: userAccountId, token: userFeedToken, version: 3 } await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should succeed with the new token', async function () { - const res2 = await getUserScopedTokens(servers[0].url, userAccessToken) - const token: ScopedToken = res2.body + const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) userFeedToken = token.feedToken const query = { accountId: userAccountId, token: userFeedToken, version: 4 } -- cgit v1.2.3 From d23dd9fbfc4d26026352c10f81d2795ceaf2908a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Jul 2021 10:02:54 +0200 Subject: Introduce videos command --- server/tests/feeds/feeds.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'server/tests/feeds/feeds.ts') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 18ce8f7c5..c66cdde1b 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -11,8 +11,6 @@ import { flushAndRunServer, ServerInfo, setAccessTokensToServers, - uploadVideo, - uploadVideoAndGetId, waitJobs } from '@shared/extra-utils' import { VideoPrivacy } from '@shared/models' @@ -68,28 +66,26 @@ describe('Test syndication feeds', () => { } { - await uploadVideo(servers[0].url, userAccessToken, { name: 'user video' }) + await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'user video' } }) } { - const videoAttributes = { + const attributes = { name: 'my super name for server 1', description: 'my super description for server 1', fixture: 'video_short.webm' } - const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) - const videoId = res.body.video.id + const { id } = await servers[0].videosCommand.upload({ attributes }) - await servers[0].commentsCommand.createThread({ videoId, text: 'super comment 1' }) - await servers[0].commentsCommand.createThread({ videoId, text: 'super comment 2' }) + await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 1' }) + await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 2' }) } { - const videoAttributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED } - const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) - const videoId = res.body.video.id + const attributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED } + const { id } = await servers[0].videosCommand.upload({ attributes }) - await servers[0].commentsCommand.createThread({ videoId, text: 'comment on unlisted video' }) + await servers[0].commentsCommand.createThread({ videoId: id, text: 'comment on unlisted video' }) } await waitJobs(servers) @@ -218,7 +214,7 @@ describe('Test syndication feeds', () => { it('Should correctly have videos feed with HLS only', async function () { this.timeout(120000) - await uploadVideo(serverHLSOnly.url, serverHLSOnly.accessToken, { name: 'hls only video' }) + await serverHLSOnly.videosCommand.upload({ attributes: { name: 'hls only video' } }) await waitJobs([ serverHLSOnly ]) @@ -265,7 +261,7 @@ describe('Test syndication feeds', () => { await servers[1].blocklistCommand.removeFromServerBlocklist({ account: remoteHandle }) { - const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'server 2' })).uuid + const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid await waitJobs(servers) await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'super comment' }) await waitJobs(servers) -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/feeds/feeds.ts | 110 ++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'server/tests/feeds/feeds.ts') 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', () => { await doubleFollow(servers[0], servers[1]) { - const user = await servers[0].usersCommand.getMyInfo() + const user = await servers[0].users.getMyInfo() rootAccountId = user.account.id rootChannelId = user.videoChannels[0].id } { const attr = { username: 'john', password: 'password' } - await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) - userAccessToken = await servers[0].loginCommand.getAccessToken(attr) + await servers[0].users.create({ username: attr.username, password: attr.password }) + userAccessToken = await servers[0].login.getAccessToken(attr) - const user = await servers[0].usersCommand.getMyInfo({ token: userAccessToken }) + const user = await servers[0].users.getMyInfo({ token: userAccessToken }) userAccountId = user.account.id userChannelId = user.videoChannels[0].id - const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) + const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken }) userFeedToken = token.feedToken } { - await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'user video' } }) + await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'user video' } }) } { @@ -75,17 +75,17 @@ describe('Test syndication feeds', () => { description: 'my super description for server 1', fixture: 'video_short.webm' } - const { id } = await servers[0].videosCommand.upload({ attributes }) + const { id } = await servers[0].videos.upload({ attributes }) - await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 1' }) - await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 2' }) + await servers[0].comments.createThread({ videoId: id, text: 'super comment 1' }) + await servers[0].comments.createThread({ videoId: id, text: 'super comment 2' }) } { const attributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED } - const { id } = await servers[0].videosCommand.upload({ attributes }) + const { id } = await servers[0].videos.upload({ attributes }) - await servers[0].commentsCommand.createThread({ videoId: id, text: 'comment on unlisted video' }) + await servers[0].comments.createThread({ videoId: id, text: 'comment on unlisted video' }) } await waitJobs(servers) @@ -95,17 +95,17 @@ describe('Test syndication feeds', () => { it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () { for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { - const rss = await servers[0].feedCommand.getXML({ feed }) + const rss = await servers[0].feed.getXML({ feed }) expect(rss).xml.to.be.valid() - const atom = await servers[0].feedCommand.getXML({ feed, format: 'atom' }) + const atom = await servers[0].feed.getXML({ feed, format: 'atom' }) expect(atom).xml.to.be.valid() } }) it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () { for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { - const jsonText = await servers[0].feedCommand.getJSON({ feed }) + const jsonText = await servers[0].feed.getJSON({ feed }) expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' }) } }) @@ -115,7 +115,7 @@ describe('Test syndication feeds', () => { it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () { for (const server of servers) { - const rss = await server.feedCommand.getXML({ feed: 'videos' }) + const rss = await server.feed.getXML({ feed: 'videos' }) expect(xmlParser.validate(rss)).to.be.true const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false }) @@ -130,7 +130,7 @@ describe('Test syndication feeds', () => { it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', async function () { for (const server of servers) { - const json = await server.feedCommand.getJSON({ feed: 'videos' }) + const json = await server.feed.getJSON({ feed: 'videos' }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(2) expect(jsonObj.items[0].attachments).to.exist @@ -143,7 +143,7 @@ describe('Test syndication feeds', () => { it('Should filter by account', async function () { { - const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: rootAccountId } }) + const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: rootAccountId } }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('my super name for server 1') @@ -151,7 +151,7 @@ describe('Test syndication feeds', () => { } { - const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: userAccountId } }) + const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: userAccountId } }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('user video') @@ -160,14 +160,14 @@ describe('Test syndication feeds', () => { for (const server of servers) { { - const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } }) + const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('my super name for server 1') } { - const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } }) + const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('user video') @@ -177,7 +177,7 @@ describe('Test syndication feeds', () => { it('Should filter by video channel', async function () { { - const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } }) + const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('my super name for server 1') @@ -185,7 +185,7 @@ describe('Test syndication feeds', () => { } { - const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } }) + const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('user video') @@ -195,7 +195,7 @@ describe('Test syndication feeds', () => { for (const server of servers) { { const query = { videoChannelName: 'root_channel@localhost:' + servers[0].port } - const json = await server.feedCommand.getJSON({ feed: 'videos', query }) + const json = await server.feed.getJSON({ feed: 'videos', query }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('my super name for server 1') @@ -203,7 +203,7 @@ describe('Test syndication feeds', () => { { const query = { videoChannelName: 'john_channel@localhost:' + servers[0].port } - const json = await server.feedCommand.getJSON({ feed: 'videos', query }) + const json = await server.feed.getJSON({ feed: 'videos', query }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].title).to.equal('user video') @@ -214,11 +214,11 @@ describe('Test syndication feeds', () => { it('Should correctly have videos feed with HLS only', async function () { this.timeout(120000) - await serverHLSOnly.videosCommand.upload({ attributes: { name: 'hls only video' } }) + await serverHLSOnly.videos.upload({ attributes: { name: 'hls only video' } }) await waitJobs([ serverHLSOnly ]) - const json = await serverHLSOnly.feedCommand.getJSON({ feed: 'videos' }) + const json = await serverHLSOnly.feed.getJSON({ feed: 'videos' }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) expect(jsonObj.items[0].attachments).to.exist @@ -236,7 +236,7 @@ describe('Test syndication feeds', () => { it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () { for (const server of servers) { - const json = await server.feedCommand.getJSON({ feed: 'video-comments' }) + const json = await server.feed.getJSON({ feed: 'video-comments' }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(2) @@ -250,31 +250,31 @@ describe('Test syndication feeds', () => { const remoteHandle = 'root@localhost:' + servers[0].port - await servers[1].blocklistCommand.addToServerBlocklist({ account: remoteHandle }) + await servers[1].blocklist.addToServerBlocklist({ account: remoteHandle }) { - const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 2 } }) + const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 2 } }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(0) } - await servers[1].blocklistCommand.removeFromServerBlocklist({ account: remoteHandle }) + await servers[1].blocklist.removeFromServerBlocklist({ account: remoteHandle }) { - const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid + const videoUUID = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid await waitJobs(servers) - await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'super comment' }) + await servers[0].comments.createThread({ videoId: videoUUID, text: 'super comment' }) await waitJobs(servers) - const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 3 } }) + const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 3 } }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(3) } - await servers[1].blocklistCommand.addToMyBlocklist({ account: remoteHandle }) + await servers[1].blocklist.addToMyBlocklist({ account: remoteHandle }) { - const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 4 } }) + const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 4 } }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(2) } @@ -287,25 +287,25 @@ describe('Test syndication feeds', () => { it('Should list no videos for a user with no videos and no subscriptions', async function () { const attr = { username: 'feeduser', password: 'password' } - await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) - const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr) + await servers[0].users.create({ username: attr.username, password: attr.password }) + const feeduserAccessToken = await servers[0].login.getAccessToken(attr) { - const user = await servers[0].usersCommand.getMyInfo({ token: feeduserAccessToken }) + const user = await servers[0].users.getMyInfo({ token: feeduserAccessToken }) feeduserAccountId = user.account.id } { - const token = await servers[0].usersCommand.getMyScopedTokens({ token: feeduserAccessToken }) + const token = await servers[0].users.getMyScopedTokens({ token: feeduserAccessToken }) feeduserFeedToken = token.feedToken } { - const body = await servers[0].subscriptionsCommand.listVideos({ token: feeduserAccessToken }) + const body = await servers[0].subscriptions.listVideos({ token: feeduserAccessToken }) expect(body.total).to.equal(0) const query = { accountId: feeduserAccountId, token: feeduserFeedToken } - const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) + const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos } @@ -313,20 +313,20 @@ describe('Test syndication feeds', () => { it('Should fail with an invalid token', async function () { const query = { accountId: feeduserAccountId, token: 'toto' } - await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) + await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should fail with a token of another user', async function () { const query = { accountId: feeduserAccountId, token: userFeedToken } - await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) + await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should list no videos for a user with videos but no subscriptions', async function () { - const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) + const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) expect(body.total).to.equal(0) const query = { accountId: userAccountId, token: userFeedToken } - const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) + const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos }) @@ -334,16 +334,16 @@ describe('Test syndication feeds', () => { it('Should list self videos for a user with a subscription to themselves', async function () { this.timeout(30000) - await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port }) + await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port }) await waitJobs(servers) { - const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) + const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) expect(body.total).to.equal(1) expect(body.data[0].name).to.equal('user video') const query = { accountId: userAccountId, token: userFeedToken, version: 1 } - const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) + const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(1) // subscribed to self, it should not list the instance's videos but list john's } @@ -352,33 +352,33 @@ describe('Test syndication feeds', () => { it('Should list videos of a user\'s subscription', async function () { this.timeout(30000) - await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) + await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) await waitJobs(servers) { - const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) + const body = await servers[0].subscriptions.listVideos({ token: userAccessToken }) expect(body.total).to.equal(2, "there should be 2 videos part of the subscription") const query = { accountId: userAccountId, token: userFeedToken, version: 2 } - const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) + const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query }) const jsonObj = JSON.parse(json) expect(jsonObj.items.length).to.be.equal(2) // subscribed to root, it should not list the instance's videos but list root/john's } }) it('Should renew the token, and so have an invalid old token', async function () { - await servers[0].usersCommand.renewMyScopedTokens({ token: userAccessToken }) + await servers[0].users.renewMyScopedTokens({ token: userAccessToken }) const query = { accountId: userAccountId, token: userFeedToken, version: 3 } - await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) + await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) it('Should succeed with the new token', async function () { - const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) + const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken }) userFeedToken = token.feedToken const query = { accountId: userAccountId, token: userFeedToken, version: 4 } - await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) + await servers[0].feed.getJSON({ feed: 'subscriptions', query }) }) }) -- cgit v1.2.3 From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/feeds/feeds.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'server/tests/feeds/feeds.ts') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 8bdafc644..7735299d3 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -7,9 +7,9 @@ import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, doubleFollow, - flushAndRunMultipleServers, - flushAndRunServer, - ServerInfo, + createMultipleServers, + createSingleServer, + PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' @@ -21,8 +21,8 @@ chai.config.includeStack = true const expect = chai.expect describe('Test syndication feeds', () => { - let servers: ServerInfo[] = [] - let serverHLSOnly: ServerInfo + let servers: PeerTubeServer[] = [] + let serverHLSOnly: PeerTubeServer let userAccessToken: string let rootAccountId: number let rootChannelId: number @@ -34,8 +34,8 @@ describe('Test syndication feeds', () => { this.timeout(120000) // Run servers - servers = await flushAndRunMultipleServers(2) - serverHLSOnly = await flushAndRunServer(3, { + servers = await createMultipleServers(2) + serverHLSOnly = await createSingleServer(3, { transcoding: { enabled: true, webtorrent: { enabled: false }, -- cgit v1.2.3 From c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/tests/feeds/feeds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/feeds/feeds.ts') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 7735299d3..543c431dd 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -3,7 +3,7 @@ import 'mocha' import * as chai from 'chai' import * as xmlParser from 'fast-xml-parser' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, doubleFollow, -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/tests/feeds/feeds.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server/tests/feeds/feeds.ts') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 543c431dd..5667207c0 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -3,17 +3,16 @@ import 'mocha' import * as chai from 'chai' import * as xmlParser from 'fast-xml-parser' -import { HttpStatusCode } from '@shared/models' import { cleanupTests, - doubleFollow, createMultipleServers, createSingleServer, + doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' -import { VideoPrivacy } from '@shared/models' +import { HttpStatusCode, VideoPrivacy } from '@shared/models' chai.use(require('chai-xml')) chai.use(require('chai-json-schema')) -- cgit v1.2.3