Introduce follows command
This commit is contained in:
parent
883a901908
commit
c3d29f694b
|
@ -15,7 +15,6 @@ import {
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
findCommentId,
|
findCommentId,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
follow,
|
|
||||||
getAccountBlocklistByAccount,
|
getAccountBlocklistByAccount,
|
||||||
getAccountBlocklistByServer,
|
getAccountBlocklistByServer,
|
||||||
getServerBlocklistByAccount,
|
getServerBlocklistByAccount,
|
||||||
|
@ -31,7 +30,6 @@ import {
|
||||||
removeServerFromServerBlocklist,
|
removeServerFromServerBlocklist,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
unfollow,
|
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
userLogin,
|
||||||
waitJobs
|
waitJobs
|
||||||
|
@ -742,9 +740,9 @@ describe('Test blocklist', function () {
|
||||||
|
|
||||||
{
|
{
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
await unfollow(servers[1].url, servers[1].accessToken, servers[0])
|
await servers[1].followsCommand.unfollow({ target: servers[0] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await follow(servers[1].url, [ servers[0].host ], servers[1].accessToken)
|
await servers[1].followsCommand.follow({ targets: [ servers[0].host ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -807,9 +805,9 @@ describe('Test blocklist', function () {
|
||||||
|
|
||||||
{
|
{
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
await unfollow(servers[1].url, servers[1].accessToken, servers[0])
|
await servers[1].followsCommand.unfollow({ target: servers[0] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await follow(servers[1].url, [ servers[0].host ], servers[1].accessToken)
|
await servers[1].followsCommand.follow({ targets: [ servers[0].host ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import {
|
||||||
checkVideoIsPublished,
|
checkVideoIsPublished,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
follow,
|
|
||||||
generateUserAccessToken,
|
generateUserAccessToken,
|
||||||
getAccount,
|
getAccount,
|
||||||
getCustomConfig,
|
getCustomConfig,
|
||||||
|
@ -35,7 +34,6 @@ import {
|
||||||
removeUserSubscription,
|
removeUserSubscription,
|
||||||
removeVideoFromBlacklist,
|
removeVideoFromBlacklist,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
unfollow,
|
|
||||||
updateCustomConfig,
|
updateCustomConfig,
|
||||||
updateCustomSubConfig,
|
updateCustomSubConfig,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
|
@ -386,7 +384,7 @@ describe('Test moderation notifications', function () {
|
||||||
it('Should send a notification only to admin when there is a new instance follower', async function () {
|
it('Should send a notification only to admin when there is a new instance follower', async function () {
|
||||||
this.timeout(20000)
|
this.timeout(20000)
|
||||||
|
|
||||||
await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
|
await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -399,7 +397,7 @@ describe('Test moderation notifications', function () {
|
||||||
it('Should send a notification on auto follow back', async function () {
|
it('Should send a notification on auto follow back', async function () {
|
||||||
this.timeout(40000)
|
this.timeout(40000)
|
||||||
|
|
||||||
await unfollow(servers[2].url, servers[2].accessToken, servers[0])
|
await servers[2].followsCommand.unfollow({ target: servers[0] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
@ -411,7 +409,7 @@ describe('Test moderation notifications', function () {
|
||||||
}
|
}
|
||||||
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
||||||
|
|
||||||
await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
|
await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -424,13 +422,13 @@ describe('Test moderation notifications', function () {
|
||||||
|
|
||||||
config.followings.instance.autoFollowBack.enabled = false
|
config.followings.instance.autoFollowBack.enabled = false
|
||||||
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
||||||
await unfollow(servers[0].url, servers[0].accessToken, servers[2])
|
await servers[0].followsCommand.unfollow({ target: servers[2] })
|
||||||
await unfollow(servers[2].url, servers[2].accessToken, servers[0])
|
await servers[2].followsCommand.unfollow({ target: servers[0] })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should send a notification on auto instances index follow', async function () {
|
it('Should send a notification on auto instances index follow', async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
await unfollow(servers[0].url, servers[0].accessToken, servers[1])
|
await servers[0].followsCommand.unfollow({ target: servers[1] })
|
||||||
|
|
||||||
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
||||||
|
|
||||||
|
@ -443,7 +441,7 @@ describe('Test moderation notifications', function () {
|
||||||
|
|
||||||
config.followings.instance.autoFollowIndex.enabled = false
|
config.followings.instance.autoFollowIndex.enabled = false
|
||||||
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
||||||
await unfollow(servers[0].url, servers[0].accessToken, servers[1])
|
await servers[0].followsCommand.unfollow({ target: servers[1] })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { VideoPrivacy } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
follow,
|
|
||||||
killallServers,
|
killallServers,
|
||||||
reRunServer,
|
reRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
@ -98,7 +97,7 @@ describe('Test redundancy constraints', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
// Server 1 and server 2 follow each other
|
// Server 1 and server 2 follow each other
|
||||||
await follow(remoteServer.url, [ localServer.url ], remoteServer.accessToken)
|
await remoteServer.followsCommand.follow({ targets: [ localServer.url ] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await updateRedundancy(remoteServer.url, remoteServer.accessToken, localServer.host, true)
|
await updateRedundancy(remoteServer.url, remoteServer.accessToken, localServer.host, true)
|
||||||
|
|
||||||
|
@ -184,7 +183,7 @@ describe('Test redundancy constraints', function () {
|
||||||
it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () {
|
it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
|
||||||
await follow(localServer.url, [ remoteServer.url ], localServer.accessToken)
|
await localServer.followsCommand.follow({ targets: [ remoteServer.url ] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await uploadWrapper('video 4 server 2')
|
await uploadWrapper('video 4 server 2')
|
||||||
|
|
|
@ -12,7 +12,6 @@ import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
getFollowingListPaginationAndSort,
|
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideoWithToken,
|
getVideoWithToken,
|
||||||
immutableAssign,
|
immutableAssign,
|
||||||
|
@ -23,7 +22,6 @@ import {
|
||||||
root,
|
root,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
unfollow,
|
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
viewVideo,
|
viewVideo,
|
||||||
|
@ -38,7 +36,6 @@ import {
|
||||||
updateRedundancy
|
updateRedundancy
|
||||||
} from '../../../../shared/extra-utils/server/redundancy'
|
} from '../../../../shared/extra-utils/server/redundancy'
|
||||||
import { getStats } from '../../../../shared/extra-utils/server/stats'
|
import { getStats } from '../../../../shared/extra-utils/server/stats'
|
||||||
import { ActorFollow } from '../../../../shared/models/actors'
|
|
||||||
import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy'
|
import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy'
|
||||||
import { ServerStats } from '../../../../shared/models/server/server-stats.model'
|
import { ServerStats } from '../../../../shared/models/server/server-stats.model'
|
||||||
import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
|
import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos'
|
||||||
|
@ -272,13 +269,19 @@ async function checkStatsWithoutRedundancy (strategy: VideoRedundancyStrategyWit
|
||||||
expect(stat.totalVideos).to.equal(0)
|
expect(stat.totalVideos).to.equal(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function findServerFollows () {
|
||||||
|
const body = await servers[0].followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
|
||||||
|
const follows = body.data
|
||||||
|
const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
|
||||||
|
const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
|
||||||
|
|
||||||
|
return { server2, server3 }
|
||||||
|
}
|
||||||
|
|
||||||
async function enableRedundancyOnServer1 () {
|
async function enableRedundancyOnServer1 () {
|
||||||
await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, true)
|
await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, true)
|
||||||
|
|
||||||
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: '-createdAt' })
|
const { server2, server3 } = await findServerFollows()
|
||||||
const follows: ActorFollow[] = res.body.data
|
|
||||||
const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
|
|
||||||
const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
|
|
||||||
|
|
||||||
expect(server3).to.not.be.undefined
|
expect(server3).to.not.be.undefined
|
||||||
expect(server3.following.hostRedundancyAllowed).to.be.false
|
expect(server3.following.hostRedundancyAllowed).to.be.false
|
||||||
|
@ -290,10 +293,7 @@ async function enableRedundancyOnServer1 () {
|
||||||
async function disableRedundancyOnServer1 () {
|
async function disableRedundancyOnServer1 () {
|
||||||
await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, false)
|
await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, false)
|
||||||
|
|
||||||
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: '-createdAt' })
|
const { server2, server3 } = await findServerFollows()
|
||||||
const follows: ActorFollow[] = res.body.data
|
|
||||||
const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
|
|
||||||
const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
|
|
||||||
|
|
||||||
expect(server3).to.not.be.undefined
|
expect(server3).to.not.be.undefined
|
||||||
expect(server3.following.hostRedundancyAllowed).to.be.false
|
expect(server3.following.hostRedundancyAllowed).to.be.false
|
||||||
|
@ -388,7 +388,7 @@ describe('Test videos redundancy', function () {
|
||||||
it('Should unfollow on server 1 and remove duplicated videos', async function () {
|
it('Should unfollow on server 1 and remove duplicated videos', async function () {
|
||||||
this.timeout(80000)
|
this.timeout(80000)
|
||||||
|
|
||||||
await unfollow(servers[0].url, servers[0].accessToken, servers[1])
|
await servers[0].followsCommand.unfollow({ target: servers[1] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await wait(5000)
|
await wait(5000)
|
||||||
|
|
|
@ -3,64 +3,46 @@
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import {
|
import {
|
||||||
acceptFollower,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
MockInstancesIndex,
|
MockInstancesIndex,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
unfollow,
|
|
||||||
updateCustomSubConfig,
|
updateCustomSubConfig,
|
||||||
wait
|
wait,
|
||||||
} from '../../../../shared/extra-utils/index'
|
waitJobs
|
||||||
import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort } from '../../../../shared/extra-utils/server/follows'
|
} from '@shared/extra-utils'
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
|
||||||
import { ActorFollow } from '../../../../shared/models/actors'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
async function checkFollow (follower: ServerInfo, following: ServerInfo, exists: boolean) {
|
async function checkFollow (follower: ServerInfo, following: ServerInfo, exists: boolean) {
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({ url: following.url, start: 0, count: 5, sort: '-createdAt' })
|
const body = await following.followsCommand.getFollowers({ start: 0, count: 5, sort: '-createdAt' })
|
||||||
const follows = res.body.data as ActorFollow[]
|
const follow = body.data.find(f => f.follower.host === follower.host && f.state === 'accepted')
|
||||||
|
|
||||||
const follow = follows.find(f => {
|
if (exists === true) expect(follow).to.exist
|
||||||
return f.follower.host === follower.host && f.state === 'accepted'
|
else expect(follow).to.be.undefined
|
||||||
})
|
|
||||||
|
|
||||||
if (exists === true) {
|
|
||||||
expect(follow).to.exist
|
|
||||||
} else {
|
|
||||||
expect(follow).to.be.undefined
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowingListPaginationAndSort({ url: follower.url, start: 0, count: 5, sort: '-createdAt' })
|
const body = await follower.followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
|
||||||
const follows = res.body.data as ActorFollow[]
|
const follow = body.data.find(f => f.following.host === following.host && f.state === 'accepted')
|
||||||
|
|
||||||
const follow = follows.find(f => {
|
if (exists === true) expect(follow).to.exist
|
||||||
return f.following.host === following.host && f.state === 'accepted'
|
else expect(follow).to.be.undefined
|
||||||
})
|
|
||||||
|
|
||||||
if (exists === true) {
|
|
||||||
expect(follow).to.exist
|
|
||||||
} else {
|
|
||||||
expect(follow).to.be.undefined
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function server1Follows2 (servers: ServerInfo[]) {
|
async function server1Follows2 (servers: ServerInfo[]) {
|
||||||
await follow(servers[0].url, [ servers[1].host ], servers[0].accessToken)
|
await servers[0].followsCommand.follow({ targets: [ servers[1].host ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resetFollows (servers: ServerInfo[]) {
|
async function resetFollows (servers: ServerInfo[]) {
|
||||||
try {
|
try {
|
||||||
await unfollow(servers[0].url, servers[0].accessToken, servers[1])
|
await servers[0].followsCommand.unfollow({ target: servers[1] })
|
||||||
await unfollow(servers[1].url, servers[1].accessToken, servers[0])
|
await servers[1].followsCommand.unfollow({ target: servers[0] })
|
||||||
} catch { /* empty */
|
} catch { /* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +119,7 @@ describe('Test auto follows', function () {
|
||||||
await checkFollow(servers[0], servers[1], false)
|
await checkFollow(servers[0], servers[1], false)
|
||||||
await checkFollow(servers[1], servers[0], false)
|
await checkFollow(servers[1], servers[0], false)
|
||||||
|
|
||||||
await acceptFollower(servers[1].url, servers[1].accessToken, 'peertube@' + servers[0].host)
|
await servers[1].followsCommand.acceptFollower({ follower: 'peertube@' + servers[0].host })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await checkFollow(servers[0], servers[1], true)
|
await checkFollow(servers[0], servers[1], true)
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import * as chai from 'chai'
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
|
import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
createUser,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
getAccountVideos,
|
getAccountVideos,
|
||||||
|
@ -12,13 +15,9 @@ import {
|
||||||
getVideoWithToken,
|
getVideoWithToken,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo
|
uploadVideo,
|
||||||
|
userLogin
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { unfollow } from '../../../../shared/extra-utils/server/follows'
|
|
||||||
import { userLogin } from '../../../../shared/extra-utils/users/login'
|
|
||||||
import { createUser } from '../../../../shared/extra-utils/users/users'
|
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -144,7 +143,7 @@ describe('Test follow constraints', function () {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
await unfollow(servers[0].url, servers[0].accessToken, servers[1])
|
await servers[0].followsCommand.unfollow({ target: servers[1] })
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('With an unlogged user', function () {
|
describe('With an unlogged user', function () {
|
||||||
|
|
|
@ -1,43 +1,30 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import * as chai from 'chai'
|
||||||
import {
|
import {
|
||||||
acceptFollower,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
|
FollowsCommand,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateCustomSubConfig
|
updateCustomSubConfig,
|
||||||
} from '../../../../shared/extra-utils/index'
|
waitJobs
|
||||||
import {
|
} from '@shared/extra-utils'
|
||||||
follow,
|
|
||||||
getFollowersListPaginationAndSort,
|
|
||||||
getFollowingListPaginationAndSort,
|
|
||||||
rejectFollower,
|
|
||||||
removeFollower
|
|
||||||
} from '../../../../shared/extra-utils/server/follows'
|
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
|
||||||
import { ActorFollow } from '../../../../shared/models/actors'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accepted') {
|
async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accepted') {
|
||||||
{
|
const fns = [
|
||||||
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
|
servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand),
|
||||||
expect(res.body.total).to.equal(1)
|
servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand)
|
||||||
|
]
|
||||||
|
|
||||||
const follow = res.body.data[0] as ActorFollow
|
for (const fn of fns) {
|
||||||
expect(follow.state).to.equal(state)
|
const body = await fn({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')
|
expect(body.total).to.equal(1)
|
||||||
expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
const follow = body.data[0]
|
||||||
const res = await getFollowersListPaginationAndSort({ url: servers[1].url, start: 0, count: 5, sort: 'createdAt' })
|
|
||||||
expect(res.body.total).to.equal(1)
|
|
||||||
|
|
||||||
const follow = res.body.data[0] as ActorFollow
|
|
||||||
expect(follow.state).to.equal(state)
|
expect(follow.state).to.equal(state)
|
||||||
expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')
|
expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')
|
||||||
expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
|
expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
|
||||||
|
@ -45,19 +32,20 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkNoFollowers (servers: ServerInfo[]) {
|
async function checkNoFollowers (servers: ServerInfo[]) {
|
||||||
{
|
const fns = [
|
||||||
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
|
servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand),
|
||||||
expect(res.body.total).to.equal(0)
|
servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand)
|
||||||
}
|
]
|
||||||
|
|
||||||
{
|
for (const fn of fns) {
|
||||||
const res = await getFollowersListPaginationAndSort({ url: servers[1].url, start: 0, count: 5, sort: 'createdAt' })
|
const body = await fn({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
expect(res.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Test follows moderation', function () {
|
describe('Test follows moderation', function () {
|
||||||
let servers: ServerInfo[] = []
|
let servers: ServerInfo[] = []
|
||||||
|
let commands: FollowsCommand[]
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
@ -66,12 +54,14 @@ describe('Test follows moderation', function () {
|
||||||
|
|
||||||
// Get the access tokens
|
// Get the access tokens
|
||||||
await setAccessTokensToServers(servers)
|
await setAccessTokensToServers(servers)
|
||||||
|
|
||||||
|
commands = servers.map(s => s.followsCommand)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have server 1 following server 2', async function () {
|
it('Should have server 1 following server 2', async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
await follow(servers[0].url, [ servers[1].url ], servers[0].accessToken)
|
await commands[0].follow({ targets: [ servers[1].url ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
@ -83,7 +73,7 @@ describe('Test follows moderation', function () {
|
||||||
it('Should remove follower on server 2', async function () {
|
it('Should remove follower on server 2', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await removeFollower(servers[1].url, servers[1].accessToken, servers[0])
|
await commands[1].removeFollower({ follower: servers[0] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
@ -106,7 +96,7 @@ describe('Test follows moderation', function () {
|
||||||
|
|
||||||
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig)
|
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig)
|
||||||
|
|
||||||
await follow(servers[0].url, [ servers[1].url ], servers[0].accessToken)
|
await commands[0].follow({ targets: [ servers[1].url ] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await checkNoFollowers(servers)
|
await checkNoFollowers(servers)
|
||||||
|
@ -126,7 +116,7 @@ describe('Test follows moderation', function () {
|
||||||
|
|
||||||
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig)
|
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig)
|
||||||
|
|
||||||
await follow(servers[0].url, [ servers[1].url ], servers[0].accessToken)
|
await commands[0].follow({ targets: [ servers[1].url ] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await checkServer1And2HasFollowers(servers)
|
await checkServer1And2HasFollowers(servers)
|
||||||
|
@ -135,7 +125,7 @@ describe('Test follows moderation', function () {
|
||||||
it('Should manually approve followers', async function () {
|
it('Should manually approve followers', async function () {
|
||||||
this.timeout(20000)
|
this.timeout(20000)
|
||||||
|
|
||||||
await removeFollower(servers[1].url, servers[1].accessToken, servers[0])
|
await commands[1].removeFollower({ follower: servers[0] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
const subConfig = {
|
const subConfig = {
|
||||||
|
@ -150,7 +140,7 @@ describe('Test follows moderation', function () {
|
||||||
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig)
|
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, subConfig)
|
||||||
await updateCustomSubConfig(servers[2].url, servers[2].accessToken, subConfig)
|
await updateCustomSubConfig(servers[2].url, servers[2].accessToken, subConfig)
|
||||||
|
|
||||||
await follow(servers[0].url, [ servers[1].url ], servers[0].accessToken)
|
await commands[0].follow({ targets: [ servers[1].url ] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await checkServer1And2HasFollowers(servers, 'pending')
|
await checkServer1And2HasFollowers(servers, 'pending')
|
||||||
|
@ -159,7 +149,7 @@ describe('Test follows moderation', function () {
|
||||||
it('Should accept a follower', async function () {
|
it('Should accept a follower', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await acceptFollower(servers[1].url, servers[1].accessToken, 'peertube@localhost:' + servers[0].port)
|
await commands[1].acceptFollower({ follower: 'peertube@localhost:' + servers[0].port })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await checkServer1And2HasFollowers(servers)
|
await checkServer1And2HasFollowers(servers)
|
||||||
|
@ -168,32 +158,32 @@ describe('Test follows moderation', function () {
|
||||||
it('Should reject another follower', async function () {
|
it('Should reject another follower', async function () {
|
||||||
this.timeout(20000)
|
this.timeout(20000)
|
||||||
|
|
||||||
await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken)
|
await commands[0].follow({ targets: [ servers[2].url ] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
|
const body = await commands[0].getFollowings({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
expect(res.body.total).to.equal(2)
|
expect(body.total).to.equal(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({ url: servers[1].url, start: 0, count: 5, sort: 'createdAt' })
|
const body = await commands[1].getFollowers({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
expect(res.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({ url: servers[2].url, start: 0, count: 5, sort: 'createdAt' })
|
const body = await commands[2].getFollowers({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
expect(res.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
await rejectFollower(servers[2].url, servers[2].accessToken, 'peertube@localhost:' + servers[0].port)
|
await commands[2].rejectFollower({ follower: 'peertube@localhost:' + servers[0].port })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await checkServer1And2HasFollowers(servers)
|
await checkServer1And2HasFollowers(servers)
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({ url: servers[2].url, start: 0, count: 5, sort: 'createdAt' })
|
const body = await commands[2].getFollowers({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
expect(res.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,7 @@ import {
|
||||||
deleteVideoComment,
|
deleteVideoComment,
|
||||||
expectAccountFollows,
|
expectAccountFollows,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
follow,
|
FollowsCommand,
|
||||||
getFollowersListPaginationAndSort,
|
|
||||||
getFollowingListPaginationAndSort,
|
|
||||||
getVideoCommentThreads,
|
getVideoCommentThreads,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
getVideoThreadComments,
|
getVideoThreadComments,
|
||||||
|
@ -24,7 +22,6 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
testCaptionFile,
|
testCaptionFile,
|
||||||
unfollow,
|
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
userLogin,
|
||||||
waitJobs
|
waitJobs
|
||||||
|
@ -35,11 +32,13 @@ const expect = chai.expect
|
||||||
|
|
||||||
describe('Test follows', function () {
|
describe('Test follows', function () {
|
||||||
let servers: ServerInfo[] = []
|
let servers: ServerInfo[] = []
|
||||||
|
let followsCommands: FollowsCommand[]
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
servers = await flushAndRunMultipleServers(3)
|
servers = await flushAndRunMultipleServers(3)
|
||||||
|
followsCommands = servers.map(s => s.followsCommand)
|
||||||
|
|
||||||
// Get the access tokens
|
// Get the access tokens
|
||||||
await setAccessTokensToServers(servers)
|
await setAccessTokensToServers(servers)
|
||||||
|
@ -47,10 +46,10 @@ describe('Test follows', function () {
|
||||||
|
|
||||||
it('Should not have followers', async function () {
|
it('Should not have followers', async function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const res = await getFollowersListPaginationAndSort({ url: server.url, start: 0, count: 5, sort: 'createdAt' })
|
const body = await server.followsCommand.getFollowers({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
const follows = res.body.data
|
expect(body.total).to.equal(0)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(0)
|
const follows = body.data
|
||||||
expect(follows).to.be.an('array')
|
expect(follows).to.be.an('array')
|
||||||
expect(follows.length).to.equal(0)
|
expect(follows.length).to.equal(0)
|
||||||
}
|
}
|
||||||
|
@ -58,10 +57,10 @@ describe('Test follows', function () {
|
||||||
|
|
||||||
it('Should not have following', async function () {
|
it('Should not have following', async function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const res = await getFollowingListPaginationAndSort({ url: server.url, start: 0, count: 5, sort: 'createdAt' })
|
const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
const follows = res.body.data
|
expect(body.total).to.equal(0)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(0)
|
const follows = body.data
|
||||||
expect(follows).to.be.an('array')
|
expect(follows).to.be.an('array')
|
||||||
expect(follows.length).to.equal(0)
|
expect(follows.length).to.equal(0)
|
||||||
}
|
}
|
||||||
|
@ -70,21 +69,21 @@ describe('Test follows', function () {
|
||||||
it('Should have server 1 following server 2 and 3', async function () {
|
it('Should have server 1 following server 2 and 3', async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
await follow(servers[0].url, [ servers[1].url, servers[2].url ], servers[0].accessToken)
|
await followsCommands[0].follow({ targets: [ servers[1].url, servers[2].url ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have 2 followings on server 1', async function () {
|
it('Should have 2 followings on server 1', async function () {
|
||||||
let res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 1, sort: 'createdAt' })
|
const body = await followsCommands[0].getFollowings({ start: 0, count: 1, sort: 'createdAt' })
|
||||||
let follows = res.body.data
|
expect(body.total).to.equal(2)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(2)
|
let follows = body.data
|
||||||
expect(follows).to.be.an('array')
|
expect(follows).to.be.an('array')
|
||||||
expect(follows.length).to.equal(1)
|
expect(follows.length).to.equal(1)
|
||||||
|
|
||||||
res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 1, count: 1, sort: 'createdAt' })
|
const body2 = await followsCommands[0].getFollowings({ start: 1, count: 1, sort: 'createdAt' })
|
||||||
follows = follows.concat(res.body.data)
|
follows = follows.concat(body2.data)
|
||||||
|
|
||||||
const server2Follow = follows.find(f => f.following.host === 'localhost:' + servers[1].port)
|
const server2Follow = follows.find(f => f.following.host === 'localhost:' + servers[1].port)
|
||||||
const server3Follow = follows.find(f => f.following.host === 'localhost:' + servers[2].port)
|
const server3Follow = follows.find(f => f.following.host === 'localhost:' + servers[2].port)
|
||||||
|
@ -99,35 +98,33 @@ describe('Test follows', function () {
|
||||||
const sort = 'createdAt'
|
const sort = 'createdAt'
|
||||||
const start = 0
|
const start = 0
|
||||||
const count = 1
|
const count = 1
|
||||||
const url = servers[0].url
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const search = ':' + servers[1].port
|
const search = ':' + servers[1].port
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowingListPaginationAndSort({ url, start, count, sort, search })
|
const body = await followsCommands[0].getFollowings({ start, count, sort, search })
|
||||||
const follows = res.body.data
|
expect(body.total).to.equal(1)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(1)
|
const follows = body.data
|
||||||
expect(follows.length).to.equal(1)
|
expect(follows.length).to.equal(1)
|
||||||
expect(follows[0].following.host).to.equal('localhost:' + servers[1].port)
|
expect(follows[0].following.host).to.equal('localhost:' + servers[1].port)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowingListPaginationAndSort({ url, start, count, sort, search, state: 'accepted' })
|
const body = await followsCommands[0].getFollowings({ start, count, sort, search, state: 'accepted' })
|
||||||
expect(res.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
expect(res.body.data).to.have.lengthOf(1)
|
expect(body.data).to.have.lengthOf(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowingListPaginationAndSort({ url, start, count, sort, search, state: 'accepted', actorType: 'Person' })
|
const body = await followsCommands[0].getFollowings({ start, count, sort, search, state: 'accepted', actorType: 'Person' })
|
||||||
expect(res.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(res.body.data).to.have.lengthOf(0)
|
expect(body.data).to.have.lengthOf(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowingListPaginationAndSort({
|
const body = await followsCommands[0].getFollowings({
|
||||||
url,
|
|
||||||
start,
|
start,
|
||||||
count,
|
count,
|
||||||
sort,
|
sort,
|
||||||
|
@ -135,32 +132,31 @@ describe('Test follows', function () {
|
||||||
state: 'accepted',
|
state: 'accepted',
|
||||||
actorType: 'Application'
|
actorType: 'Application'
|
||||||
})
|
})
|
||||||
expect(res.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
expect(res.body.data).to.have.lengthOf(1)
|
expect(body.data).to.have.lengthOf(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowingListPaginationAndSort({ url, start, count, sort, search, state: 'pending' })
|
const body = await followsCommands[0].getFollowings({ start, count, sort, search, state: 'pending' })
|
||||||
expect(res.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(res.body.data).to.have.lengthOf(0)
|
expect(body.data).to.have.lengthOf(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowingListPaginationAndSort({ url, start, count, sort, search: 'bla' })
|
const body = await followsCommands[0].getFollowings({ start, count, sort, search: 'bla' })
|
||||||
const follows = res.body.data
|
expect(body.total).to.equal(0)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(0)
|
expect(body.data.length).to.equal(0)
|
||||||
expect(follows.length).to.equal(0)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have 0 followings on server 2 and 3', async function () {
|
it('Should have 0 followings on server 2 and 3', async function () {
|
||||||
for (const server of [ servers[1], servers[2] ]) {
|
for (const server of [ servers[1], servers[2] ]) {
|
||||||
const res = await getFollowingListPaginationAndSort({ url: server.url, start: 0, count: 5, sort: 'createdAt' })
|
const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
const follows = res.body.data
|
expect(body.total).to.equal(0)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(0)
|
const follows = body.data
|
||||||
expect(follows).to.be.an('array')
|
expect(follows).to.be.an('array')
|
||||||
expect(follows.length).to.equal(0)
|
expect(follows.length).to.equal(0)
|
||||||
}
|
}
|
||||||
|
@ -168,10 +164,10 @@ describe('Test follows', function () {
|
||||||
|
|
||||||
it('Should have 1 followers on server 2 and 3', async function () {
|
it('Should have 1 followers on server 2 and 3', async function () {
|
||||||
for (const server of [ servers[1], servers[2] ]) {
|
for (const server of [ servers[1], servers[2] ]) {
|
||||||
const res = await getFollowersListPaginationAndSort({ url: server.url, start: 0, count: 1, sort: 'createdAt' })
|
const body = await server.followsCommand.getFollowers({ start: 0, count: 1, sort: 'createdAt' })
|
||||||
|
expect(body.total).to.equal(1)
|
||||||
|
|
||||||
const follows = res.body.data
|
const follows = body.data
|
||||||
expect(res.body.total).to.equal(1)
|
|
||||||
expect(follows).to.be.an('array')
|
expect(follows).to.be.an('array')
|
||||||
expect(follows.length).to.equal(1)
|
expect(follows.length).to.equal(1)
|
||||||
expect(follows[0].follower.host).to.equal('localhost:' + servers[0].port)
|
expect(follows[0].follower.host).to.equal('localhost:' + servers[0].port)
|
||||||
|
@ -179,7 +175,6 @@ describe('Test follows', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should search/filter followers on server 2', async function () {
|
it('Should search/filter followers on server 2', async function () {
|
||||||
const url = servers[2].url
|
|
||||||
const start = 0
|
const start = 0
|
||||||
const count = 5
|
const count = 5
|
||||||
const sort = 'createdAt'
|
const sort = 'createdAt'
|
||||||
|
@ -188,29 +183,28 @@ describe('Test follows', function () {
|
||||||
const search = servers[0].port + ''
|
const search = servers[0].port + ''
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({ url, start, count, sort, search })
|
const body = await followsCommands[2].getFollowers({ start, count, sort, search })
|
||||||
const follows = res.body.data
|
expect(body.total).to.equal(1)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(1)
|
const follows = body.data
|
||||||
expect(follows.length).to.equal(1)
|
expect(follows.length).to.equal(1)
|
||||||
expect(follows[0].following.host).to.equal('localhost:' + servers[2].port)
|
expect(follows[0].following.host).to.equal('localhost:' + servers[2].port)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({ url, start, count, sort, search, state: 'accepted' })
|
const body = await followsCommands[2].getFollowers({ start, count, sort, search, state: 'accepted' })
|
||||||
expect(res.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
expect(res.body.data).to.have.lengthOf(1)
|
expect(body.data).to.have.lengthOf(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({ url, start, count, sort, search, state: 'accepted', actorType: 'Person' })
|
const body = await followsCommands[2].getFollowers({ start, count, sort, search, state: 'accepted', actorType: 'Person' })
|
||||||
expect(res.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(res.body.data).to.have.lengthOf(0)
|
expect(body.data).to.have.lengthOf(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({
|
const body = await followsCommands[2].getFollowers({
|
||||||
url,
|
|
||||||
start,
|
start,
|
||||||
count,
|
count,
|
||||||
sort,
|
sort,
|
||||||
|
@ -218,31 +212,31 @@ describe('Test follows', function () {
|
||||||
state: 'accepted',
|
state: 'accepted',
|
||||||
actorType: 'Application'
|
actorType: 'Application'
|
||||||
})
|
})
|
||||||
expect(res.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
expect(res.body.data).to.have.lengthOf(1)
|
expect(body.data).to.have.lengthOf(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({ url, start, count, sort, search, state: 'pending' })
|
const body = await followsCommands[2].getFollowers({ start, count, sort, search, state: 'pending' })
|
||||||
expect(res.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(res.body.data).to.have.lengthOf(0)
|
expect(body.data).to.have.lengthOf(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getFollowersListPaginationAndSort({ url, start, count, sort, search: 'bla' })
|
const body = await followsCommands[2].getFollowers({ start, count, sort, search: 'bla' })
|
||||||
const follows = res.body.data
|
expect(body.total).to.equal(0)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(0)
|
const follows = body.data
|
||||||
expect(follows.length).to.equal(0)
|
expect(follows.length).to.equal(0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have 0 followers on server 1', async function () {
|
it('Should have 0 followers on server 1', async function () {
|
||||||
const res = await getFollowersListPaginationAndSort({ url: servers[0].url, start: 0, count: 5, sort: 'createdAt' })
|
const body = await followsCommands[0].getFollowers({ start: 0, count: 5, sort: 'createdAt' })
|
||||||
const follows = res.body.data
|
expect(body.total).to.equal(0)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(0)
|
const follows = body.data
|
||||||
expect(follows).to.be.an('array')
|
expect(follows).to.be.an('array')
|
||||||
expect(follows.length).to.equal(0)
|
expect(follows.length).to.equal(0)
|
||||||
})
|
})
|
||||||
|
@ -263,16 +257,16 @@ describe('Test follows', function () {
|
||||||
it('Should unfollow server 3 on server 1', async function () {
|
it('Should unfollow server 3 on server 1', async function () {
|
||||||
this.timeout(5000)
|
this.timeout(5000)
|
||||||
|
|
||||||
await unfollow(servers[0].url, servers[0].accessToken, servers[2])
|
await followsCommands[0].unfollow({ target: servers[2] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not follow server 3 on server 1 anymore', async function () {
|
it('Should not follow server 3 on server 1 anymore', async function () {
|
||||||
const res = await getFollowingListPaginationAndSort({ url: servers[0].url, start: 0, count: 2, sort: 'createdAt' })
|
const body = await followsCommands[0].getFollowings({ start: 0, count: 2, sort: 'createdAt' })
|
||||||
const follows = res.body.data
|
expect(body.total).to.equal(1)
|
||||||
|
|
||||||
expect(res.body.total).to.equal(1)
|
const follows = body.data
|
||||||
expect(follows).to.be.an('array')
|
expect(follows).to.be.an('array')
|
||||||
expect(follows.length).to.equal(1)
|
expect(follows.length).to.equal(1)
|
||||||
|
|
||||||
|
@ -280,10 +274,10 @@ describe('Test follows', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not have server 1 as follower on server 3 anymore', async function () {
|
it('Should not have server 1 as follower on server 3 anymore', async function () {
|
||||||
const res = await getFollowersListPaginationAndSort({ url: servers[2].url, start: 0, count: 1, sort: 'createdAt' })
|
const body = await followsCommands[2].getFollowers({ start: 0, count: 1, sort: 'createdAt' })
|
||||||
|
expect(body.total).to.equal(0)
|
||||||
|
|
||||||
const follows = res.body.data
|
const follows = body.data
|
||||||
expect(res.body.total).to.equal(0)
|
|
||||||
expect(follows).to.be.an('array')
|
expect(follows).to.be.an('array')
|
||||||
expect(follows.length).to.equal(0)
|
expect(follows.length).to.equal(0)
|
||||||
})
|
})
|
||||||
|
@ -404,7 +398,7 @@ describe('Test follows', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
// Server 1 follows server 3
|
// Server 1 follows server 3
|
||||||
await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken)
|
await followsCommands[0].follow({ targets: [ servers[2].url ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
@ -563,7 +557,7 @@ describe('Test follows', function () {
|
||||||
it('Should unfollow server 3 on server 1 and does not list server 3 videos', async function () {
|
it('Should unfollow server 3 on server 1 and does not list server 3 videos', async function () {
|
||||||
this.timeout(5000)
|
this.timeout(5000)
|
||||||
|
|
||||||
await unfollow(servers[0].url, servers[0].accessToken, servers[2])
|
await followsCommands[0].unfollow({ target: servers[2] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
|
|
@ -1,39 +1,33 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { JobState, Video } from '../../../../shared/models'
|
import * as chai from 'chai'
|
||||||
import { VideoPrivacy } from '../../../../shared/models/videos'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { VideoCommentThreadTree } from '../../../../shared/models/videos/comment/video-comment.model'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
addVideoCommentReply,
|
||||||
|
addVideoCommentThread,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
closeAllSequelize,
|
closeAllSequelize,
|
||||||
completeVideoCheck,
|
completeVideoCheck,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
|
getJobsListPaginationAndSort,
|
||||||
getVideo,
|
getVideo,
|
||||||
|
getVideoCommentThreads,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
|
getVideoThreadComments,
|
||||||
immutableAssign,
|
immutableAssign,
|
||||||
killallServers,
|
killallServers,
|
||||||
reRunServer,
|
reRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
setActorFollowScores,
|
setActorFollowScores,
|
||||||
unfollow,
|
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
wait
|
wait,
|
||||||
} from '../../../../shared/extra-utils'
|
waitJobs
|
||||||
import { follow, getFollowersListPaginationAndSort } from '../../../../shared/extra-utils/server/follows'
|
} from '@shared/extra-utils'
|
||||||
import { getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
import { JobState, Video, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
|
||||||
import {
|
|
||||||
addVideoCommentReply,
|
|
||||||
addVideoCommentThread,
|
|
||||||
getVideoCommentThreads,
|
|
||||||
getVideoThreadComments
|
|
||||||
} from '../../../../shared/extra-utils/videos/video-comments'
|
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -118,8 +112,8 @@ describe('Test handle downs', function () {
|
||||||
this.timeout(240000)
|
this.timeout(240000)
|
||||||
|
|
||||||
// Server 2 and 3 follow server 1
|
// Server 2 and 3 follow server 1
|
||||||
await follow(servers[1].url, [ servers[0].url ], servers[1].accessToken)
|
await servers[1].followsCommand.follow({ targets: [ servers[0].url ] })
|
||||||
await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
|
await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -177,10 +171,10 @@ describe('Test handle downs', function () {
|
||||||
await wait(11000)
|
await wait(11000)
|
||||||
|
|
||||||
// Only server 3 is still a follower of server 1
|
// Only server 3 is still a follower of server 1
|
||||||
const res = await getFollowersListPaginationAndSort({ url: servers[0].url, start: 0, count: 2, sort: 'createdAt' })
|
const body = await servers[0].followsCommand.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
|
||||||
expect(res.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(res.body.data).to.have.lengthOf(1)
|
expect(body.data).to.have.lengthOf(1)
|
||||||
expect(res.body.data[0].follower.host).to.equal('localhost:' + servers[2].port)
|
expect(body.data[0].follower.host).to.equal('localhost:' + servers[2].port)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not have pending/processing jobs anymore', async function () {
|
it('Should not have pending/processing jobs anymore', async function () {
|
||||||
|
@ -205,16 +199,16 @@ describe('Test handle downs', function () {
|
||||||
await reRunServer(servers[1])
|
await reRunServer(servers[1])
|
||||||
await reRunServer(servers[2])
|
await reRunServer(servers[2])
|
||||||
|
|
||||||
await unfollow(servers[1].url, servers[1].accessToken, servers[0])
|
await servers[1].followsCommand.unfollow({ target: servers[0] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await follow(servers[1].url, [ servers[0].url ], servers[1].accessToken)
|
await servers[1].followsCommand.follow({ targets: [ servers[0].url ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
const res = await getFollowersListPaginationAndSort({ url: servers[0].url, start: 0, count: 2, sort: 'createdAt' })
|
const body = await servers[0].followsCommand.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
|
||||||
expect(res.body.data).to.be.an('array')
|
expect(body.data).to.be.an('array')
|
||||||
expect(res.body.data).to.have.lengthOf(2)
|
expect(body.data).to.have.lengthOf(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should send an update to server 3, and automatically fetch the video', async function () {
|
it('Should send an update to server 3, and automatically fetch the video', async function () {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import * as chai from 'chai'
|
||||||
import { cleanupTests, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
|
import { cleanupTests, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
|
||||||
|
import { dateIsValid } from '../../../../shared/extra-utils/miscs/miscs'
|
||||||
import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
|
import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
|
||||||
import { getJobsList, getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
import { getJobsList, getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
||||||
import { flushAndRunMultipleServers } from '../../../../shared/extra-utils/server/servers'
|
import { flushAndRunMultipleServers } from '../../../../shared/extra-utils/server/servers'
|
||||||
import { uploadVideo } from '../../../../shared/extra-utils/videos/videos'
|
import { uploadVideo } from '../../../../shared/extra-utils/videos/videos'
|
||||||
import { dateIsValid } from '../../../../shared/extra-utils/miscs/miscs'
|
|
||||||
import { Job } from '../../../../shared/models/server'
|
import { Job } from '../../../../shared/models/server'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
|
@ -4,27 +4,23 @@ import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import {
|
import {
|
||||||
addVideoChannel,
|
addVideoChannel,
|
||||||
|
addVideoCommentThread,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
createVideoPlaylist,
|
createVideoPlaylist,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
follow,
|
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
unfollow,
|
setAccessTokensToServers,
|
||||||
updateCustomSubConfig,
|
updateCustomSubConfig,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin,
|
userLogin,
|
||||||
viewVideo,
|
viewVideo,
|
||||||
wait
|
wait,
|
||||||
} from '../../../../shared/extra-utils'
|
waitJobs
|
||||||
import { setAccessTokensToServers } from '../../../../shared/extra-utils/index'
|
} from '@shared/extra-utils'
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
import { getStats } from '@shared/extra-utils/server/stats'
|
||||||
import { getStats } from '../../../../shared/extra-utils/server/stats'
|
import { ActivityType, ServerStats, VideoPlaylistPrivacy } from '@shared/models'
|
||||||
import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
|
|
||||||
import { ServerStats } from '../../../../shared/models/server/server-stats.model'
|
|
||||||
import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
|
|
||||||
import { ActivityType } from '@shared/models'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -57,7 +53,7 @@ describe('Test stats (excluding redundancy)', function () {
|
||||||
// Wait the video views repeatable job
|
// Wait the video views repeatable job
|
||||||
await wait(8000)
|
await wait(8000)
|
||||||
|
|
||||||
await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
|
await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -111,7 +107,7 @@ describe('Test stats (excluding redundancy)', function () {
|
||||||
it('Should have the correct total videos stats after an unfollow', async function () {
|
it('Should have the correct total videos stats after an unfollow', async function () {
|
||||||
this.timeout(15000)
|
this.timeout(15000)
|
||||||
|
|
||||||
await unfollow(servers[2].url, servers[2].accessToken, servers[0])
|
await servers[2].followsCommand.unfollow({ target: servers[0] })
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
const res = await getStats(servers[2].url)
|
const res = await getStats(servers[2].url)
|
||||||
|
|
|
@ -1,30 +1,27 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import * as chai from 'chai'
|
||||||
import {
|
import {
|
||||||
|
addUserSubscription,
|
||||||
|
areSubscriptionsExist,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
follow,
|
|
||||||
getVideosList,
|
|
||||||
unfollow,
|
|
||||||
updateVideo,
|
|
||||||
userLogin
|
|
||||||
} from '../../../../shared/extra-utils'
|
|
||||||
import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
|
|
||||||
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
|
|
||||||
import { Video, VideoChannel } from '../../../../shared/models/videos'
|
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
|
||||||
import {
|
|
||||||
addUserSubscription,
|
|
||||||
areSubscriptionsExist,
|
|
||||||
getUserSubscription,
|
getUserSubscription,
|
||||||
|
getVideosList,
|
||||||
listUserSubscriptions,
|
listUserSubscriptions,
|
||||||
listUserSubscriptionVideos,
|
listUserSubscriptionVideos,
|
||||||
removeUserSubscription
|
removeUserSubscription,
|
||||||
} from '../../../../shared/extra-utils/users/user-subscriptions'
|
ServerInfo,
|
||||||
|
setAccessTokensToServers,
|
||||||
|
updateVideo,
|
||||||
|
uploadVideo,
|
||||||
|
userLogin,
|
||||||
|
waitJobs
|
||||||
|
} from '@shared/extra-utils'
|
||||||
|
import { Video, VideoChannel } from '@shared/models'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -250,7 +247,7 @@ describe('Test users subscriptions', function () {
|
||||||
it('Should have server 1 follow server 3 and display server 3 videos', async function () {
|
it('Should have server 1 follow server 3 and display server 3 videos', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
await follow(servers[0].url, [ servers[2].url ], servers[0].accessToken)
|
await servers[0].followsCommand.follow({ targets: [ servers[2].url ] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -268,7 +265,7 @@ describe('Test users subscriptions', function () {
|
||||||
it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () {
|
it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
await unfollow(servers[0].url, servers[0].accessToken, servers[2])
|
await servers[0].followsCommand.unfollow({ target: servers[2] })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
deleteMe,
|
deleteMe,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
follow,
|
|
||||||
getAccountRatings,
|
getAccountRatings,
|
||||||
getBlacklistedVideosList,
|
getBlacklistedVideosList,
|
||||||
getCustomConfig,
|
getCustomConfig,
|
||||||
|
@ -138,7 +137,12 @@ describe('Test users', function () {
|
||||||
|
|
||||||
it('Should not be able to follow', async function () {
|
it('Should not be able to follow', async function () {
|
||||||
accessToken = 'my_super_token'
|
accessToken = 'my_super_token'
|
||||||
await follow(server.url, [ 'http://example.com' ], accessToken, HttpStatusCode.UNAUTHORIZED_401)
|
|
||||||
|
await server.followsCommand.follow({
|
||||||
|
targets: [ 'http://example.com' ],
|
||||||
|
token: accessToken,
|
||||||
|
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not be able to unfollow')
|
it('Should not be able to unfollow')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import * as chai from 'chai'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
|
addAccountToAccountBlocklist,
|
||||||
|
addAccountToServerBlocklist,
|
||||||
|
addServerToAccountBlocklist,
|
||||||
|
addServerToServerBlocklist,
|
||||||
addVideoChannel,
|
addVideoChannel,
|
||||||
addVideoInPlaylist,
|
addVideoInPlaylist,
|
||||||
addVideoToBlacklist,
|
addVideoToBlacklist,
|
||||||
|
@ -27,6 +31,10 @@ import {
|
||||||
getVideoPlaylistPrivacies,
|
getVideoPlaylistPrivacies,
|
||||||
getVideoPlaylistsList,
|
getVideoPlaylistsList,
|
||||||
getVideoPlaylistWithToken,
|
getVideoPlaylistWithToken,
|
||||||
|
removeAccountFromAccountBlocklist,
|
||||||
|
removeAccountFromServerBlocklist,
|
||||||
|
removeServerFromAccountBlocklist,
|
||||||
|
removeServerFromServerBlocklist,
|
||||||
removeUser,
|
removeUser,
|
||||||
removeVideoFromBlacklist,
|
removeVideoFromBlacklist,
|
||||||
removeVideoFromPlaylist,
|
removeVideoFromPlaylist,
|
||||||
|
@ -35,7 +43,6 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
setDefaultVideoChannel,
|
setDefaultVideoChannel,
|
||||||
testImage,
|
testImage,
|
||||||
unfollow,
|
|
||||||
updateVideo,
|
updateVideo,
|
||||||
updateVideoPlaylist,
|
updateVideoPlaylist,
|
||||||
updateVideoPlaylistElement,
|
updateVideoPlaylistElement,
|
||||||
|
@ -44,24 +51,18 @@ import {
|
||||||
userLogin,
|
userLogin,
|
||||||
wait,
|
wait,
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '../../../../shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
addAccountToAccountBlocklist,
|
User,
|
||||||
addAccountToServerBlocklist,
|
VideoExistInPlaylist,
|
||||||
addServerToAccountBlocklist,
|
VideoPlaylist,
|
||||||
addServerToServerBlocklist,
|
VideoPlaylistCreateResult,
|
||||||
removeAccountFromAccountBlocklist,
|
VideoPlaylistElement,
|
||||||
removeAccountFromServerBlocklist,
|
VideoPlaylistElementType,
|
||||||
removeServerFromAccountBlocklist,
|
VideoPlaylistPrivacy,
|
||||||
removeServerFromServerBlocklist
|
VideoPlaylistType,
|
||||||
} from '../../../../shared/extra-utils/users/blocklist'
|
VideoPrivacy
|
||||||
import { User } from '../../../../shared/models/users'
|
} from '@shared/models'
|
||||||
import { VideoPlaylistCreateResult, VideoPrivacy } from '../../../../shared/models/videos'
|
|
||||||
import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
|
|
||||||
import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../../shared/models/videos/playlist/video-playlist-element.model'
|
|
||||||
import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
|
|
||||||
import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
|
|
||||||
import { VideoPlaylist } from '../../../../shared/models/videos/playlist/video-playlist.model'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -1171,7 +1172,7 @@ describe('Test video playlists', function () {
|
||||||
expect(finder(res.body.data)).to.not.be.undefined
|
expect(finder(res.body.data)).to.not.be.undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
await unfollow(servers[2].url, servers[2].accessToken, servers[0])
|
await servers[2].followsCommand.unfollow({ target: servers[0] })
|
||||||
|
|
||||||
{
|
{
|
||||||
const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
|
const res = await getVideoPlaylistsList(servers[2].url, 0, 5)
|
||||||
|
|
|
@ -7,15 +7,14 @@ export * from './miscs'
|
||||||
export * from './mock-servers'
|
export * from './mock-servers'
|
||||||
export * from './moderation'
|
export * from './moderation'
|
||||||
export * from './overviews'
|
export * from './overviews'
|
||||||
|
export * from './search'
|
||||||
|
export * from './server'
|
||||||
|
|
||||||
export * from './requests/check-api-params'
|
export * from './requests/check-api-params'
|
||||||
export * from './requests/requests'
|
export * from './requests/requests'
|
||||||
|
|
||||||
export * from './search'
|
|
||||||
|
|
||||||
export * from './server/clients'
|
export * from './server/clients'
|
||||||
export * from './server/config'
|
export * from './server/config'
|
||||||
export * from './server/follows'
|
|
||||||
export * from './server/jobs'
|
export * from './server/jobs'
|
||||||
export * from './server/plugins'
|
export * from './server/plugins'
|
||||||
export * from './server/servers'
|
export * from './server/servers'
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
import { pick } from 'lodash'
|
||||||
|
import { ActivityPubActorType, ActorFollow, FollowState, ResultList } from '@shared/models'
|
||||||
|
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
|
||||||
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||||
|
import { ServerInfo } from './servers'
|
||||||
|
|
||||||
|
export class FollowsCommand extends AbstractCommand {
|
||||||
|
|
||||||
|
getFollowers (options: OverrideCommandOptions & {
|
||||||
|
start: number
|
||||||
|
count: number
|
||||||
|
sort: string
|
||||||
|
search?: string
|
||||||
|
actorType?: ActivityPubActorType
|
||||||
|
state?: FollowState
|
||||||
|
}) {
|
||||||
|
const path = '/api/v1/server/followers'
|
||||||
|
|
||||||
|
const toPick = [ 'start', 'count', 'sort', 'search', 'state', 'actorType' ]
|
||||||
|
const query = pick(options, toPick)
|
||||||
|
|
||||||
|
return this.getRequestBody<ResultList<ActorFollow>>({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
token: null,
|
||||||
|
|
||||||
|
path,
|
||||||
|
query,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getFollowings (options: OverrideCommandOptions & {
|
||||||
|
start: number
|
||||||
|
count: number
|
||||||
|
sort: string
|
||||||
|
search?: string
|
||||||
|
actorType?: ActivityPubActorType
|
||||||
|
state?: FollowState
|
||||||
|
}) {
|
||||||
|
const path = '/api/v1/server/following'
|
||||||
|
|
||||||
|
const toPick = [ 'start', 'count', 'sort', 'search', 'state', 'actorType' ]
|
||||||
|
const query = pick(options, toPick)
|
||||||
|
|
||||||
|
return this.getRequestBody<ResultList<ActorFollow>>({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
token: null,
|
||||||
|
|
||||||
|
path,
|
||||||
|
query,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
follow (options: OverrideCommandOptions & {
|
||||||
|
targets: string[]
|
||||||
|
}) {
|
||||||
|
const path = '/api/v1/server/following'
|
||||||
|
|
||||||
|
const hosts = options.targets.map(f => f.replace(/^http:\/\//, ''))
|
||||||
|
|
||||||
|
return this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
fields: { hosts },
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async unfollow (options: OverrideCommandOptions & {
|
||||||
|
target: ServerInfo
|
||||||
|
}) {
|
||||||
|
const path = '/api/v1/server/following/' + options.target.host
|
||||||
|
|
||||||
|
return this.deleteRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
acceptFollower (options: OverrideCommandOptions & {
|
||||||
|
follower: string
|
||||||
|
}) {
|
||||||
|
const path = '/api/v1/server/followers/' + options.follower + '/accept'
|
||||||
|
|
||||||
|
return this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
rejectFollower (options: OverrideCommandOptions & {
|
||||||
|
follower: string
|
||||||
|
}) {
|
||||||
|
const path = '/api/v1/server/followers/' + options.follower + '/reject'
|
||||||
|
|
||||||
|
return this.postBodyRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
removeFollower (options: OverrideCommandOptions & {
|
||||||
|
follower: ServerInfo
|
||||||
|
}) {
|
||||||
|
const path = '/api/v1/server/followers/peertube@' + options.follower.host
|
||||||
|
|
||||||
|
return this.deleteRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,126 +1,10 @@
|
||||||
import * as request from 'supertest'
|
|
||||||
import { ServerInfo } from './servers'
|
|
||||||
import { waitJobs } from './jobs'
|
import { waitJobs } from './jobs'
|
||||||
import { makePostBodyRequest } from '../requests/requests'
|
import { ServerInfo } from './servers'
|
||||||
import { ActivityPubActorType, FollowState } from '@shared/models'
|
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
function getFollowersListPaginationAndSort (options: {
|
|
||||||
url: string
|
|
||||||
start: number
|
|
||||||
count: number
|
|
||||||
sort: string
|
|
||||||
search?: string
|
|
||||||
actorType?: ActivityPubActorType
|
|
||||||
state?: FollowState
|
|
||||||
}) {
|
|
||||||
const { url, start, count, sort, search, state, actorType } = options
|
|
||||||
const path = '/api/v1/server/followers'
|
|
||||||
|
|
||||||
const query = {
|
|
||||||
start,
|
|
||||||
count,
|
|
||||||
sort,
|
|
||||||
search,
|
|
||||||
state,
|
|
||||||
actorType
|
|
||||||
}
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.get(path)
|
|
||||||
.query(query)
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.expect(HttpStatusCode.OK_200)
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
}
|
|
||||||
|
|
||||||
function acceptFollower (url: string, token: string, follower: string, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
|
|
||||||
const path = '/api/v1/server/followers/' + follower + '/accept'
|
|
||||||
|
|
||||||
return makePostBodyRequest({
|
|
||||||
url,
|
|
||||||
token,
|
|
||||||
path,
|
|
||||||
statusCodeExpected
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function rejectFollower (url: string, token: string, follower: string, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) {
|
|
||||||
const path = '/api/v1/server/followers/' + follower + '/reject'
|
|
||||||
|
|
||||||
return makePostBodyRequest({
|
|
||||||
url,
|
|
||||||
token,
|
|
||||||
path,
|
|
||||||
statusCodeExpected
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFollowingListPaginationAndSort (options: {
|
|
||||||
url: string
|
|
||||||
start: number
|
|
||||||
count: number
|
|
||||||
sort: string
|
|
||||||
search?: string
|
|
||||||
actorType?: ActivityPubActorType
|
|
||||||
state?: FollowState
|
|
||||||
}) {
|
|
||||||
const { url, start, count, sort, search, state, actorType } = options
|
|
||||||
const path = '/api/v1/server/following'
|
|
||||||
|
|
||||||
const query = {
|
|
||||||
start,
|
|
||||||
count,
|
|
||||||
sort,
|
|
||||||
search,
|
|
||||||
state,
|
|
||||||
actorType
|
|
||||||
}
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.get(path)
|
|
||||||
.query(query)
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.expect(HttpStatusCode.OK_200)
|
|
||||||
.expect('Content-Type', /json/)
|
|
||||||
}
|
|
||||||
|
|
||||||
function follow (follower: string, following: string[], accessToken: string, expectedStatus = HttpStatusCode.NO_CONTENT_204) {
|
|
||||||
const path = '/api/v1/server/following'
|
|
||||||
|
|
||||||
const followingHosts = following.map(f => f.replace(/^http:\/\//, ''))
|
|
||||||
return request(follower)
|
|
||||||
.post(path)
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.set('Authorization', 'Bearer ' + accessToken)
|
|
||||||
.send({ hosts: followingHosts })
|
|
||||||
.expect(expectedStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function unfollow (url: string, accessToken: string, target: ServerInfo, expectedStatus = HttpStatusCode.NO_CONTENT_204) {
|
|
||||||
const path = '/api/v1/server/following/' + target.host
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.delete(path)
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.set('Authorization', 'Bearer ' + accessToken)
|
|
||||||
.expect(expectedStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeFollower (url: string, accessToken: string, follower: ServerInfo, expectedStatus = HttpStatusCode.NO_CONTENT_204) {
|
|
||||||
const path = '/api/v1/server/followers/peertube@' + follower.host
|
|
||||||
|
|
||||||
return request(url)
|
|
||||||
.delete(path)
|
|
||||||
.set('Accept', 'application/json')
|
|
||||||
.set('Authorization', 'Bearer ' + accessToken)
|
|
||||||
.expect(expectedStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
|
async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
follow(server1.url, [ server2.url ], server1.accessToken),
|
server1.followsCommand.follow({ targets: [ server2.url ] }),
|
||||||
follow(server2.url, [ server1.url ], server2.accessToken)
|
server2.followsCommand.follow({ targets: [ server1.url ] })
|
||||||
])
|
])
|
||||||
|
|
||||||
// Wait request propagation
|
// Wait request propagation
|
||||||
|
@ -132,12 +16,5 @@ async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getFollowersListPaginationAndSort,
|
doubleFollow
|
||||||
getFollowingListPaginationAndSort,
|
|
||||||
unfollow,
|
|
||||||
removeFollower,
|
|
||||||
follow,
|
|
||||||
doubleFollow,
|
|
||||||
acceptFollower,
|
|
||||||
rejectFollower
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
export * from './contact-form-command'
|
export * from './contact-form-command'
|
||||||
export * from './debug-command'
|
export * from './debug-command'
|
||||||
|
export * from './follows-command'
|
||||||
|
export * from './follows'
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { makeGetRequest } from '../requests/requests'
|
||||||
import { SearchCommand } from '../search'
|
import { SearchCommand } from '../search'
|
||||||
import { ContactFormCommand } from './contact-form-command'
|
import { ContactFormCommand } from './contact-form-command'
|
||||||
import { DebugCommand } from './debug-command'
|
import { DebugCommand } from './debug-command'
|
||||||
|
import { FollowsCommand } from './follows-command'
|
||||||
|
|
||||||
interface ServerInfo {
|
interface ServerInfo {
|
||||||
app: ChildProcess
|
app: ChildProcess
|
||||||
|
@ -81,6 +82,7 @@ interface ServerInfo {
|
||||||
searchCommand?: SearchCommand
|
searchCommand?: SearchCommand
|
||||||
contactFormCommand?: ContactFormCommand
|
contactFormCommand?: ContactFormCommand
|
||||||
debugCommand?: DebugCommand
|
debugCommand?: DebugCommand
|
||||||
|
followsCommand?: FollowsCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
function parallelTests () {
|
function parallelTests () {
|
||||||
|
@ -296,6 +298,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
|
||||||
server.searchCommand = new SearchCommand(server)
|
server.searchCommand = new SearchCommand(server)
|
||||||
server.contactFormCommand = new ContactFormCommand(server)
|
server.contactFormCommand = new ContactFormCommand(server)
|
||||||
server.debugCommand = new DebugCommand(server)
|
server.debugCommand = new DebugCommand(server)
|
||||||
|
server.followsCommand = new FollowsCommand(server)
|
||||||
|
|
||||||
res(server)
|
res(server)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue