1
0
Fork 0

Introduce accounts command

This commit is contained in:
Chocobozzz 2021-07-07 13:38:26 +02:00
parent 87e2635a50
commit 9fff08cf83
No known key found for this signature in database
GPG key ID: 583A612D890159BE
15 changed files with 172 additions and 167 deletions

View file

@ -1,8 +1,10 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import { HttpStatusCode } from '@shared/core-utils'
import {
cleanupTests, closeAllSequelize,
cleanupTests,
closeAllSequelize,
createVideoPlaylist,
doubleFollow,
flushAndRunMultipleServers,
@ -21,10 +23,8 @@ import {
uploadVideoAndGetId,
wait,
waitJobs
} from '../../../../shared/extra-utils'
import { getAccount } from '../../../../shared/extra-utils/users/accounts'
import { VideoPlaylistPrivacy } from '../../../../shared/models/videos'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
} from '@shared/extra-utils'
import { VideoPlaylistPrivacy } from '@shared/models'
describe('Test AP refresher', function () {
let servers: ServerInfo[] = []
@ -116,19 +116,21 @@ describe('Test AP refresher', function () {
it('Should remove a deleted actor', async function () {
this.timeout(60000)
const command = servers[0].accountsCommand
await wait(10000)
// Change actor name so the remote server returns a 404
const to = 'http://localhost:' + servers[1].port + '/accounts/user2'
await setActorField(servers[1].internalServerNumber, to, 'preferredUsername', 'toto')
await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port)
await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port)
await command.get({ accountName: 'user1@localhost:' + servers[1].port })
await command.get({ accountName: 'user2@localhost:' + servers[1].port })
await waitJobs(servers)
await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port, HttpStatusCode.OK_200)
await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port, HttpStatusCode.NOT_FOUND_404)
await command.get({ accountName: 'user1@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.OK_200 })
await command.get({ accountName: 'user2@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
})

View file

@ -1,15 +1,15 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../../shared/extra-utils'
import { HttpStatusCode } from '@shared/core-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
import { getAccount } from '../../../../shared/extra-utils/users/accounts'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
checkBadStartPagination,
cleanupTests,
flushAndRunServer,
ServerInfo
} from '@shared/extra-utils'
describe('Test accounts API validators', function () {
const path = '/api/v1/accounts/'
@ -38,8 +38,9 @@ describe('Test accounts API validators', function () {
})
describe('When getting an account', function () {
it('Should return 404 with a non existing name', async function () {
await getAccount(server.url, 'arfaze', HttpStatusCode.NOT_FOUND_404)
await server.accountsCommand.get({ accountName: 'arfaze', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
})

View file

@ -13,7 +13,6 @@ import {
doubleFollow,
flushAndRunMultipleServers,
generateUserAccessToken,
getAccount,
getVideoCommentThreads,
getVideoIdFromUUID,
getVideosList,
@ -606,10 +605,8 @@ describe('Test abuses', function () {
describe('Account abuses', function () {
async function getAccountFromServer (url: string, name: string, server: ServerInfo) {
const res = await getAccount(url, name + '@' + server.host)
return res.body as Account
function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) {
return server.accountsCommand.get({ accountName: targetName + '@' + targetServer.host })
}
before(async function () {
@ -626,7 +623,7 @@ describe('Test abuses', function () {
it('Should report abuse on an account', async function () {
this.timeout(15000)
const account = await getAccountFromServer(servers[0].url, 'user_1', servers[0])
const account = await getAccountFromServer(servers[0], 'user_1', servers[0])
const reason = 'it is a bad account'
await commands[0].report({ accountId: account.id, reason })
@ -664,7 +661,7 @@ describe('Test abuses', function () {
it('Should report abuse on a remote account', async function () {
this.timeout(10000)
const account = await getAccountFromServer(servers[0].url, 'user_2', servers[1])
const account = await getAccountFromServer(servers[0], 'user_2', servers[1])
const reason = 'it is a really bad account'
await commands[0].report({ accountId: account.id, reason })
@ -718,7 +715,7 @@ describe('Test abuses', function () {
it('Should keep the account abuse when deleting the account', async function () {
this.timeout(10000)
const account = await getAccountFromServer(servers[1].url, 'user_2', servers[1])
const account = await getAccountFromServer(servers[1], 'user_2', servers[1])
await removeUser(servers[1].url, account.userId, servers[1].accessToken)
await waitJobs(servers)

View file

@ -22,7 +22,6 @@ import {
cleanupTests,
createUser,
generateUserAccessToken,
getAccount,
getVideoCommentThreads,
getVideoIdFromUUID,
immutableAssign,
@ -157,8 +156,8 @@ describe('Test moderation notifications', function () {
await waitJobs(servers)
const resAccount = await getAccount(servers[1].url, username + '@' + servers[0].host)
await servers[1].abusesCommand.report({ accountId: resAccount.body.id, reason: 'super reason' })
const account = await servers[1].accountsCommand.get({ accountName: username + '@' + servers[0].host })
await servers[1].abusesCommand.report({ accountId: account.id, reason: 'super reason' })
await waitJobs(servers)
await checkNewAccountAbuseForModerators(baseParams, username, 'presence')

View file

@ -242,16 +242,16 @@ describe('Test follows', function () {
})
it('Should have the correct follows counts', async function () {
await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[0].port, 0, 2)
await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[1].port, 1, 0)
await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[2].port, 1, 0)
await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 2 })
await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 })
// Server 2 and 3 does not know server 1 follow another server (there was not a refresh)
await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[0].port, 0, 1)
await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[1].port, 1, 0)
await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[0].port, 0, 1)
await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[2].port, 1, 0)
await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 })
})
it('Should unfollow server 3 on server 1', async function () {
@ -283,14 +283,14 @@ describe('Test follows', function () {
})
it('Should have the correct follows counts 2', async function () {
await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[0].port, 0, 1)
await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[1].port, 1, 0)
await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[0].port, 0, 1)
await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[1].port, 1, 0)
await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[0].port, 0, 0)
await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[2].port, 0, 0)
await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 0 })
await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[2].port, followers: 0, following: 0 })
})
it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () {
@ -404,15 +404,15 @@ describe('Test follows', function () {
})
it('Should have the correct follows counts 3', async function () {
await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[0].port, 0, 2)
await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[1].port, 1, 0)
await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[2].port, 1, 0)
await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 2 })
await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
await expectAccountFollows({ server: servers[0], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 })
await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[0].port, 0, 1)
await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[1].port, 1, 0)
await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
await expectAccountFollows({ server: servers[1], handle: 'peertube@localhost:' + servers[1].port, followers: 1, following: 0 })
await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[0].port, 0, 1)
await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[2].port, 1, 0)
await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[0].port, followers: 0, following: 1 })
await expectAccountFollows({ server: servers[2], handle: 'peertube@localhost:' + servers[2].port, followers: 1, following: 0 })
})
it('Should have propagated videos', async function () {

View file

@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import { Account } from '../../../../shared/models/actors'
import * as chai from 'chai'
import {
checkActorFilesWereRemoved,
checkTmpIsEmpty,
checkVideoFilesWereRemoved,
cleanupTests,
@ -11,17 +11,19 @@ import {
doubleFollow,
flushAndRunMultipleServers,
getAccountVideos,
getMyUserInformation,
getVideoChannelsList,
removeUser,
ServerInfo,
setAccessTokensToServers,
testImage,
updateMyAvatar,
updateMyUser,
userLogin
} from '../../../../shared/extra-utils'
import { getMyUserInformation, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../../../shared/extra-utils/index'
import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts'
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
import { User } from '../../../../shared/models/users'
import { VideoChannel } from '../../../../shared/models/videos'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
uploadVideo,
userLogin,
waitJobs
} from '@shared/extra-utils'
import { User, VideoChannel } from '@shared/models'
const expect = chai.expect
@ -133,13 +135,12 @@ describe('Test users with multiple servers', function () {
let createdAt: string | Date
for (const server of servers) {
const resAccounts = await getAccountsList(server.url, '-createdAt')
const body = await server.accountsCommand.list({ sort: '-createdAt' })
const resList = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port) as Account
const resList = body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port)
expect(resList).not.to.be.undefined
const resAccount = await getAccount(server.url, resList.name + '@' + resList.host)
const account = resAccount.body as Account
const account = await server.accountsCommand.get({ accountName: resList.name + '@' + resList.host })
if (!createdAt) createdAt = account.createdAt
@ -193,9 +194,9 @@ describe('Test users with multiple servers', function () {
this.timeout(10_000)
for (const server of servers) {
const resAccounts = await getAccountsList(server.url, '-createdAt')
const body = await server.accountsCommand.list({ sort: '-createdAt' })
const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account
const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
expect(accountDeleted).not.to.be.undefined
const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
@ -210,9 +211,9 @@ describe('Test users with multiple servers', function () {
await waitJobs(servers)
for (const server of servers) {
const resAccounts = await getAccountsList(server.url, '-createdAt')
const body = await server.accountsCommand.list({ sort: '-createdAt' })
const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account
const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
expect(accountDeleted).to.be.undefined
const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)

View file

@ -11,7 +11,6 @@ import {
createUser,
deleteMe,
flushAndRunServer,
getAccountRatings,
getBlacklistedVideosList,
getMyUserInformation,
getMyUserVideoQuotaUsed,
@ -194,25 +193,22 @@ describe('Test users', function () {
it('Should retrieve ratings list', async function () {
await rateVideo(server.url, accessToken, videoId, 'like')
const res = await getAccountRatings(server.url, server.user.username, server.accessToken, null, HttpStatusCode.OK_200)
const ratings = res.body
const body = await server.accountsCommand.listRatings({ accountName: server.user.username })
expect(ratings.total).to.equal(1)
expect(ratings.data[0].video.id).to.equal(videoId)
expect(ratings.data[0].rating).to.equal('like')
expect(body.total).to.equal(1)
expect(body.data[0].video.id).to.equal(videoId)
expect(body.data[0].rating).to.equal('like')
})
it('Should retrieve ratings list by rating type', async function () {
{
const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'like')
const ratings = res.body
expect(ratings.data.length).to.equal(1)
const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'like' })
expect(body.data.length).to.equal(1)
}
{
const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'dislike')
const ratings = res.body
expect(ratings.data.length).to.equal(0)
const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'dislike' })
expect(body.data.length).to.equal(0)
}
})
})

View file

@ -5,7 +5,7 @@ import * as chai from 'chai'
import { createFile, readdir } from 'fs-extra'
import { join } from 'path'
import { buildUUID } from '@server/helpers/uuid'
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
import { HttpStatusCode } from '@shared/core-utils'
import {
buildServerDirectory,
cleanupTests,
@ -13,7 +13,6 @@ import {
createVideoPlaylist,
doubleFollow,
flushAndRunMultipleServers,
getAccount,
killallServers,
makeGetRequest,
ServerInfo,
@ -21,10 +20,10 @@ import {
setDefaultVideoChannel,
updateMyAvatar,
uploadVideo,
wait
} from '../../../shared/extra-utils'
import { waitJobs } from '../../../shared/extra-utils/server/jobs'
import { Account, VideoPlaylistPrivacy } from '../../../shared/models'
wait,
waitJobs
} from '@shared/extra-utils'
import { VideoPlaylistPrivacy } from '@shared/models'
const expect = chai.expect
@ -94,8 +93,7 @@ describe('Test prune storage scripts', function () {
// Lazy load the remote avatar
{
const res = await getAccount(servers[0].url, 'root@localhost:' + servers[1].port)
const account: Account = res.body
const account = await servers[0].accountsCommand.get({ accountName: 'root@localhost:' + servers[1].port })
await makeGetRequest({
url: servers[0].url,
path: account.avatar.path,
@ -104,8 +102,7 @@ describe('Test prune storage scripts', function () {
}
{
const res = await getAccount(servers[1].url, 'root@localhost:' + servers[0].port)
const account: Account = res.body
const account = await servers[1].accountsCommand.get({ accountName: 'root@localhost:' + servers[0].port })
await makeGetRequest({
url: servers[1].url,
path: account.avatar.path,

View file

@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import * as chai from 'chai'
import {
addVideoChannel,
addVideoCommentThread,
cleanupTests,
createUser,
flushAndRunServer,
@ -16,12 +16,10 @@ import {
reRunServer,
ServerInfo,
setAccessTokensToServers,
uploadVideo
} from '../../../shared/extra-utils'
import { waitJobs } from '../../../shared/extra-utils/server/jobs'
import { getAccountsList } from '../../../shared/extra-utils/users/accounts'
import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
import { VideoDetails } from '../../../shared/models/videos'
uploadVideo,
waitJobs
} from '@shared/extra-utils'
import { VideoDetails } from '@shared/models'
const expect = chai.expect
@ -104,10 +102,10 @@ describe('Test update host scripts', function () {
})
it('Should have updated accounts url', async function () {
const res = await getAccountsList(server.url)
expect(res.body.total).to.equal(3)
const body = await server.accountsCommand.list()
expect(body.total).to.equal(3)
for (const account of res.body.data) {
for (const account of body.data) {
const usernameWithDomain = account.name
const { body } = await makeActivityPubGetRequest(server.url, '/accounts/' + usernameWithDomain)

View file

@ -11,7 +11,6 @@ import {
createVideoPlaylist,
doubleFollow,
flushAndRunMultipleServers,
getAccount,
getVideosList,
makeGetRequest,
makeHTMLRequest,
@ -105,8 +104,7 @@ describe('Test a client controllers', function () {
await updateMyUser({ url: servers[0].url, accessToken: servers[0].accessToken, description: 'my account description' })
const resAccountRequest = await getAccount(servers[0].url, `${servers[0].user.username}@${servers[0].host}`)
account = resAccountRequest.body
account = await servers[0].accountsCommand.get({ accountName: `${servers[0].user.username}@${servers[0].host}` })
await waitJobs(servers)
})

View file

@ -10,17 +10,11 @@ export * from './overviews'
export * from './search'
export * from './server'
export * from './socket'
export * from './users'
export * from './requests/check-api-params'
export * from './requests/requests'
export * from './users/accounts'
export * from './users/blocklist'
export * from './users/login'
export * from './users/user-notifications'
export * from './users/user-subscriptions'
export * from './users/users'
export * from './videos/live'
export * from './videos/services'
export * from './videos/video-blacklist'

View file

@ -17,6 +17,7 @@ import { OverviewsCommand } from '../overviews'
import { makeGetRequest } from '../requests/requests'
import { SearchCommand } from '../search'
import { SocketIOCommand } from '../socket'
import { AccountsCommand } from '../users'
import { ConfigCommand } from './config-command'
import { ContactFormCommand } from './contact-form-command'
import { DebugCommand } from './debug-command'
@ -95,6 +96,7 @@ interface ServerInfo {
statsCommand?: StatsCommand
configCommand?: ConfigCommand
socketIOCommand?: SocketIOCommand
accountsCommand?: AccountsCommand
}
function parallelTests () {
@ -317,6 +319,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
server.statsCommand = new StatsCommand(server)
server.configCommand = new ConfigCommand(server)
server.socketIOCommand = new SocketIOCommand(server)
server.accountsCommand = new AccountsCommand(server)
res(server)
})

View file

@ -0,0 +1,54 @@
import { ResultList } from '@shared/models'
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
import { Account } from '../../models/actors'
import { AccountVideoRate, VideoRateType } from '../../models/videos'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class AccountsCommand extends AbstractCommand {
list (options: OverrideCommandOptions & {
sort?: string // default -createdAt
} = {}) {
const { sort = '-createdAt' } = options
const path = '/api/v1/accounts'
return this.getRequestBody<ResultList<Account>>({
...options,
path,
query: { sort },
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
get (options: OverrideCommandOptions & {
accountName: string
}) {
const path = '/api/v1/accounts/' + options.accountName
return this.getRequestBody<Account>({
...options,
path,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
listRatings (options: OverrideCommandOptions & {
accountName: string
rating?: VideoRateType
}) {
const { rating, accountName } = options
const path = '/api/v1/accounts/' + accountName + '/ratings'
const query = { rating }
return this.getRequestBody<ResultList<AccountVideoRate>>({
...options,
path,
query,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
}

View file

@ -1,43 +1,25 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as request from 'supertest'
import { expect } from 'chai'
import { existsSync, readdir } from 'fs-extra'
import { pathExists, readdir } from 'fs-extra'
import { join } from 'path'
import { Account } from '../../models/actors'
import { root } from '../miscs/miscs'
import { makeGetRequest } from '../requests/requests'
import { VideoRateType } from '../../models/videos'
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
import { root } from '@server/helpers/core-utils'
import { ServerInfo } from '../server'
function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = HttpStatusCode.OK_200) {
const path = '/api/v1/accounts'
async function expectAccountFollows (options: {
server: ServerInfo
handle: string
followers: number
following: number
}) {
const { server, handle, followers, following } = options
return makeGetRequest({
url,
query: { sort },
path,
statusCodeExpected
})
}
const body = await server.accountsCommand.list()
const account = body.data.find(a => a.name + '@' + a.host === handle)
function getAccount (url: string, accountName: string, statusCodeExpected = HttpStatusCode.OK_200) {
const path = '/api/v1/accounts/' + accountName
return makeGetRequest({
url,
path,
statusCodeExpected
})
}
async function expectAccountFollows (url: string, nameWithDomain: string, followersCount: number, followingCount: number) {
const res = await getAccountsList(url)
const account = res.body.data.find((a: Account) => a.name + '@' + a.host === nameWithDomain)
const message = `${nameWithDomain} on ${url}`
expect(account.followersCount).to.equal(followersCount, message)
expect(account.followingCount).to.equal(followingCount, message)
const message = `${handle} on ${server.url}`
expect(account.followersCount).to.equal(followers, message)
expect(account.followingCount).to.equal(following, message)
}
async function checkActorFilesWereRemoved (filename: string, serverNumber: number) {
@ -46,7 +28,7 @@ async function checkActorFilesWereRemoved (filename: string, serverNumber: numbe
for (const directory of [ 'avatars' ]) {
const directoryPath = join(root(), testDirectory, directory)
const directoryExists = existsSync(directoryPath)
const directoryExists = await pathExists(directoryPath)
expect(directoryExists).to.be.true
const files = await readdir(directoryPath)
@ -56,32 +38,7 @@ async function checkActorFilesWereRemoved (filename: string, serverNumber: numbe
}
}
function getAccountRatings (
url: string,
accountName: string,
accessToken: string,
rating?: VideoRateType,
statusCodeExpected = HttpStatusCode.OK_200
) {
const path = '/api/v1/accounts/' + accountName + '/ratings'
const query = rating ? { rating } : {}
return request(url)
.get(path)
.query(query)
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + accessToken)
.expect(statusCodeExpected)
.expect('Content-Type', /json/)
}
// ---------------------------------------------------------------------------
export {
getAccount,
expectAccountFollows,
getAccountsList,
checkActorFilesWereRemoved,
getAccountRatings
checkActorFilesWereRemoved
}

View file

@ -0,0 +1,8 @@
export * from './accounts'
export * from './accounts-command'
export * from './blocklist'
export * from './login'
export * from './user-notifications'
export * from './user-subscriptions'
export * from './users'