Shorter server command names

This commit is contained in:
Chocobozzz
2021-07-16 09:04:35 +02:00
parent d23dd9fbfc
commit 89d241a79c
155 changed files with 2508 additions and 2508 deletions

View File

@@ -19,7 +19,7 @@ describe('Test plugin action hooks', function () {
let threadId: number
function checkHook (hook: ServerHookName) {
return servers[0].serversCommand.waitUntilLog('Run hook ' + hook)
return servers[0].servers.waitUntilLog('Run hook ' + hook)
}
before(async function () {
@@ -29,7 +29,7 @@ describe('Test plugin action hooks', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() })
await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() })
await killallServers([ servers[0] ])
@@ -49,20 +49,20 @@ describe('Test plugin action hooks', function () {
describe('Videos hooks', function () {
it('Should run action:api.video.uploaded', async function () {
const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' } })
const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' } })
videoUUID = uuid
await checkHook('action:api.video.uploaded')
})
it('Should run action:api.video.updated', async function () {
await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video updated' } })
await servers[0].videos.update({ id: videoUUID, attributes: { name: 'video updated' } })
await checkHook('action:api.video.updated')
})
it('Should run action:api.video.viewed', async function () {
await servers[0].videosCommand.view({ id: videoUUID })
await servers[0].videos.view({ id: videoUUID })
await checkHook('action:api.video.viewed')
})
@@ -74,10 +74,10 @@ describe('Test plugin action hooks', function () {
const attributes = {
name: 'live',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id
channelId: servers[0].store.channel.id
}
await servers[0].liveCommand.create({ fields: attributes })
await servers[0].live.create({ fields: attributes })
await checkHook('action:api.live-video.created')
})
@@ -85,20 +85,20 @@ describe('Test plugin action hooks', function () {
describe('Comments hooks', function () {
it('Should run action:api.video-thread.created', async function () {
const created = await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'thread' })
const created = await servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' })
threadId = created.id
await checkHook('action:api.video-thread.created')
})
it('Should run action:api.video-comment-reply.created', async function () {
await servers[0].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: 'reply' })
await servers[0].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: 'reply' })
await checkHook('action:api.video-comment-reply.created')
})
it('Should run action:api.video-comment.deleted', async function () {
await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId: threadId })
await servers[0].comments.delete({ videoId: videoUUID, commentId: threadId })
await checkHook('action:api.video-comment.deleted')
})
@@ -108,44 +108,44 @@ describe('Test plugin action hooks', function () {
let userId: number
it('Should run action:api.user.registered', async function () {
await servers[0].usersCommand.register({ username: 'registered_user' })
await servers[0].users.register({ username: 'registered_user' })
await checkHook('action:api.user.registered')
})
it('Should run action:api.user.created', async function () {
const user = await servers[0].usersCommand.create({ username: 'created_user' })
const user = await servers[0].users.create({ username: 'created_user' })
userId = user.id
await checkHook('action:api.user.created')
})
it('Should run action:api.user.oauth2-got-token', async function () {
await servers[0].loginCommand.getAccessToken('created_user', 'super_password')
await servers[0].login.getAccessToken('created_user', 'super_password')
await checkHook('action:api.user.oauth2-got-token')
})
it('Should run action:api.user.blocked', async function () {
await servers[0].usersCommand.banUser({ userId })
await servers[0].users.banUser({ userId })
await checkHook('action:api.user.blocked')
})
it('Should run action:api.user.unblocked', async function () {
await servers[0].usersCommand.unbanUser({ userId })
await servers[0].users.unbanUser({ userId })
await checkHook('action:api.user.unblocked')
})
it('Should run action:api.user.updated', async function () {
await servers[0].usersCommand.update({ userId, videoQuota: 50 })
await servers[0].users.update({ userId, videoQuota: 50 })
await checkHook('action:api.user.updated')
})
it('Should run action:api.user.deleted', async function () {
await servers[0].usersCommand.remove({ userId })
await servers[0].users.remove({ userId })
await checkHook('action:api.user.deleted')
})
@@ -157,7 +157,7 @@ describe('Test plugin action hooks', function () {
before(async function () {
{
const { id } = await servers[0].playlistsCommand.create({
const { id } = await servers[0].playlists.create({
attributes: {
displayName: 'My playlist',
privacy: VideoPlaylistPrivacy.PRIVATE
@@ -167,13 +167,13 @@ describe('Test plugin action hooks', function () {
}
{
const { id } = await servers[0].videosCommand.upload({ attributes: { name: 'my super name' } })
const { id } = await servers[0].videos.upload({ attributes: { name: 'my super name' } })
videoId = id
}
})
it('Should run action:api.video-playlist-element.created', async function () {
await servers[0].playlistsCommand.addElement({ playlistId, attributes: { videoId } })
await servers[0].playlists.addElement({ playlistId, attributes: { videoId } })
await checkHook('action:api.video-playlist-element.created')
})

View File

@@ -23,7 +23,7 @@ async function loginExternal (options: {
statusCodeExpected?: HttpStatusCode
statusCodeExpectedStep2?: HttpStatusCode
}) {
const res = await options.server.pluginsCommand.getExternalAuth({
const res = await options.server.plugins.getExternalAuth({
npmName: options.npmName,
npmVersion: '0.0.1',
authName: options.authName,
@@ -36,7 +36,7 @@ async function loginExternal (options: {
const location = res.header.location
const { externalAuthToken } = decodeQueryString(location)
const resLogin = await options.server.loginCommand.loginUsingExternalToken({
const resLogin = await options.server.login.loginUsingExternalToken({
username: options.username,
externalAuthToken: externalAuthToken as string,
expectedStatus: options.statusCodeExpectedStep2
@@ -63,12 +63,12 @@ describe('Test external auth plugins', function () {
await setAccessTokensToServers([ server ])
for (const suffix of [ 'one', 'two', 'three' ]) {
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-external-auth-' + suffix) })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-external-auth-' + suffix) })
}
})
it('Should display the correct configuration', async function () {
const config = await server.configCommand.getConfig()
const config = await server.config.getConfig()
const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(8)
@@ -80,7 +80,7 @@ describe('Test external auth plugins', function () {
})
it('Should redirect for a Cyan login', async function () {
const res = await server.pluginsCommand.getExternalAuth({
const res = await server.plugins.getExternalAuth({
npmName: 'test-external-auth-one',
npmVersion: '0.0.1',
authName: 'external-auth-1',
@@ -102,14 +102,14 @@ describe('Test external auth plugins', function () {
})
it('Should reject auto external login with a missing or invalid token', async function () {
const command = server.loginCommand
const command = server.login
await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: '', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: 'blabla', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should reject auto external login with a missing or invalid username', async function () {
const command = server.loginCommand
const command = server.login
await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
@@ -120,13 +120,13 @@ describe('Test external auth plugins', function () {
await wait(5000)
await server.loginCommand.loginUsingExternalToken({
await server.login.loginUsingExternalToken({
username: 'cyan',
externalAuthToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await server.serversCommand.waitUntilLog('expired external auth token', 2)
await server.servers.waitUntilLog('expired external auth token', 2)
})
it('Should auto login Cyan, create the user and use the token', async function () {
@@ -146,7 +146,7 @@ describe('Test external auth plugins', function () {
}
{
const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken })
const body = await server.users.getMyInfo({ token: cyanAccessToken })
expect(body.username).to.equal('cyan')
expect(body.account.displayName).to.equal('cyan')
expect(body.email).to.equal('cyan@example.com')
@@ -168,7 +168,7 @@ describe('Test external auth plugins', function () {
}
{
const body = await server.usersCommand.getMyInfo({ token: kefkaAccessToken })
const body = await server.users.getMyInfo({ token: kefkaAccessToken })
expect(body.username).to.equal('kefka')
expect(body.account.displayName).to.equal('Kefka Palazzo')
expect(body.email).to.equal('kefka@example.com')
@@ -178,39 +178,39 @@ describe('Test external auth plugins', function () {
it('Should refresh Cyan token, but not Kefka token', async function () {
{
const resRefresh = await server.loginCommand.refreshToken({ refreshToken: cyanRefreshToken })
const resRefresh = await server.login.refreshToken({ refreshToken: cyanRefreshToken })
cyanAccessToken = resRefresh.body.access_token
cyanRefreshToken = resRefresh.body.refresh_token
const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken })
const body = await server.users.getMyInfo({ token: cyanAccessToken })
expect(body.username).to.equal('cyan')
}
{
await server.loginCommand.refreshToken({ refreshToken: kefkaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.login.refreshToken({ refreshToken: kefkaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
})
it('Should update Cyan profile', async function () {
await server.usersCommand.updateMe({
await server.users.updateMe({
token: cyanAccessToken,
displayName: 'Cyan Garamonde',
description: 'Retainer to the king of Doma'
})
const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken })
const body = await server.users.getMyInfo({ token: cyanAccessToken })
expect(body.account.displayName).to.equal('Cyan Garamonde')
expect(body.account.description).to.equal('Retainer to the king of Doma')
})
it('Should logout Cyan', async function () {
await server.loginCommand.logout({ token: cyanAccessToken })
await server.login.logout({ token: cyanAccessToken })
})
it('Should have logged out Cyan', async function () {
await server.serversCommand.waitUntilLog('On logout cyan')
await server.servers.waitUntilLog('On logout cyan')
await server.usersCommand.getMyInfo({ token: cyanAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
await server.users.getMyInfo({ token: cyanAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should login Cyan and keep the old existing profile', async function () {
@@ -228,7 +228,7 @@ describe('Test external auth plugins', function () {
cyanAccessToken = res.access_token
}
const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken })
const body = await server.users.getMyInfo({ token: cyanAccessToken })
expect(body.username).to.equal('cyan')
expect(body.account.displayName).to.equal('Cyan Garamonde')
expect(body.account.description).to.equal('Retainer to the king of Doma')
@@ -236,7 +236,7 @@ describe('Test external auth plugins', function () {
})
it('Should not update an external auth email', async function () {
await server.usersCommand.updateMe({
await server.users.updateMe({
token: cyanAccessToken,
email: 'toto@example.com',
currentPassword: 'toto',
@@ -249,16 +249,16 @@ describe('Test external auth plugins', function () {
await wait(5000)
await server.usersCommand.getMyInfo({ token: kefkaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
await server.users.getMyInfo({ token: kefkaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should unregister external-auth-2 and do not login existing Kefka', async function () {
await server.pluginsCommand.updateSettings({
await server.plugins.updateSettings({
npmName: 'peertube-plugin-test-external-auth-one',
settings: { disableKefka: true }
})
await server.loginCommand.login({ user: { username: 'kefka', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.login.login({ user: { username: 'kefka', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await loginExternal({
server,
@@ -273,7 +273,7 @@ describe('Test external auth plugins', function () {
})
it('Should have disabled this auth', async function () {
const config = await server.configCommand.getConfig()
const config = await server.config.getConfig()
const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(7)
@@ -283,7 +283,7 @@ describe('Test external auth plugins', function () {
})
it('Should uninstall the plugin one and do not login Cyan', async function () {
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' })
await server.plugins.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' })
await loginExternal({
server,
@@ -296,9 +296,9 @@ describe('Test external auth plugins', function () {
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
})
await server.loginCommand.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.loginCommand.login({ user: { username: 'cyan', password: '' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.loginCommand.login({ user: { username: 'cyan', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.login.login({ user: { username: 'cyan', password: '' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.login.login({ user: { username: 'cyan', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not login kefka with another plugin', async function () {
@@ -320,7 +320,7 @@ describe('Test external auth plugins', function () {
})
it('Should not login an existing user', async function () {
await server.usersCommand.create({ username: 'existing_user', password: 'super_password' })
await server.users.create({ username: 'existing_user', password: 'super_password' })
await loginExternal({
server,
@@ -332,7 +332,7 @@ describe('Test external auth plugins', function () {
})
it('Should display the correct configuration', async function () {
const config = await server.configCommand.getConfig()
const config = await server.config.getConfig()
const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(6)
@@ -353,7 +353,7 @@ describe('Test external auth plugins', function () {
username: 'cid'
})
const { redirectUrl } = await server.loginCommand.logout({ token: resLogin.access_token })
const { redirectUrl } = await server.login.logout({ token: resLogin.access_token })
expect(redirectUrl).to.equal('https://example.com/redirectUrl')
})
@@ -365,7 +365,7 @@ describe('Test external auth plugins', function () {
username: 'cid'
})
const { redirectUrl } = await server.loginCommand.logout({ token: resLogin.access_token })
const { redirectUrl } = await server.login.logout({ token: resLogin.access_token })
expect(redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token)
})
})

View File

@@ -32,17 +32,17 @@ describe('Test plugin filter hooks', function () {
await setDefaultVideoChannel(servers)
await doubleFollow(servers[0], servers[1])
await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() })
await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() })
await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
for (let i = 0; i < 10; i++) {
await servers[0].videosCommand.upload({ attributes: { name: 'default video ' + i } })
await servers[0].videos.upload({ attributes: { name: 'default video ' + i } })
}
const { data } = await servers[0].videosCommand.list()
const { data } = await servers[0].videos.list()
videoUUID = data[0].uuid
await servers[0].configCommand.updateCustomSubConfig({
await servers[0].config.updateCustomSubConfig({
newConfig: {
live: { enabled: true },
signup: { enabled: true },
@@ -57,98 +57,98 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.videos.list.params', async function () {
const { data } = await servers[0].videosCommand.list({ start: 0, count: 2 })
const { data } = await servers[0].videos.list({ start: 0, count: 2 })
// 2 plugins do +1 to the count parameter
expect(data).to.have.lengthOf(4)
})
it('Should run filter:api.videos.list.result', async function () {
const { total } = await servers[0].videosCommand.list({ start: 0, count: 0 })
const { total } = await servers[0].videos.list({ start: 0, count: 0 })
// Plugin do +1 to the total result
expect(total).to.equal(11)
})
it('Should run filter:api.accounts.videos.list.params', async function () {
const { data } = await servers[0].videosCommand.listByAccount({ accountName: 'root', start: 0, count: 2 })
const { data } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 })
// 1 plugin do +1 to the count parameter
expect(data).to.have.lengthOf(3)
})
it('Should run filter:api.accounts.videos.list.result', async function () {
const { total } = await servers[0].videosCommand.listByAccount({ accountName: 'root', start: 0, count: 2 })
const { total } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 })
// Plugin do +2 to the total result
expect(total).to.equal(12)
})
it('Should run filter:api.video-channels.videos.list.params', async function () {
const { data } = await servers[0].videosCommand.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
const { data } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
// 1 plugin do +3 to the count parameter
expect(data).to.have.lengthOf(5)
})
it('Should run filter:api.video-channels.videos.list.result', async function () {
const { total } = await servers[0].videosCommand.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
const { total } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
// Plugin do +3 to the total result
expect(total).to.equal(13)
})
it('Should run filter:api.user.me.videos.list.params', async function () {
const { data } = await servers[0].videosCommand.listMyVideos({ start: 0, count: 2 })
const { data } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
// 1 plugin do +4 to the count parameter
expect(data).to.have.lengthOf(6)
})
it('Should run filter:api.user.me.videos.list.result', async function () {
const { total } = await servers[0].videosCommand.listMyVideos({ start: 0, count: 2 })
const { total } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
// Plugin do +4 to the total result
expect(total).to.equal(14)
})
it('Should run filter:api.video.get.result', async function () {
const video = await servers[0].videosCommand.get({ id: videoUUID })
const video = await servers[0].videos.get({ id: videoUUID })
expect(video.name).to.contain('<3')
})
it('Should run filter:api.video.upload.accept.result', async function () {
await servers[0].videosCommand.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
await servers[0].videos.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.live-video.create.accept.result', async function () {
const attributes = {
name: 'video with bad word',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id
channelId: servers[0].store.channel.id
}
await servers[0].liveCommand.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
await servers[0].live.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.video.pre-import-url.accept.result', async function () {
const attributes = {
name: 'normal title',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id,
channelId: servers[0].store.channel.id,
targetUrl: ImportsCommand.getGoodVideoUrl() + 'bad'
}
await servers[0].importsCommand.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.video.pre-import-torrent.accept.result', async function () {
const attributes = {
name: 'bad torrent',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id,
channelId: servers[0].store.channel.id,
torrentfile: 'video-720p.torrent' as any
}
await servers[0].importsCommand.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.video.post-import-url.accept.result', async function () {
@@ -160,17 +160,17 @@ describe('Test plugin filter hooks', function () {
const attributes = {
name: 'title with bad word',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id,
channelId: servers[0].store.channel.id,
targetUrl: ImportsCommand.getGoodVideoUrl()
}
const body = await servers[0].importsCommand.importVideo({ attributes })
const body = await servers[0].imports.importVideo({ attributes })
videoImportId = body.id
}
await waitJobs(servers)
{
const body = await servers[0].importsCommand.getMyVideoImports()
const body = await servers[0].imports.getMyVideoImports()
const videoImports = body.data
const videoImport = videoImports.find(i => i.id === videoImportId)
@@ -189,17 +189,17 @@ describe('Test plugin filter hooks', function () {
const attributes = {
name: 'title with bad word',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].videoChannel.id,
channelId: servers[0].store.channel.id,
torrentfile: 'video-720p.torrent' as any
}
const body = await servers[0].importsCommand.importVideo({ attributes })
const body = await servers[0].imports.importVideo({ attributes })
videoImportId = body.id
}
await waitJobs(servers)
{
const { data: videoImports } = await servers[0].importsCommand.getMyVideoImports()
const { data: videoImports } = await servers[0].imports.getMyVideoImports()
const videoImport = videoImports.find(i => i.id === videoImportId)
@@ -209,7 +209,7 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.video-thread.create.accept.result', async function () {
await servers[0].commentsCommand.createThread({
await servers[0].comments.createThread({
videoId: videoUUID,
text: 'comment with bad word',
expectedStatus: HttpStatusCode.FORBIDDEN_403
@@ -217,16 +217,16 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.video-comment-reply.create.accept.result', async function () {
const created = await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'thread' })
const created = await servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' })
threadId = created.id
await servers[0].commentsCommand.addReply({
await servers[0].comments.addReply({
videoId: videoUUID,
toCommentId: threadId,
text: 'comment with bad word',
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
await servers[0].commentsCommand.addReply({
await servers[0].comments.addReply({
videoId: videoUUID,
toCommentId: threadId,
text: 'comment with good word',
@@ -235,14 +235,14 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.video-threads.list.params', async function () {
const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 0 })
const { data } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
// our plugin do +1 to the count parameter
expect(data).to.have.lengthOf(1)
})
it('Should run filter:api.video-threads.list.result', async function () {
const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 0 })
const { total } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
// Plugin do +1 to the total result
expect(total).to.equal(2)
@@ -251,7 +251,7 @@ describe('Test plugin filter hooks', function () {
it('Should run filter:api.video-thread-comments.list.params')
it('Should run filter:api.video-thread-comments.list.result', async function () {
const thread = await servers[0].commentsCommand.getThread({ videoId: videoUUID, threadId })
const thread = await servers[0].comments.getThread({ videoId: videoUUID, threadId })
expect(thread.comment.text.endsWith(' <3')).to.be.true
})
@@ -259,12 +259,12 @@ describe('Test plugin filter hooks', function () {
describe('Should run filter:video.auto-blacklist.result', function () {
async function checkIsBlacklisted (id: number | string, value: boolean) {
const video = await servers[0].videosCommand.getWithToken({ id })
const video = await servers[0].videos.getWithToken({ id })
expect(video.blacklisted).to.equal(value)
}
it('Should blacklist on upload', async function () {
const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video please blacklist me' } })
const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video please blacklist me' } })
await checkIsBlacklisted(uuid, true)
})
@@ -274,24 +274,24 @@ describe('Test plugin filter hooks', function () {
const attributes = {
name: 'video please blacklist me',
targetUrl: ImportsCommand.getGoodVideoUrl(),
channelId: servers[0].videoChannel.id
channelId: servers[0].store.channel.id
}
const body = await servers[0].importsCommand.importVideo({ attributes })
const body = await servers[0].imports.importVideo({ attributes })
await checkIsBlacklisted(body.video.uuid, true)
})
it('Should blacklist on update', async function () {
const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' } })
const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' } })
await checkIsBlacklisted(uuid, false)
await servers[0].videosCommand.update({ id: uuid, attributes: { name: 'please blacklist me' } })
await servers[0].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
await checkIsBlacklisted(uuid, true)
})
it('Should blacklist on remote upload', async function () {
this.timeout(120000)
const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'remote please blacklist me' } })
const { uuid } = await servers[1].videos.upload({ attributes: { name: 'remote please blacklist me' } })
await waitJobs(servers)
await checkIsBlacklisted(uuid, true)
@@ -300,12 +300,12 @@ describe('Test plugin filter hooks', function () {
it('Should blacklist on remote update', async function () {
this.timeout(120000)
const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video' } })
const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video' } })
await waitJobs(servers)
await checkIsBlacklisted(uuid, false)
await servers[1].videosCommand.update({ id: uuid, attributes: { name: 'please blacklist me' } })
await servers[1].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
await waitJobs(servers)
await checkIsBlacklisted(uuid, true)
@@ -315,16 +315,16 @@ describe('Test plugin filter hooks', function () {
describe('Should run filter:api.user.signup.allowed.result', function () {
it('Should run on config endpoint', async function () {
const body = await servers[0].configCommand.getConfig()
const body = await servers[0].config.getConfig()
expect(body.signup.allowed).to.be.true
})
it('Should allow a signup', async function () {
await servers[0].usersCommand.register({ username: 'john', password: 'password' })
await servers[0].users.register({ username: 'john', password: 'password' })
})
it('Should not allow a signup', async function () {
const res = await servers[0].usersCommand.register({
const res = await servers[0].users.register({
username: 'jma',
password: 'password',
expectedStatus: HttpStatusCode.FORBIDDEN_403
@@ -340,7 +340,7 @@ describe('Test plugin filter hooks', function () {
before(async function () {
this.timeout(120000)
await servers[0].configCommand.updateCustomSubConfig({
await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
webtorrent: {
@@ -356,14 +356,14 @@ describe('Test plugin filter hooks', function () {
const uuids: string[] = []
for (const name of [ 'bad torrent', 'bad file', 'bad playlist file' ]) {
const uuid = (await servers[0].videosCommand.quickUpload({ name: name })).uuid
const uuid = (await servers[0].videos.quickUpload({ name: name })).uuid
uuids.push(uuid)
}
await waitJobs(servers)
for (const uuid of uuids) {
downloadVideos.push(await servers[0].videosCommand.get({ id: uuid }))
downloadVideos.push(await servers[0].videos.get({ id: uuid }))
}
})
@@ -403,7 +403,7 @@ describe('Test plugin filter hooks', function () {
before(async function () {
this.timeout(60000)
await servers[0].configCommand.updateCustomSubConfig({
await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: false
@@ -413,15 +413,15 @@ describe('Test plugin filter hooks', function () {
for (const name of [ 'bad embed', 'good embed' ]) {
{
const uuid = (await servers[0].videosCommand.quickUpload({ name: name })).uuid
embedVideos.push(await servers[0].videosCommand.get({ id: uuid }))
const uuid = (await servers[0].videos.quickUpload({ name: name })).uuid
embedVideos.push(await servers[0].videos.get({ id: uuid }))
}
{
const attributes = { displayName: name, videoChannelId: servers[0].videoChannel.id, privacy: VideoPlaylistPrivacy.PUBLIC }
const { id } = await servers[0].playlistsCommand.create({ attributes })
const attributes = { displayName: name, videoChannelId: servers[0].store.channel.id, privacy: VideoPlaylistPrivacy.PUBLIC }
const { id } = await servers[0].playlists.create({ attributes })
const playlist = await servers[0].playlistsCommand.get({ playlistId: id })
const playlist = await servers[0].playlists.get({ playlistId: id })
embedPlaylists.push(playlist)
}
}
@@ -441,7 +441,7 @@ describe('Test plugin filter hooks', function () {
describe('Search filters', function () {
before(async function () {
await servers[0].configCommand.updateCustomSubConfig({
await servers[0].config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
@@ -455,78 +455,78 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.search.videos.local.list.{params,result}', async function () {
await servers[0].searchCommand.advancedVideoSearch({
await servers[0].search.advancedVideoSearch({
search: {
search: 'Sun Quan'
}
})
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
})
it('Should run filter:api.search.videos.index.list.{params,result}', async function () {
await servers[0].searchCommand.advancedVideoSearch({
await servers[0].search.advancedVideoSearch({
search: {
search: 'Sun Quan',
searchTarget: 'search-index'
}
})
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1)
})
it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () {
await servers[0].searchCommand.advancedChannelSearch({
await servers[0].search.advancedChannelSearch({
search: {
search: 'Sun Ce'
}
})
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
})
it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () {
await servers[0].searchCommand.advancedChannelSearch({
await servers[0].search.advancedChannelSearch({
search: {
search: 'Sun Ce',
searchTarget: 'search-index'
}
})
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1)
})
it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () {
await servers[0].searchCommand.advancedPlaylistSearch({
await servers[0].search.advancedPlaylistSearch({
search: {
search: 'Sun Jian'
}
})
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
})
it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () {
await servers[0].searchCommand.advancedPlaylistSearch({
await servers[0].search.advancedPlaylistSearch({
search: {
search: 'Sun Jian',
searchTarget: 'search-index'
}
})
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1)
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1)
await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1)
})
})

View File

@@ -23,7 +23,7 @@ describe('Test plugins HTML injection', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
command = server.pluginsCommand
command = server.plugins
})
it('Should not inject global css file in HTML', async function () {

View File

@@ -22,12 +22,12 @@ describe('Test id and pass auth plugins', function () {
await setAccessTokensToServers([ server ])
for (const suffix of [ 'one', 'two', 'three' ]) {
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) })
}
})
it('Should display the correct configuration', async function () {
const config = await server.configCommand.getConfig()
const config = await server.config.getConfig()
const auths = config.plugin.registeredIdAndPassAuths
expect(auths).to.have.lengthOf(8)
@@ -39,13 +39,13 @@ describe('Test id and pass auth plugins', function () {
})
it('Should not login', async function () {
await server.loginCommand.login({ user: { username: 'toto', password: 'password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.login.login({ user: { username: 'toto', password: 'password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should login Spyro, create the user and use the token', async function () {
const accessToken = await server.loginCommand.getAccessToken({ username: 'spyro', password: 'spyro password' })
const accessToken = await server.login.getAccessToken({ username: 'spyro', password: 'spyro password' })
const body = await server.usersCommand.getMyInfo({ token: accessToken })
const body = await server.users.getMyInfo({ token: accessToken })
expect(body.username).to.equal('spyro')
expect(body.account.displayName).to.equal('Spyro the Dragon')
@@ -54,13 +54,13 @@ describe('Test id and pass auth plugins', function () {
it('Should login Crash, create the user and use the token', async function () {
{
const body = await server.loginCommand.login({ user: { username: 'crash', password: 'crash password' } })
const body = await server.login.login({ user: { username: 'crash', password: 'crash password' } })
crashAccessToken = body.access_token
crashRefreshToken = body.refresh_token
}
{
const body = await server.usersCommand.getMyInfo({ token: crashAccessToken })
const body = await server.users.getMyInfo({ token: crashAccessToken })
expect(body.username).to.equal('crash')
expect(body.account.displayName).to.equal('Crash Bandicoot')
@@ -70,13 +70,13 @@ describe('Test id and pass auth plugins', function () {
it('Should login the first Laguna, create the user and use the token', async function () {
{
const body = await server.loginCommand.login({ user: { username: 'laguna', password: 'laguna password' } })
const body = await server.login.login({ user: { username: 'laguna', password: 'laguna password' } })
lagunaAccessToken = body.access_token
lagunaRefreshToken = body.refresh_token
}
{
const body = await server.usersCommand.getMyInfo({ token: lagunaAccessToken })
const body = await server.users.getMyInfo({ token: lagunaAccessToken })
expect(body.username).to.equal('laguna')
expect(body.account.displayName).to.equal('laguna')
@@ -86,46 +86,46 @@ describe('Test id and pass auth plugins', function () {
it('Should refresh crash token, but not laguna token', async function () {
{
const resRefresh = await server.loginCommand.refreshToken({ refreshToken: crashRefreshToken })
const resRefresh = await server.login.refreshToken({ refreshToken: crashRefreshToken })
crashAccessToken = resRefresh.body.access_token
crashRefreshToken = resRefresh.body.refresh_token
const body = await server.usersCommand.getMyInfo({ token: crashAccessToken })
const body = await server.users.getMyInfo({ token: crashAccessToken })
expect(body.username).to.equal('crash')
}
{
await server.loginCommand.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.login.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
})
it('Should update Crash profile', async function () {
await server.usersCommand.updateMe({
await server.users.updateMe({
token: crashAccessToken,
displayName: 'Beautiful Crash',
description: 'Mutant eastern barred bandicoot'
})
const body = await server.usersCommand.getMyInfo({ token: crashAccessToken })
const body = await server.users.getMyInfo({ token: crashAccessToken })
expect(body.account.displayName).to.equal('Beautiful Crash')
expect(body.account.description).to.equal('Mutant eastern barred bandicoot')
})
it('Should logout Crash', async function () {
await server.loginCommand.logout({ token: crashAccessToken })
await server.login.logout({ token: crashAccessToken })
})
it('Should have logged out Crash', async function () {
await server.serversCommand.waitUntilLog('On logout for auth 1 - 2')
await server.servers.waitUntilLog('On logout for auth 1 - 2')
await server.usersCommand.getMyInfo({ token: crashAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
await server.users.getMyInfo({ token: crashAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should login Crash and keep the old existing profile', async function () {
crashAccessToken = await server.loginCommand.getAccessToken({ username: 'crash', password: 'crash password' })
crashAccessToken = await server.login.getAccessToken({ username: 'crash', password: 'crash password' })
const body = await server.usersCommand.getMyInfo({ token: crashAccessToken })
const body = await server.users.getMyInfo({ token: crashAccessToken })
expect(body.username).to.equal('crash')
expect(body.account.displayName).to.equal('Beautiful Crash')
@@ -138,38 +138,38 @@ describe('Test id and pass auth plugins', function () {
await wait(5000)
await server.usersCommand.getMyInfo({ token: lagunaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
await server.users.getMyInfo({ token: lagunaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should reject an invalid username, email, role or display name', async function () {
const command = server.loginCommand
const command = server.login
await command.login({ user: { username: 'ward', password: 'ward password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.serversCommand.waitUntilLog('valid username')
await server.servers.waitUntilLog('valid username')
await command.login({ user: { username: 'kiros', password: 'kiros password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.serversCommand.waitUntilLog('valid display name')
await server.servers.waitUntilLog('valid display name')
await command.login({ user: { username: 'raine', password: 'raine password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.serversCommand.waitUntilLog('valid role')
await server.servers.waitUntilLog('valid role')
await command.login({ user: { username: 'ellone', password: 'elonne password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.serversCommand.waitUntilLog('valid email')
await server.servers.waitUntilLog('valid email')
})
it('Should unregister spyro-auth and do not login existing Spyro', async function () {
await server.pluginsCommand.updateSettings({
await server.plugins.updateSettings({
npmName: 'peertube-plugin-test-id-pass-auth-one',
settings: { disableSpyro: true }
})
const command = server.loginCommand
const command = server.login
await command.login({ user: { username: 'spyro', password: 'spyro password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await command.login({ user: { username: 'spyro', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should have disabled this auth', async function () {
const config = await server.configCommand.getConfig()
const config = await server.config.getConfig()
const auths = config.plugin.registeredIdAndPassAuths
expect(auths).to.have.lengthOf(7)
@@ -179,16 +179,16 @@ describe('Test id and pass auth plugins', function () {
})
it('Should uninstall the plugin one and do not login existing Crash', async function () {
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' })
await server.plugins.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' })
await server.loginCommand.login({
await server.login.login({
user: { username: 'crash', password: 'crash password' },
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
it('Should display the correct configuration', async function () {
const config = await server.configCommand.getConfig()
const config = await server.config.getConfig()
const auths = config.plugin.registeredIdAndPassAuths
expect(auths).to.have.lengthOf(6)
@@ -198,7 +198,7 @@ describe('Test id and pass auth plugins', function () {
})
it('Should display plugin auth information in users list', async function () {
const { data } = await server.usersCommand.list()
const { data } = await server.users.list()
const root = data.find(u => u.username === 'root')
const crash = data.find(u => u.username === 'crash')

View File

@@ -39,28 +39,28 @@ describe('Test plugin helpers', function () {
await doubleFollow(servers[0], servers[1])
await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-four') })
await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-four') })
})
describe('Logger', function () {
it('Should have logged things', async function () {
await servers[0].serversCommand.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false)
await servers[0].serversCommand.waitUntilLog('Hello world from plugin four', 1)
await servers[0].servers.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false)
await servers[0].servers.waitUntilLog('Hello world from plugin four', 1)
})
})
describe('Database', function () {
it('Should have made a query', async function () {
await servers[0].serversCommand.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`)
await servers[0].servers.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`)
})
})
describe('Config', function () {
it('Should have the correct webserver url', async function () {
await servers[0].serversCommand.waitUntilLog(`server url is http://localhost:${servers[0].port}`)
await servers[0].servers.waitUntilLog(`server url is http://localhost:${servers[0].port}`)
})
it('Should have the correct config', async function () {
@@ -78,7 +78,7 @@ describe('Test plugin helpers', function () {
describe('Server', function () {
it('Should get the server actor', async function () {
await servers[0].serversCommand.waitUntilLog('server actor name is peertube')
await servers[0].servers.waitUntilLog('server actor name is peertube')
})
})
@@ -140,17 +140,17 @@ describe('Test plugin helpers', function () {
this.timeout(60000)
{
const res = await await servers[0].videosCommand.quickUpload({ name: 'video server 1' })
const res = await await servers[0].videos.quickUpload({ name: 'video server 1' })
videoUUIDServer1 = res.uuid
}
{
await await servers[1].videosCommand.quickUpload({ name: 'video server 2' })
await await servers[1].videos.quickUpload({ name: 'video server 2' })
}
await waitJobs(servers)
const { data } = await servers[0].videosCommand.list()
const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(2)
})
@@ -159,7 +159,7 @@ describe('Test plugin helpers', function () {
this.timeout(10000)
await postCommand(servers[0], 'blockServer', { hostToBlock: `localhost:${servers[1].port}` })
const { data } = await servers[0].videosCommand.list()
const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(1)
expect(data[0].name).to.equal('video server 1')
@@ -168,7 +168,7 @@ describe('Test plugin helpers', function () {
it('Should unmute server 2', async function () {
await postCommand(servers[0], 'unblockServer', { hostToUnblock: `localhost:${servers[1].port}` })
const { data } = await servers[0].videosCommand.list()
const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(2)
})
@@ -176,7 +176,7 @@ describe('Test plugin helpers', function () {
it('Should mute account of server 2', async function () {
await postCommand(servers[0], 'blockAccount', { handleToBlock: `root@localhost:${servers[1].port}` })
const { data } = await servers[0].videosCommand.list()
const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(1)
expect(data[0].name).to.equal('video server 1')
@@ -185,7 +185,7 @@ describe('Test plugin helpers', function () {
it('Should unmute account of server 2', async function () {
await postCommand(servers[0], 'unblockAccount', { handleToUnblock: `root@localhost:${servers[1].port}` })
const { data } = await servers[0].videosCommand.list()
const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(2)
})
@@ -198,7 +198,7 @@ describe('Test plugin helpers', function () {
await waitJobs(servers)
for (const server of servers) {
const { data } = await server.videosCommand.list()
const { data } = await server.videos.list()
expect(data).to.have.lengthOf(1)
expect(data[0].name).to.equal('video server 2')
@@ -213,7 +213,7 @@ describe('Test plugin helpers', function () {
await waitJobs(servers)
for (const server of servers) {
const { data } = await server.videosCommand.list()
const { data } = await server.videos.list()
expect(data).to.have.lengthOf(2)
}
@@ -224,7 +224,7 @@ describe('Test plugin helpers', function () {
let videoUUID: string
before(async () => {
const res = await await servers[0].videosCommand.quickUpload({ name: 'video1' })
const res = await await servers[0].videos.quickUpload({ name: 'video1' })
videoUUID = res.uuid
})
@@ -232,15 +232,15 @@ describe('Test plugin helpers', function () {
this.timeout(40000)
// Should not throw -> video exists
await servers[0].videosCommand.get({ id: videoUUID })
await servers[0].videos.get({ id: videoUUID })
// Should delete the video
await servers[0].videosCommand.view({ id: videoUUID })
await servers[0].videos.view({ id: videoUUID })
await servers[0].serversCommand.waitUntilLog('Video deleted by plugin four.')
await servers[0].servers.waitUntilLog('Video deleted by plugin four.')
try {
// Should throw because the video should have been deleted
await servers[0].videosCommand.get({ id: videoUUID })
await servers[0].videos.get({ id: videoUUID })
throw new Error('Video exists')
} catch (err) {
if (err.message.includes('exists')) throw err
@@ -250,7 +250,7 @@ describe('Test plugin helpers', function () {
})
it('Should have fetched the video by URL', async function () {
await servers[0].serversCommand.waitUntilLog(`video from DB uuid is ${videoUUID}`)
await servers[0].servers.waitUntilLog(`video from DB uuid is ${videoUUID}`)
})
})

View File

@@ -26,7 +26,7 @@ describe('Test plugin helpers', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-five') })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') })
})
it('Should answer "pong"', async function () {
@@ -82,7 +82,7 @@ describe('Test plugin helpers', function () {
})
it('Should remove the plugin and remove the routes', async function () {
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-five' })
await server.plugins.uninstall({ npmName: 'peertube-plugin-test-five' })
for (const path of basePaths) {
await makeGetRequest({

View File

@@ -16,13 +16,13 @@ describe('Test plugin storage', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') })
})
describe('DB storage', function () {
it('Should correctly store a subkey', async function () {
await server.serversCommand.waitUntilLog('superkey stored value is toto')
await server.servers.waitUntilLog('superkey stored value is toto')
})
})
@@ -38,12 +38,12 @@ describe('Test plugin storage', function () {
}
before(function () {
dataPath = server.serversCommand.buildDirectory('plugins/data')
dataPath = server.servers.buildDirectory('plugins/data')
pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
})
it('Should have created the directory on install', async function () {
const dataPath = server.serversCommand.buildDirectory('plugins/data')
const dataPath = server.servers.buildDirectory('plugins/data')
const pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
expect(await pathExists(dataPath)).to.be.true
@@ -64,14 +64,14 @@ describe('Test plugin storage', function () {
})
it('Should still have the file after an uninstallation', async function () {
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-six' })
await server.plugins.uninstall({ npmName: 'peertube-plugin-test-six' })
const content = await getFileContent()
expect(content).to.equal('Prince Ali')
})
it('Should still have the file after the reinstallation', async function () {
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') })
const content = await getFileContent()
expect(content).to.equal('Prince Ali')

View File

@@ -19,17 +19,17 @@ import { VideoPrivacy } from '@shared/models'
async function createLiveWrapper (server: ServerInfo) {
const liveAttributes = {
name: 'live video',
channelId: server.videoChannel.id,
channelId: server.store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
const { uuid } = await server.liveCommand.create({ fields: liveAttributes })
const { uuid } = await server.live.create({ fields: liveAttributes })
return uuid
}
function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) {
return server.configCommand.updateCustomSubConfig({
return server.config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: true,
@@ -79,7 +79,7 @@ describe('Test transcoding plugins', function () {
describe('When using a plugin adding profiles to existing encoders', function () {
async function checkVideoFPS (uuid: string, type: 'above' | 'below', fps: number) {
const video = await server.videosCommand.get({ id: uuid })
const video = await server.videos.get({ id: uuid })
const files = video.files.concat(...video.streamingPlaylists.map(p => p.files))
for (const file of files) {
@@ -103,11 +103,11 @@ describe('Test transcoding plugins', function () {
}
before(async function () {
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') })
})
it('Should have the appropriate available profiles', async function () {
const config = await server.configCommand.getConfig()
const config = await server.config.getConfig()
expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ])
expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'low-live', 'input-options-live', 'bad-scale-live' ])
@@ -116,7 +116,7 @@ describe('Test transcoding plugins', function () {
it('Should not use the plugin profile if not chosen by the admin', async function () {
this.timeout(240000)
const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
await checkVideoFPS(videoUUID, 'above', 20)
@@ -127,7 +127,7 @@ describe('Test transcoding plugins', function () {
await updateConf(server, 'low-vod', 'default')
const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
await checkVideoFPS(videoUUID, 'below', 12)
@@ -138,7 +138,7 @@ describe('Test transcoding plugins', function () {
await updateConf(server, 'input-options-vod', 'default')
const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
await checkVideoFPS(videoUUID, 'below', 6)
@@ -149,11 +149,11 @@ describe('Test transcoding plugins', function () {
await updateConf(server, 'bad-scale-vod', 'default')
const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
// Transcoding failed
const video = await server.videosCommand.get({ id: videoUUID })
const video = await server.videos.get({ id: videoUUID })
expect(video.files).to.have.lengthOf(1)
expect(video.streamingPlaylists).to.have.lengthOf(0)
})
@@ -163,8 +163,8 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await server.liveCommand.waitUntilPublished({ videoId: liveVideoId })
await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ])
await checkLiveFPS(liveVideoId, 'above', 20)
@@ -177,8 +177,8 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await server.liveCommand.waitUntilPublished({ videoId: liveVideoId })
await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ])
await checkLiveFPS(liveVideoId, 'below', 12)
@@ -191,8 +191,8 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await server.liveCommand.waitUntilPublished({ videoId: liveVideoId })
await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ])
await checkLiveFPS(liveVideoId, 'below', 6)
@@ -205,21 +205,21 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
const command = await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
const command = await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await testFfmpegStreamError(command, true)
})
it('Should default to the default profile if the specified profile does not exist', async function () {
this.timeout(240000)
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
await server.plugins.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
const config = await server.configCommand.getConfig()
const config = await server.config.getConfig()
expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ])
expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ])
const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
await checkVideoFPS(videoUUID, 'above', 20)
@@ -230,7 +230,7 @@ describe('Test transcoding plugins', function () {
describe('When using a plugin adding new encoders', function () {
before(async function () {
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') })
await updateConf(server, 'test-vod-profile', 'test-live-profile')
})
@@ -238,10 +238,10 @@ describe('Test transcoding plugins', function () {
it('Should use the new vod encoders', async function () {
this.timeout(240000)
const videoUUID = (await server.videosCommand.quickUpload({ name: 'video', fixture: 'video_short_240p.mp4' })).uuid
const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_short_240p.mp4' })).uuid
await waitJobs([ server ])
const path = server.serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4'))
const path = server.servers.buildDirectory(join('videos', videoUUID + '-240.mp4'))
const audioProbe = await getAudioStream(path)
expect(audioProbe.audioStream.codec_name).to.equal('opus')
@@ -254,8 +254,8 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await server.liveCommand.waitUntilPublished({ videoId: liveVideoId })
await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ])
const playlistUrl = `${server.url}/static/streaming-playlists/hls/${liveVideoId}/0.m3u8`

View File

@@ -16,7 +16,7 @@ describe('Test plugins module unloading', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
})
it('Should return a numeric value', async function () {
@@ -41,7 +41,7 @@ describe('Test plugins module unloading', function () {
})
it('Should uninstall the plugin and free the route', async function () {
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-unloading' })
await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' })
await makeGetRequest({
url: server.url,
@@ -51,7 +51,7 @@ describe('Test plugins module unloading', function () {
})
it('Should return a different numeric value', async function () {
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
const res = await makeGetRequest({
url: server.url,

View File

@@ -17,7 +17,7 @@ describe('Test plugin translations', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
command = server.pluginsCommand
command = server.plugins
await command.install({ path: PluginsCommand.getPluginTestPath() })
await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })

View File

@@ -17,11 +17,11 @@ describe('Test plugin altering video constants', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-video-constants') })
await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-video-constants') })
})
it('Should have updated languages', async function () {
const languages = await server.videosCommand.getLanguages()
const languages = await server.videos.getLanguages()
expect(languages['en']).to.not.exist
expect(languages['fr']).to.not.exist
@@ -32,7 +32,7 @@ describe('Test plugin altering video constants', function () {
})
it('Should have updated categories', async function () {
const categories = await server.videosCommand.getCategories()
const categories = await server.videos.getCategories()
expect(categories[1]).to.not.exist
expect(categories[2]).to.not.exist
@@ -42,7 +42,7 @@ describe('Test plugin altering video constants', function () {
})
it('Should have updated licences', async function () {
const licences = await server.videosCommand.getLicences()
const licences = await server.videos.getLicences()
expect(licences[1]).to.not.exist
expect(licences[7]).to.not.exist
@@ -52,7 +52,7 @@ describe('Test plugin altering video constants', function () {
})
it('Should have updated video privacies', async function () {
const privacies = await server.videosCommand.getPrivacies()
const privacies = await server.videos.getPrivacies()
expect(privacies[1]).to.exist
expect(privacies[2]).to.not.exist
@@ -61,7 +61,7 @@ describe('Test plugin altering video constants', function () {
})
it('Should have updated playlist privacies', async function () {
const playlistPrivacies = await server.playlistsCommand.getPrivacies()
const playlistPrivacies = await server.playlists.getPrivacies()
expect(playlistPrivacies[1]).to.exist
expect(playlistPrivacies[2]).to.exist
@@ -70,29 +70,29 @@ describe('Test plugin altering video constants', function () {
it('Should not be able to create a video with this privacy', async function () {
const attributes = { name: 'video', privacy: 2 }
await server.videosCommand.upload({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.videos.upload({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not be able to create a video with this privacy', async function () {
const attributes = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE }
await server.playlistsCommand.create({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await server.playlists.create({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should be able to upload a video with these values', async function () {
const attributes = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' }
const { uuid } = await server.videosCommand.upload({ attributes })
const { uuid } = await server.videos.upload({ attributes })
const video = await server.videosCommand.get({ id: uuid })
const video = await server.videos.get({ id: uuid })
expect(video.language.label).to.equal('Al Bhed 2')
expect(video.licence.label).to.equal('Best licence')
expect(video.category.label).to.equal('Best category')
})
it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () {
await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-video-constants' })
await server.plugins.uninstall({ npmName: 'peertube-plugin-test-video-constants' })
{
const languages = await server.videosCommand.getLanguages()
const languages = await server.videos.getLanguages()
expect(languages['en']).to.equal('English')
expect(languages['fr']).to.equal('French')
@@ -103,7 +103,7 @@ describe('Test plugin altering video constants', function () {
}
{
const categories = await server.videosCommand.getCategories()
const categories = await server.videos.getCategories()
expect(categories[1]).to.equal('Music')
expect(categories[2]).to.equal('Films')
@@ -113,7 +113,7 @@ describe('Test plugin altering video constants', function () {
}
{
const licences = await server.videosCommand.getLicences()
const licences = await server.videos.getLicences()
expect(licences[1]).to.equal('Attribution')
expect(licences[7]).to.equal('Public Domain Dedication')
@@ -123,7 +123,7 @@ describe('Test plugin altering video constants', function () {
}
{
const privacies = await server.videosCommand.getPrivacies()
const privacies = await server.videos.getPrivacies()
expect(privacies[1]).to.exist
expect(privacies[2]).to.exist
@@ -132,7 +132,7 @@ describe('Test plugin altering video constants', function () {
}
{
const playlistPrivacies = await server.playlistsCommand.getPrivacies()
const playlistPrivacies = await server.playlists.getPrivacies()
expect(playlistPrivacies[1]).to.exist
expect(playlistPrivacies[2]).to.exist