}
for (let i = 0; i < 10; i++) {
- await server.videosCommand.upload({ attributes: { ...attributes, name: 'my super video ' + i } })
+ await server.videos.upload({ attributes: { ...attributes, name: 'my super video ' + i } })
}
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
video = data.find(v => v.name === 'my super video 1')
for (let i = 0; i < 10; i++) {
const text = 'my super first comment'
- const created = await server.commentsCommand.createThread({ videoId: video.id, text })
+ const created = await server.comments.createThread({ videoId: video.id, text })
threadId = created.id
const text1 = 'my super answer to thread 1'
- const child = await server.commentsCommand.addReply({ videoId: video.id, toCommentId: threadId, text: text1 })
+ const child = await server.comments.addReply({ videoId: video.id, toCommentId: threadId, text: text1 })
const text2 = 'my super answer to answer of thread 1'
- await server.commentsCommand.addReply({ videoId: video.id, toCommentId: child.id, text: text2 })
+ await server.comments.addReply({ videoId: video.id, toCommentId: child.id, text: text2 })
const text3 = 'my second answer to thread 1'
- await server.commentsCommand.addReply({ videoId: video.id, toCommentId: threadId, text: text3 })
+ await server.comments.addReply({ videoId: video.id, toCommentId: threadId, text: text3 })
}
for (const caption of [ 'ar', 'fr', 'en', 'zh' ]) {
- await server.captionsCommand.createVideoCaption({
+ await server.captions.createVideoCaption({
language: caption,
videoId: video.id,
fixture: 'subtitle-good2.vtt'
// Create 1 comment per video
// Update 1 remote URL and 1 local URL on
- videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'server 1' })).uuid
- videoUUID2 = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid
- videoUUID3 = (await servers[2].videosCommand.quickUpload({ name: 'server 3' })).uuid
+ videoUUID1 = (await servers[0].videos.quickUpload({ name: 'server 1' })).uuid
+ videoUUID2 = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid
+ videoUUID3 = (await servers[2].videos.quickUpload({ name: 'server 3' })).uuid
videoUUIDs = [ videoUUID1, videoUUID2, videoUUID3 ]
for (const server of servers) {
for (const uuid of videoUUIDs) {
- await server.videosCommand.rate({ id: uuid, rating: 'like' })
- await server.commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ await server.videos.rate({ id: uuid, rating: 'like' })
+ await server.comments.createThread({ videoId: uuid, text: 'comment' })
}
}
it('Should have the correct likes', async function () {
for (const server of servers) {
for (const uuid of videoUUIDs) {
- const video = await server.videosCommand.get({ id: uuid })
+ const video = await server.videos.get({ id: uuid })
expect(video.likes).to.equal(3)
expect(video.dislikes).to.equal(0)
it('Should destroy server 3 internal likes and correctly clean them', async function () {
this.timeout(20000)
- await servers[2].sqlCommand.deleteAll('accountVideoRate')
+ await servers[2].sql.deleteAll('accountVideoRate')
for (const uuid of videoUUIDs) {
- await servers[2].sqlCommand.setVideoField(uuid, 'likes', '0')
+ await servers[2].sql.setVideoField(uuid, 'likes', '0')
}
await wait(5000)
// Updated rates of my video
{
- const video = await servers[0].videosCommand.get({ id: videoUUID1 })
+ const video = await servers[0].videos.get({ id: videoUUID1 })
expect(video.likes).to.equal(2)
expect(video.dislikes).to.equal(0)
}
// Did not update rates of a remote video
{
- const video = await servers[0].videosCommand.get({ id: videoUUID2 })
+ const video = await servers[0].videos.get({ id: videoUUID2 })
expect(video.likes).to.equal(3)
expect(video.dislikes).to.equal(0)
}
for (const server of servers) {
for (const uuid of videoUUIDs) {
- await server.videosCommand.rate({ id: uuid, rating: 'dislike' })
+ await server.videos.rate({ id: uuid, rating: 'dislike' })
}
}
for (const server of servers) {
for (const uuid of videoUUIDs) {
- const video = await server.videosCommand.get({ id: uuid })
+ const video = await server.videos.get({ id: uuid })
expect(video.likes).to.equal(0)
expect(video.dislikes).to.equal(3)
}
it('Should destroy server 3 internal dislikes and correctly clean them', async function () {
this.timeout(20000)
- await servers[2].sqlCommand.deleteAll('accountVideoRate')
+ await servers[2].sql.deleteAll('accountVideoRate')
for (const uuid of videoUUIDs) {
- await servers[2].sqlCommand.setVideoField(uuid, 'dislikes', '0')
+ await servers[2].sql.setVideoField(uuid, 'dislikes', '0')
}
await wait(5000)
// Updated rates of my video
{
- const video = await servers[0].videosCommand.get({ id: videoUUID1 })
+ const video = await servers[0].videos.get({ id: videoUUID1 })
expect(video.likes).to.equal(0)
expect(video.dislikes).to.equal(2)
}
// Did not update rates of a remote video
{
- const video = await servers[0].videosCommand.get({ id: videoUUID2 })
+ const video = await servers[0].videos.get({ id: videoUUID2 })
expect(video.likes).to.equal(0)
expect(video.dislikes).to.equal(3)
}
it('Should destroy server 3 internal shares and correctly clean them', async function () {
this.timeout(20000)
- const preCount = await servers[0].sqlCommand.getCount('videoShare')
+ const preCount = await servers[0].sql.getCount('videoShare')
expect(preCount).to.equal(6)
- await servers[2].sqlCommand.deleteAll('videoShare')
+ await servers[2].sql.deleteAll('videoShare')
await wait(5000)
await waitJobs(servers)
// Still 6 because we don't have remote shares on local videos
- const postCount = await servers[0].sqlCommand.getCount('videoShare')
+ const postCount = await servers[0].sql.getCount('videoShare')
expect(postCount).to.equal(6)
})
this.timeout(20000)
{
- const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 })
+ const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 })
expect(total).to.equal(3)
}
- await servers[2].sqlCommand.deleteAll('videoComment')
+ await servers[2].sql.deleteAll('videoComment')
await wait(5000)
await waitJobs(servers)
{
- const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 })
+ const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 })
expect(total).to.equal(2)
}
})
async function check (like: string, ofServerUrl: string, urlSuffix: string, remote: 'true' | 'false') {
const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` +
`INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'`
- const res = await servers[0].sqlCommand.selectQuery(query)
+ const res = await servers[0].sql.selectQuery(query)
for (const rate of res) {
const matcher = new RegExp(`^${ofServerUrl}/accounts/root/dislikes/\\d+${urlSuffix}$`)
{
const query = `UPDATE "accountVideoRate" SET url = url || 'stan'`
- await servers[1].sqlCommand.updateQuery(query)
+ await servers[1].sql.updateQuery(query)
await wait(5000)
await waitJobs(servers)
const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` +
`INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'`
- const res = await servers[0].sqlCommand.selectQuery(query)
+ const res = await servers[0].sql.selectQuery(query)
for (const comment of res) {
const matcher = new RegExp(`${ofServerUrl}/videos/watch/${comment.videoUUID}/comments/\\d+${urlSuffix}`)
{
const query = `UPDATE "videoComment" SET url = url || 'kyle'`
- await servers[1].sqlCommand.updateQuery(query)
+ await servers[1].sql.updateQuery(query)
await wait(5000)
await waitJobs(servers)
await setDefaultVideoChannel(servers)
{
- video = await await servers[0].videosCommand.quickUpload({ name: 'video' })
+ video = await await servers[0].videos.quickUpload({ name: 'video' })
}
{
- const attributes = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].videoChannel.id }
- playlist = await servers[0].playlistsCommand.create({ attributes })
+ const attributes = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].store.channel.id }
+ playlist = await servers[0].playlists.create({ attributes })
}
await doubleFollow(servers[0], servers[1])
const user = { username: 'user1', password: 'password' }
for (const server of servers) {
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
}
- const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ const userAccessToken = await servers[0].login.getAccessToken(user)
- await servers[0].videosCommand.upload({ attributes: { name: 'video root' } })
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'bad video root' } })
- await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'video user' } })
+ await servers[0].videos.upload({ attributes: { name: 'video root' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'bad video root' } })
+ await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } })
{
const to = 'http://localhost:' + servers[0].port + '/accounts/user1'
const value = 'http://localhost:' + servers[1].port + '/accounts/user1'
- await servers[0].sqlCommand.setActorField(to, 'url', value)
+ await servers[0].sql.setActorField(to, 'url', value)
}
{
const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid
- await servers[0].sqlCommand.setVideoField(uuid, 'url', value)
+ await servers[0].sql.setVideoField(uuid, 'url', value)
}
})
await waitJobs(servers)
{
- const { total, data } = await servers[0].videosCommand.list({ sort: 'createdAt' })
+ const { total, data } = await servers[0].videos.list({ sort: 'createdAt' })
expect(total).to.equal(3)
expect(data[0].name).to.equal('video root')
}
{
- const { total, data } = await servers[1].videosCommand.list({ sort: 'createdAt' })
+ const { total, data } = await servers[1].videos.list({ sort: 'createdAt' })
expect(total).to.equal(1)
expect(data[0].name).to.equal('video root')
await setDefaultVideoChannel(servers)
{
- videoUUID1 = (await servers[1].videosCommand.quickUpload({ name: 'video1' })).uuid
- videoUUID2 = (await servers[1].videosCommand.quickUpload({ name: 'video2' })).uuid
- videoUUID3 = (await servers[1].videosCommand.quickUpload({ name: 'video3' })).uuid
+ videoUUID1 = (await servers[1].videos.quickUpload({ name: 'video1' })).uuid
+ videoUUID2 = (await servers[1].videos.quickUpload({ name: 'video2' })).uuid
+ videoUUID3 = (await servers[1].videos.quickUpload({ name: 'video3' })).uuid
}
{
- const token1 = await servers[1].usersCommand.generateUserAndToken('user1')
- await servers[1].videosCommand.upload({ token: token1, attributes: { name: 'video4' } })
+ const token1 = await servers[1].users.generateUserAndToken('user1')
+ await servers[1].videos.upload({ token: token1, attributes: { name: 'video4' } })
- const token2 = await servers[1].usersCommand.generateUserAndToken('user2')
- await servers[1].videosCommand.upload({ token: token2, attributes: { name: 'video5' } })
+ const token2 = await servers[1].users.generateUserAndToken('user2')
+ await servers[1].videos.upload({ token: token2, attributes: { name: 'video5' } })
}
{
- const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
- const created = await servers[1].playlistsCommand.create({ attributes })
+ const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id }
+ const created = await servers[1].playlists.create({ attributes })
playlistUUID1 = created.uuid
}
{
- const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
- const created = await servers[1].playlistsCommand.create({ attributes })
+ const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id }
+ const created = await servers[1].playlists.create({ attributes })
playlistUUID2 = created.uuid
}
await wait(10000)
// Change UUID so the remote server returns a 404
- await servers[1].sqlCommand.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
+ await servers[1].sql.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
- await servers[0].videosCommand.get({ id: videoUUID1 })
- await servers[0].videosCommand.get({ id: videoUUID2 })
+ await servers[0].videos.get({ id: videoUUID1 })
+ await servers[0].videos.get({ id: videoUUID2 })
await waitJobs(servers)
- await servers[0].videosCommand.get({ id: videoUUID1, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
- await servers[0].videosCommand.get({ id: videoUUID2 })
+ await servers[0].videos.get({ id: videoUUID1, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[0].videos.get({ id: videoUUID2 })
})
it('Should not update a remote video if the remote instance is down', async function () {
await killallServers([ servers[1] ])
- await servers[1].sqlCommand.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
+ await servers[1].sql.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
// Video will need a refresh
await wait(10000)
- await servers[0].videosCommand.get({ id: videoUUID3 })
+ await servers[0].videos.get({ id: videoUUID3 })
// The refresh should fail
await waitJobs([ servers[0] ])
await reRunServer(servers[1])
- await servers[0].videosCommand.get({ id: videoUUID3 })
+ await servers[0].videos.get({ id: videoUUID3 })
})
})
it('Should remove a deleted actor', async function () {
this.timeout(60000)
- const command = servers[0].accountsCommand
+ const command = servers[0].accounts
await wait(10000)
// Change actor name so the remote server returns a 404
const to = 'http://localhost:' + servers[1].port + '/accounts/user2'
- await servers[1].sqlCommand.setActorField(to, 'preferredUsername', 'toto')
+ await servers[1].sql.setActorField(to, 'preferredUsername', 'toto')
await command.get({ accountName: 'user1@localhost:' + servers[1].port })
await command.get({ accountName: 'user2@localhost:' + servers[1].port })
await wait(10000)
// Change UUID so the remote server returns a 404
- await servers[1].sqlCommand.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
+ await servers[1].sql.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
- await servers[0].playlistsCommand.get({ playlistId: playlistUUID1 })
- await servers[0].playlistsCommand.get({ playlistId: playlistUUID2 })
+ await servers[0].playlists.get({ playlistId: playlistUUID1 })
+ await servers[0].playlists.get({ playlistId: playlistUUID2 })
await waitJobs(servers)
- await servers[0].playlistsCommand.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 })
- await servers[0].playlistsCommand.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[0].playlists.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 })
+ await servers[0].playlists.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
})
const url = 'http://localhost:' + ofServer.port + '/accounts/peertube'
return Promise.all([
- onServer.sqlCommand.setActorField(url, 'publicKey', publicKey),
- onServer.sqlCommand.setActorField(url, 'privateKey', privateKey)
+ onServer.sql.setActorField(url, 'publicKey', publicKey),
+ onServer.sql.setActorField(url, 'privateKey', privateKey)
])
}
const url = 'http://localhost:' + ofServer.port + '/accounts/peertube'
return Promise.all([
- onServer.sqlCommand.setActorField(url, 'createdAt', updatedAt),
- onServer.sqlCommand.setActorField(url, 'updatedAt', updatedAt)
+ onServer.sql.setActorField(url, 'createdAt', updatedAt),
+ onServer.sql.setActorField(url, 'updatedAt', updatedAt)
])
}
await setAccessTokensToServers([ server ])
- userToken = await server.usersCommand.generateUserAndToken('user_1')
- userToken2 = await server.usersCommand.generateUserAndToken('user_2')
+ userToken = await server.users.generateUserAndToken('user_1')
+ userToken2 = await server.users.generateUserAndToken('user_2')
- server.video = await server.videosCommand.upload()
+ server.store.video = await server.videos.upload()
- command = server.abusesCommand
+ command = server.abuses
})
describe('When listing abuses for admins', function () {
})
it('Should fail with a non authenticated user', async function () {
- const fields = { video: { id: server.video.id }, reason: 'my super reason' }
+ const fields = { video: { id: server.store.video.id }, reason: 'my super reason' }
await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a reason too short', async function () {
- const fields = { video: { id: server.video.id }, reason: 'h' }
+ const fields = { video: { id: server.store.video.id }, reason: 'h' }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
it('Should fail with a too big reason', async function () {
- const fields = { video: { id: server.video.id }, reason: 'super'.repeat(605) }
+ const fields = { video: { id: server.store.video.id }, reason: 'super'.repeat(605) }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
it('Should succeed with the correct parameters (basic)', async function () {
- const fields: AbuseCreate = { video: { id: server.video.shortUUID }, reason: 'my super reason' }
+ const fields: AbuseCreate = { video: { id: server.store.video.shortUUID }, reason: 'my super reason' }
const res = await makePostBodyRequest({
url: server.url,
})
it('Should fail with a wrong predefined reason', async function () {
- const fields = { video: { id: server.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] }
+ const fields = { video: { id: server.store.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
it('Should fail with negative timestamps', async function () {
- const fields = { video: { id: server.video.id, startAt: -1 }, reason: 'my super reason' }
+ const fields = { video: { id: server.store.video.id, startAt: -1 }, reason: 'my super reason' }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
it('Should fail mith misordered startAt/endAt', async function () {
- const fields = { video: { id: server.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' }
+ const fields = { video: { id: server.store.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
it('Should succeed with the corret parameters (advanced)', async function () {
const fields: AbuseCreate = {
video: {
- id: server.video.id,
+ id: server.store.video.id,
startAt: 1,
endAt: 5
},
await doubleFollow(anotherServer, server)
- const server2VideoId = await anotherServer.videosCommand.getId({ uuid: server.video.uuid })
- await anotherServer.abusesCommand.report({ reason: 'remote server', videoId: server2VideoId })
+ const server2VideoId = await anotherServer.videos.getId({ uuid: server.store.video.uuid })
+ await anotherServer.abuses.report({ reason: 'remote server', videoId: server2VideoId })
await waitJobs([ server, anotherServer ])
describe('When getting an account', function () {
it('Should return 404 with a non existing name', async function () {
- await server.accountsCommand.get({ accountName: 'arfaze', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.accounts.get({ accountName: 'arfaze', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
})
server = servers[0]
const user = { username: 'user1', password: 'password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ userAccessToken = await server.login.getAccessToken(user)
await doubleFollow(servers[0], servers[1])
})
await setAccessTokensToServers([ server ])
const user = { username: 'user1', password: 'password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When removing comments of', function () {
username: 'user1',
password: 'password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When getting the configuration', function () {
// Email is disabled
server = await flushAndRunServer(1)
- command = server.contactFormCommand
+ command = server.contactForm
})
it('Should not accept a contact form if emails are disabled', async function () {
await setAccessTokensToServers([ server ])
const user = { username: 'user1', password: 'password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When updating instance homepage', function () {
username: 'user1',
password: 'my super password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When getting debug endpoint', function () {
password: 'password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When adding follows', function () {
username: 'user1',
password: 'my super password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When listing jobs', function () {
await setAccessTokensToServers([ server ])
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
const username = 'user1'
const password = 'my super password'
- await server.usersCommand.create({ username: username, password: password })
- userAccessToken = await server.loginCommand.getAccessToken({ username, password })
+ await server.users.create({ username: username, password: password })
+ userAccessToken = await server.login.getAccessToken({ username, password })
{
- const { videoChannels } = await server.usersCommand.getMyInfo()
+ const { videoChannels } = await server.users.getMyInfo()
channelId = videoChannels[0].id
}
{
- videoIdNotLive = (await server.videosCommand.quickUpload({ name: 'not live' })).id
+ videoIdNotLive = (await server.videos.quickUpload({ name: 'not live' })).id
}
- command = server.liveCommand
+ command = server.live
})
describe('When creating a live', function () {
username: 'fake',
password: 'fake_password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- const accessTokenUser = await server.loginCommand.getAccessToken(user)
- const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser })
+ const accessTokenUser = await server.login.getAccessToken(user)
+ const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
const customChannelId = videoChannels[0].id
const fields = { ...baseCorrectParams, channelId: customChannelId }
})
it('Should forbid if live is disabled', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: false
it('Should forbid to save replay if not enabled by the admin', async function () {
const fields = { ...baseCorrectParams, saveReplay: true }
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
it('Should allow to save replay if enabled by the admin', async function () {
const fields = { ...baseCorrectParams, saveReplay: true }
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
})
it('Should not allow live if max instance lives is reached', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
})
it('Should not allow live if max user lives is reached', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
})
it('Should fail to update replay status if replay is not allowed on the instance', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
username: 'user1',
password: 'my super password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When getting logs', function () {
password: 'password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
{
- const res = await server.pluginsCommand.install({ npmName: npmPlugin })
+ const res = await server.plugins.install({ npmName: npmPlugin })
const plugin = res.body as PeerTubePlugin
npmVersion = plugin.version
}
{
- const res = await server.pluginsCommand.install({ npmName: themePlugin })
+ const res = await server.plugins.install({ npmName: themePlugin })
const plugin = res.body as PeerTubePlugin
themeVersion = plugin.version
}
password: 'password'
}
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ await servers[0].users.create({ username: user.username, password: user.password })
+ userAccessToken = await servers[0].login.getAccessToken(user)
- videoIdLocal = (await servers[0].videosCommand.quickUpload({ name: 'video' })).id
+ videoIdLocal = (await servers[0].videos.quickUpload({ name: 'video' })).id
- const remoteUUID = (await servers[1].videosCommand.quickUpload({ name: 'video' })).uuid
+ const remoteUUID = (await servers[1].videos.quickUpload({ name: 'video' })).uuid
await waitJobs(servers)
- videoRemote = await servers[0].videosCommand.get({ id: remoteUUID })
+ videoRemote = await servers[0].videos.get({ id: remoteUUID })
})
describe('When listing redundancies', function () {
} from '@shared/extra-utils'
function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) {
- return server.configCommand.updateCustomSubConfig({
+ return server.config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
- server.video = await server.videosCommand.upload({ attributes: { name: 'my super name' } })
+ server.store.video = await server.videos.upload({ attributes: { name: 'my super name' } })
{
- const created = await server.playlistsCommand.create({
+ const created = await server.playlists.create({
attributes: {
displayName: 'super playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
})
})
it('Should fail with an invalid host', async function () {
- const embedUrl = 'http://hello.com/videos/watch/' + server.video.uuid
+ const embedUrl = 'http://hello.com/videos/watch/' + server.store.video.uuid
await checkParamEmbed(server, embedUrl)
})
})
it('Should fail with an invalid path', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl)
})
it('Should fail with an invalid max height', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' })
})
it('Should fail with an invalid max width', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' })
})
it('Should fail with an invalid format', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' })
})
it('Should fail with a non supported format', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' })
})
it('Should succeed with the correct params with a video', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
const query = {
format: 'json',
maxheight: 400,
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
- const user = await server.usersCommand.getMyInfo()
+ const user = await server.users.getMyInfo()
rootId = user.id
- await server.usersCommand.update({ userId: rootId, videoQuota: 42 })
+ await server.users.update({ userId: rootId, videoQuota: 42 })
- command = server.videosCommand
+ command = server.videos
})
describe('When having a video quota', function () {
this.timeout(30000)
const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
- await server.usersCommand.register(user)
- const userToken = await server.loginCommand.getAccessToken(user)
+ await server.users.register(user)
+ const userToken = await server.login.getAccessToken(user)
const attributes = { fixture: 'video_short2.webm' }
for (let i = 0; i < 5; i++) {
this.timeout(30000)
const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
- await server.usersCommand.register(user)
- const userToken = await server.loginCommand.getAccessToken(user)
+ await server.users.register(user)
+ const userToken = await server.login.getAccessToken(user)
const attributes = { fixture: 'video_short2.webm' }
for (let i = 0; i < 5; i++) {
this.timeout(120000)
const baseAttributes = {
- channelId: server.videoChannel.id,
+ channelId: server.store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
- await server.importsCommand.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } })
- await server.importsCommand.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } })
- await server.importsCommand.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } })
+ await server.imports.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } })
+ await server.imports.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } })
+ await server.imports.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } })
await waitJobs([ server ])
- const { total, data: videoImports } = await server.importsCommand.getMyVideoImports()
+ const { total, data: videoImports } = await server.imports.getMyVideoImports()
expect(total).to.equal(3)
expect(videoImports).to.have.lengthOf(3)
describe('When having a daily video quota', function () {
it('Should fail with a user having too many videos daily', async function () {
- await server.usersCommand.update({ userId: rootId, videoQuotaDaily: 42 })
+ await server.users.update({ userId: rootId, videoQuotaDaily: 42 })
await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' })
await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' })
describe('When having an absolute and daily video quota', function () {
it('Should fail if exceeding total quota', async function () {
- await server.usersCommand.update({
+ await server.users.update({
userId: rootId,
videoQuota: 42,
videoQuotaDaily: 1024 * 1024 * 1024
})
it('Should fail if exceeding daily quota', async function () {
- await server.usersCommand.update({
+ await server.users.update({
userId: rootId,
videoQuota: 1024 * 1024 * 1024,
videoQuotaDaily: 42
username: 'user1',
password: 'my super password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When listing my subscriptions', function () {
{
const user = { username: 'user1' }
- await server.usersCommand.create({ ...user })
- userToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ ...user })
+ userToken = await server.login.getAccessToken(user)
}
{
const moderator = { username: 'moderator1' }
- await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR })
- moderatorToken = await server.loginCommand.getAccessToken(moderator)
+ await server.users.create({ ...moderator, role: UserRole.MODERATOR })
+ moderatorToken = await server.login.getAccessToken(moderator)
}
{
const moderator = { username: 'moderator2' }
- await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR })
+ await server.users.create({ ...moderator, role: UserRole.MODERATOR })
}
{
- video = await server.videosCommand.upload()
+ video = await server.videos.upload()
}
{
- const { data } = await server.usersCommand.list()
+ const { data } = await server.users.list()
userId = data.find(u => u.username === 'user1').id
rootId = data.find(u => u.username === 'root').id
moderatorId = data.find(u => u.username === 'moderator2').id
it('Should fail with a non admin user', async function () {
const user = { username: 'user1' }
- userToken = await server.loginCommand.getAccessToken(user)
+ userToken = await server.login.getAccessToken(user)
const fields = {
username: 'user3',
describe('When managing my scoped tokens', function () {
it('Should fail to get my scoped tokens with an non authenticated user', async function () {
- await server.usersCommand.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail to get my scoped tokens with a bad token', async function () {
- await server.usersCommand.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should succeed to get my scoped tokens', async function () {
- await server.usersCommand.getMyScopedTokens()
+ await server.users.getMyScopedTokens()
})
it('Should fail to renew my scoped tokens with an non authenticated user', async function () {
- await server.usersCommand.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail to renew my scoped tokens with a bad token', async function () {
- await server.usersCommand.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should succeed to renew my scoped tokens', async function () {
- await server.usersCommand.renewMyScopedTokens()
+ await server.users.renewMyScopedTokens()
})
})
describe('When getting my information', function () {
it('Should fail with a non authenticated user', async function () {
- await server.usersCommand.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should success with the correct parameters', async function () {
- await server.usersCommand.getMyInfo({ token: userToken })
+ await server.users.getMyInfo({ token: userToken })
})
})
let command: UsersCommand
before(function () {
- command = server.usersCommand
+ command = server.users
})
it('Should fail with a non authenticated user', async function () {
it('Should fail with an incorrect id', async function () {
const options = { userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.usersCommand.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.users.remove(options)
+ await server.users.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.users.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should fail with the root user', async function () {
const options = { userId: rootId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.remove(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
it('Should return 404 with a non existing id', async function () {
const options = { userId: 4545454, expectedStatus: HttpStatusCode.NOT_FOUND_404 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.remove(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
it('Should fail with a non admin user', async function () {
const options = { userId, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.remove(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
it('Should fail on a moderator with a moderator', async function () {
const options = { userId: moderatorId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.remove(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
it('Should succeed on a user with a moderator', async function () {
const options = { userId, token: moderatorToken }
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
})
describe('When deleting our account', function () {
it('Should fail with with the root account', async function () {
- await server.usersCommand.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.users.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
})
it('Should fail with an existing channel', async function () {
const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
- await server.channelsCommand.create({ attributes })
+ await server.channels.create({ attributes })
const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } }
describe('When registering multiple users on a server with users limit', function () {
it('Should fail when after 3 registrations', async function () {
- await server.usersCommand.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await server.users.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
})
{
const username = 'user1'
const password = 'my super password'
- await servers[0].usersCommand.create({ username: username, password: password })
- userAccessToken1 = await servers[0].loginCommand.getAccessToken({ username, password })
+ await servers[0].users.create({ username: username, password: password })
+ userAccessToken1 = await servers[0].login.getAccessToken({ username, password })
}
{
const username = 'user2'
const password = 'my super password'
- await servers[0].usersCommand.create({ username: username, password: password })
- userAccessToken2 = await servers[0].loginCommand.getAccessToken({ username, password })
+ await servers[0].users.create({ username: username, password: password })
+ userAccessToken2 = await servers[0].login.getAccessToken({ username, password })
}
{
- servers[0].video = await servers[0].videosCommand.upload({ token: userAccessToken1 })
+ servers[0].store.video = await servers[0].videos.upload({ token: userAccessToken1 })
}
{
- const { uuid } = await servers[0].videosCommand.upload()
+ const { uuid } = await servers[0].videos.upload()
notBlacklistedVideoId = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload()
+ const { uuid } = await servers[1].videos.upload()
remoteVideoUUID = uuid
}
await waitJobs(servers)
- command = servers[0].blacklistCommand
+ command = servers[0].blacklist
})
describe('When adding a video in blacklist', function () {
const basePath = '/api/v1/videos/'
it('Should fail with nothing', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
})
})
it('Should fail with a non authenticated user', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePostBodyRequest({
url: servers[0].url,
})
it('Should fail with an invalid reason', async function () {
- const path = basePath + servers[0].video.uuid + '/blacklist'
+ const path = basePath + servers[0].store.video.uuid + '/blacklist'
const fields = { reason: 'a'.repeat(305) }
await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
})
it('Should succeed with the correct params', async function () {
- const path = basePath + servers[0].video.uuid + '/blacklist'
+ const path = basePath + servers[0].store.video.uuid + '/blacklist'
const fields = {}
await makePostBodyRequest({
})
it('Should fail with a non authenticated user', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePutBodyRequest({
url: servers[0].url,
})
it('Should fail with an invalid reason', async function () {
- const path = basePath + servers[0].video.uuid + '/blacklist'
+ const path = basePath + servers[0].store.video.uuid + '/blacklist'
const fields = { reason: 'a'.repeat(305) }
await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
})
it('Should succeed with the correct params', async function () {
- const path = basePath + servers[0].video.shortUUID + '/blacklist'
+ const path = basePath + servers[0].store.video.shortUUID + '/blacklist'
const fields = { reason: 'hello' }
await makePutBodyRequest({
describe('When getting blacklisted video', function () {
it('Should fail with a non authenticated user', async function () {
- await servers[0].videosCommand.get({ id: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[0].videos.get({ id: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with another user', async function () {
- await servers[0].videosCommand.getWithToken({
+ await servers[0].videos.getWithToken({
token: userAccessToken2,
- id: servers[0].video.uuid,
+ id: servers[0].store.video.uuid,
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
it('Should succeed with the owner authenticated user', async function () {
- const video = await servers[0].videosCommand.getWithToken({ token: userAccessToken1, id: servers[0].video.uuid })
+ const video = await servers[0].videos.getWithToken({ token: userAccessToken1, id: servers[0].store.video.uuid })
expect(video.blacklisted).to.be.true
})
it('Should succeed with an admin', async function () {
- const video = servers[0].video
+ const video = servers[0].store.video
for (const id of [ video.id, video.uuid, video.shortUUID ]) {
- const video = await servers[0].videosCommand.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 })
+ const video = await servers[0].videos.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 })
expect(video.blacklisted).to.be.true
}
})
describe('When removing a video in blacklist', function () {
it('Should fail with a non authenticated user', async function () {
- await command.remove({ token: 'fake token', videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await command.remove({ token: 'fake token', videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
- await command.remove({ token: userAccessToken2, videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await command.remove({ token: userAccessToken2, videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with an incorrect id', async function () {
})
it('Should succeed with the correct params', async function () {
- await command.remove({ videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
+ await command.remove({ videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
})
})
const basePath = '/api/v1/videos/blacklist/'
it('Should fail with a non authenticated user', async function () {
- await servers[0].blacklistCommand.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[0].blacklist.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
- await servers[0].blacklistCommand.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].blacklist.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with a bad start pagination', async function () {
})
it('Should fail with an invalid type', async function () {
- await servers[0].blacklistCommand.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await servers[0].blacklist.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should succeed with the correct parameters', async function () {
- await servers[0].blacklistCommand.list({ type: VideoBlacklistType.MANUAL })
+ await servers[0].blacklist.list({ type: VideoBlacklistType.MANUAL })
})
})
await setAccessTokensToServers([ server ])
- video = await server.videosCommand.upload()
+ video = await server.videos.upload()
{
const user = {
username: 'user1',
password: 'my super password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
}
})
// })
it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () {
- await server.captionsCommand.createVideoCaption({
+ await server.captions.createVideoCaption({
language: 'zh',
videoId: video.uuid,
fixture: 'subtitle-good.srt',
}
{
- await server.usersCommand.create({ username: user.username, password: user.password })
- accessTokenUser = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ accessTokenUser = await server.login.getAccessToken(user)
}
- command = server.channelsCommand
+ command = server.channels
})
describe('When listing a video channels', function () {
})
it('Should fail with a unknown account', async function () {
- await server.channelsCommand.listByAccount({ accountName: 'unknown', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.channels.listByAccount({ accountName: 'unknown', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Should succeed with the correct parameters', async function () {
await setAccessTokensToServers([ server ])
{
- const video = await server.videosCommand.upload({ attributes: {} })
+ const video = await server.videos.upload({ attributes: {} })
pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
}
{
- const created = await server.commentsCommand.createThread({ videoId: video.uuid, text: 'coucou' })
+ const created = await server.comments.createThread({ videoId: video.uuid, text: 'coucou' })
commentId = created.id
pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId
}
{
const user = { username: 'user1', password: 'my super password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
}
{
const user = { username: 'user2', password: 'my super password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken2 = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken2 = await server.login.getAccessToken(user)
}
})
let commentToDelete: number
{
- const created = await server.commentsCommand.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' })
+ const created = await server.comments.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' })
commentToDelete = created.id
}
let anotherVideoUUID: string
{
- const { uuid } = await server.videosCommand.upload({ token: userAccessToken, attributes: { name: 'video' } })
+ const { uuid } = await server.videos.upload({ token: userAccessToken, attributes: { name: 'video' } })
anotherVideoUUID = uuid
}
{
- const created = await server.commentsCommand.createThread({ videoId: anotherVideoUUID, text: 'hello' })
+ const created = await server.comments.createThread({ videoId: anotherVideoUUID, text: 'hello' })
commentToDelete = created.id
}
describe('When a video has comments disabled', function () {
before(async function () {
- video = await server.videosCommand.upload({ attributes: { commentsEnabled: false } })
+ video = await server.videos.upload({ attributes: { commentsEnabled: false } })
pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
})
const username = 'user1'
const password = 'my super password'
- await server.usersCommand.create({ username: username, password: password })
- userAccessToken = await server.loginCommand.getAccessToken({ username, password })
+ await server.users.create({ username: username, password: password })
+ userAccessToken = await server.login.getAccessToken({ username, password })
{
- const { videoChannels } = await server.usersCommand.getMyInfo()
+ const { videoChannels } = await server.users.getMyInfo()
channelId = videoChannels[0].id
}
})
username: 'fake',
password: 'fake_password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- const accessTokenUser = await server.loginCommand.getAccessToken(user)
- const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser })
+ const accessTokenUser = await server.login.getAccessToken(user)
+ const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
const customChannelId = videoChannels[0].id
const fields = { ...baseCorrectParams, channelId: customChannelId }
})
it('Should forbid to import http videos', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
import: {
videos: {
})
it('Should forbid to import torrent videos', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
import: {
videos: {
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
- userAccessToken = await server.usersCommand.generateUserAndToken('user1')
- videoId = (await server.videosCommand.quickUpload({ name: 'video 1' })).id
+ userAccessToken = await server.users.generateUserAndToken('user1')
+ videoId = (await server.videos.quickUpload({ name: 'video 1' })).id
- command = server.playlistsCommand
+ command = server.playlists
{
const { data } = await command.listByAccount({
attributes: {
displayName: 'super playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
})
}
const playlist = await command.create({
attributes: {
displayName: 'super playlist',
- videoChannelId: server.videoChannel.id,
+ videoChannelId: server.store.channel.id,
privacy: VideoPlaylistPrivacy.UNLISTED
}
})
displayName: 'display name',
privacy: VideoPlaylistPrivacy.UNLISTED,
thumbnailfile: 'thumbnail.jpg',
- videoChannelId: server.videoChannel.id,
+ videoChannelId: server.store.channel.id,
...attributes
},
}
before(async function () {
- videoId3 = (await server.videosCommand.quickUpload({ name: 'video 3' })).id
- videoId4 = (await server.videosCommand.quickUpload({ name: 'video 4' })).id
+ videoId3 = (await server.videos.quickUpload({ name: 'video 3' })).id
+ videoId4 = (await server.videos.quickUpload({ name: 'video 4' })).id
for (const id of [ videoId3, videoId4 ]) {
await command.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: id } })
await setDefaultVideoChannel([ server ])
const user = { username: 'user1', password: 'my super password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
const moderator = { username: 'moderator', password: 'my super password' }
- await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
+ await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
- moderatorAccessToken = await server.loginCommand.getAccessToken(moderator)
+ moderatorAccessToken = await server.login.getAccessToken(moderator)
})
describe('When setting a video filter', function () {
await setAccessTokensToServers([ server ])
- const { uuid } = await server.videosCommand.upload()
+ const { uuid } = await server.videos.upload()
watchingPath = '/api/v1/videos/' + uuid + '/watching'
})
describe('When getting videos overview', function () {
it('Should fail with a bad pagination', async function () {
- await server.overviewsCommand.getVideos({ page: 0, expectedStatus: 400 })
- await server.overviewsCommand.getVideos({ page: 100, expectedStatus: 400 })
+ await server.overviews.getVideos({ page: 0, expectedStatus: 400 })
+ await server.overviews.getVideos({ page: 100, expectedStatus: 400 })
})
it('Should succeed with a good pagination', async function () {
- await server.overviewsCommand.getVideos({ page: 1 })
+ await server.overviews.getVideos({ page: 1 })
})
})
const username = 'user1'
const password = 'my super password'
- await server.usersCommand.create({ username: username, password: password })
- userAccessToken = await server.loginCommand.getAccessToken({ username, password })
+ await server.users.create({ username: username, password: password })
+ userAccessToken = await server.login.getAccessToken({ username, password })
{
- const body = await server.usersCommand.getMyInfo()
+ const body = await server.users.getMyInfo()
channelId = body.videoChannels[0].id
channelName = body.videoChannels[0].name
accountName = body.account.name + '@' + body.account.host
username: 'fake' + randomInt(0, 1500),
password: 'fake_password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- const accessTokenUser = await server.loginCommand.getAccessToken(user)
- const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser })
+ const accessTokenUser = await server.login.getAccessToken(user)
+ const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
const customChannelId = videoChannels[0].id
const fields = { ...baseCorrectParams, channelId: customChannelId }
}
before(async function () {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
video = data[0]
})
})
it('Should fail without a correct uuid', async function () {
- await server.videosCommand.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.videos.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should return 404 with an incorrect video', async function () {
- await server.videosCommand.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Shoud report the appropriate error', async function () {
- const body = await server.videosCommand.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const error = body as unknown as PeerTubeProblemDocument
expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo')
})
it('Should succeed with the correct parameters', async function () {
- await server.videosCommand.get({ id: video.shortUUID })
+ await server.videos.get({ id: video.shortUUID })
})
})
let videoId: number
before(async function () {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
videoId = data[0].id
})
})
it('Should fail without a correct uuid', async function () {
- await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should fail with a video which does not exist', async function () {
- await server.videosCommand.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Should fail with a video of another user without the appropriate right', async function () {
- await server.videosCommand.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with a video of another server')
it('Shoud report the appropriate error', async function () {
- const body = await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const error = body as unknown as PeerTubeProblemDocument
expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
})
it('Should succeed with the correct parameters', async function () {
- await server.videosCommand.remove({ id: video.uuid })
+ await server.videos.remove({ id: video.uuid })
})
})
saveReplay
}
- const { uuid } = await servers[0].liveCommand.create({ token: userAccessToken, fields: liveAttributes })
+ const { uuid } = await servers[0].live.create({ token: userAccessToken, fields: liveAttributes })
return uuid
}
async function checkSaveReplay (videoId: string, resolutions = [ 720 ]) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.isLive).to.be.false
expect(video.duration).to.be.greaterThan(0)
}
async function waitUntilLivePublishedOnAllServers (videoId: string) {
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId })
+ await server.live.waitUntilPublished({ videoId })
}
}
function updateQuota (options: { total: number, daily: number }) {
- return servers[0].usersCommand.update({
+ return servers[0].users.update({
userId,
videoQuota: options.total,
videoQuotaDaily: options.daily
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
})
{
- const res = await servers[0].usersCommand.generate('user1')
+ const res = await servers[0].users.generate('user1')
userId = res.userId
userChannelId = res.userChannelId
userAccessToken = res.token
this.timeout(60000)
const userVideoLiveoId = await createLiveWrapper(false)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
})
it('Should have size limit depending on user global quota if save replay is enabled', async function () {
await wait(5000)
const userVideoLiveoId = await createLiveWrapper(true)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
await waitJobs(servers)
await updateQuota({ total: -1, daily: 1 })
const userVideoLiveoId = await createLiveWrapper(true)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
await waitJobs(servers)
await updateQuota({ total: 10 * 1000 * 1000, daily: -1 })
const userVideoLiveoId = await createLiveWrapper(true)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
})
it('Should have max duration limit', async function () {
this.timeout(60000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
})
const userVideoLiveoId = await createLiveWrapper(true)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
await waitJobs(servers)
async function createLiveWrapper (permanentLive: boolean) {
const attributes: LiveVideoCreate = {
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
name: 'my super live',
saveReplay: false,
permanentLive
}
- const { uuid } = await servers[0].liveCommand.create({ fields: attributes })
+ const { uuid } = await servers[0].live.create({ fields: attributes })
return uuid
}
async function checkVideoState (videoId: string, state: VideoState) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.state.id).to.equal(state)
}
}
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
const videoUUID = await createLiveWrapper(false)
{
- const live = await servers[0].liveCommand.get({ videoId: videoUUID })
+ const live = await servers[0].live.get({ videoId: videoUUID })
expect(live.permanentLive).to.be.false
}
- await servers[0].liveCommand.update({ videoId: videoUUID, fields: { permanentLive: true } })
+ await servers[0].live.update({ videoId: videoUUID, fields: { permanentLive: true } })
{
- const live = await servers[0].liveCommand.get({ videoId: videoUUID })
+ const live = await servers[0].live.get({ videoId: videoUUID })
expect(live.permanentLive).to.be.true
}
})
videoUUID = await createLiveWrapper(true)
- const live = await servers[0].liveCommand.get({ videoId: videoUUID })
+ const live = await servers[0].live.get({ videoId: videoUUID })
expect(live.permanentLive).to.be.true
await waitJobs(servers)
it('Should stream into this permanent live', async function () {
this.timeout(120000)
- const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID })
+ const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID })
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId: videoUUID })
+ await server.live.waitUntilPublished({ videoId: videoUUID })
}
await checkVideoState(videoUUID, VideoState.PUBLISHED)
await stopFfmpeg(ffmpegCommand)
- await servers[0].liveCommand.waitUntilWaiting({ videoId: videoUUID })
+ await servers[0].live.waitUntilWaiting({ videoId: videoUUID })
await waitJobs(servers)
})
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videoUUID })
+ const videoDetails = await server.videos.get({ id: videoUUID })
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
}
})
it('Should be able to stream again in the permanent live', async function () {
this.timeout(20000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
}
})
- const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID })
+ const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID })
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId: videoUUID })
+ await server.live.waitUntilPublished({ videoId: videoUUID })
}
await checkVideoState(videoUUID, VideoState.PUBLISHED)
- const count = await servers[0].liveCommand.countPlaylists({ videoUUID })
+ const count = await servers[0].live.countPlaylists({ videoUUID })
// master playlist and 720p playlist
expect(count).to.equal(2)
async function createLiveWrapper (saveReplay: boolean) {
if (liveVideoUUID) {
try {
- await servers[0].videosCommand.remove({ id: liveVideoUUID })
+ await servers[0].videos.remove({ id: liveVideoUUID })
await waitJobs(servers)
} catch {}
}
const attributes: LiveVideoCreate = {
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
name: 'my super live',
saveReplay
}
- const { uuid } = await servers[0].liveCommand.create({ fields: attributes })
+ const { uuid } = await servers[0].live.create({ fields: attributes })
return uuid
}
for (const server of servers) {
const length = existsInList ? 1 : 0
- const { data, total } = await server.videosCommand.list()
+ const { data, total } = await server.videos.list()
expect(data).to.have.lengthOf(length)
expect(total).to.equal(length)
if (expectedStatus) {
- await server.videosCommand.get({ id: videoId, expectedStatus })
+ await server.videos.get({ id: videoId, expectedStatus })
}
}
}
async function checkVideoState (videoId: string, state: VideoState) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.state.id).to.equal(state)
}
}
async function waitUntilLivePublishedOnAllServers (videoId: string) {
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId })
+ await server.live.waitUntilPublished({ videoId })
}
}
async function waitUntilLiveSavedOnAllServers (videoId: string) {
for (const server of servers) {
- await server.liveCommand.waitUntilSaved({ videoId })
+ await server.live.waitUntilSaved({ videoId })
}
}
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
it('Should correctly have updated the live and federated it when streaming in the live', async function () {
this.timeout(30000)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await stopFfmpeg(ffmpegCommand)
for (const server of servers) {
- await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID })
+ await server.live.waitUntilEnded({ videoId: liveVideoUUID })
}
await waitJobs(servers)
liveVideoUUID = await createLiveWrapper(false)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await Promise.all([
- servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
+ servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
testFfmpegStreamError(ffmpegCommand, true)
])
await checkVideosExist(liveVideoUUID, false)
- await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
await wait(5000)
await waitJobs(servers)
liveVideoUUID = await createLiveWrapper(false)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await Promise.all([
testFfmpegStreamError(ffmpegCommand, true),
- servers[0].videosCommand.remove({ id: liveVideoUUID })
+ servers[0].videos.remove({ id: liveVideoUUID })
])
await wait(5000)
it('Should correctly have updated the live and federated it when streaming in the live', async function () {
this.timeout(20000)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
it('Should update the saved live and correctly federate the updated attributes', async function () {
this.timeout(30000)
- await servers[0].videosCommand.update({ id: liveVideoUUID, attributes: { name: 'video updated' } })
+ await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated' } })
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: liveVideoUUID })
+ const video = await server.videos.get({ id: liveVideoUUID })
expect(video.name).to.equal('video updated')
expect(video.isLive).to.be.false
}
liveVideoUUID = await createLiveWrapper(true)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await Promise.all([
- servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
+ servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
testFfmpegStreamError(ffmpegCommand, true)
])
await checkVideosExist(liveVideoUUID, false)
- await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
await wait(5000)
await waitJobs(servers)
liveVideoUUID = await createLiveWrapper(true)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await Promise.all([
- servers[0].videosCommand.remove({ id: liveVideoUUID }),
+ servers[0].videos.remove({ id: liveVideoUUID }),
testFfmpegStreamError(ffmpegCommand, true)
])
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
async function createLiveWrapper () {
const liveAttributes = {
name: 'live video',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
- const { uuid } = await servers[0].liveCommand.create({ fields: liveAttributes })
+ const { uuid } = await servers[0].live.create({ fields: liveAttributes })
return uuid
}
await waitJobs(servers)
{
- const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID })
- const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket()
+ const localSocket = servers[0].socketIO.getLiveNotificationSocket()
localSocket.on('state-change', data => localStateChanges.push(data.state))
localSocket.emit('subscribe', { videoId })
}
{
- const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[1].videos.getId({ uuid: liveVideoUUID })
- const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket()
+ const remoteSocket = servers[1].socketIO.getLiveNotificationSocket()
remoteSocket.on('state-change', data => remoteStateChanges.push(data.state))
remoteSocket.emit('subscribe', { videoId })
}
- const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
await stopFfmpeg(ffmpegCommand)
for (const server of servers) {
- await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID })
+ await server.live.waitUntilEnded({ videoId: liveVideoUUID })
}
await waitJobs(servers)
await waitJobs(servers)
{
- const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID })
- const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket()
+ const localSocket = servers[0].socketIO.getLiveNotificationSocket()
localSocket.on('views-change', data => { localLastVideoViews = data.views })
localSocket.emit('subscribe', { videoId })
}
{
- const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[1].videos.getId({ uuid: liveVideoUUID })
- const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket()
+ const remoteSocket = servers[1].socketIO.getLiveNotificationSocket()
remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views })
remoteSocket.emit('subscribe', { videoId })
}
- const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
expect(localLastVideoViews).to.equal(0)
expect(remoteLastVideoViews).to.equal(0)
- await servers[0].videosCommand.view({ id: liveVideoUUID })
- await servers[1].videosCommand.view({ id: liveVideoUUID })
+ await servers[0].videos.view({ id: liveVideoUUID })
+ await servers[1].videos.view({ id: liveVideoUUID })
await waitJobs(servers)
await wait(5000)
const liveVideoUUID = await createLiveWrapper()
await waitJobs(servers)
- const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID })
- const socket = servers[0].socketIOCommand.getLiveNotificationSocket()
+ const socket = servers[0].socketIO.getLiveNotificationSocket()
socket.on('state-change', data => stateChanges.push(data.state))
socket.emit('subscribe', { videoId })
- const command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ const command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
async function countViews (expected: number) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: liveVideoId })
+ const video = await server.videos.get({ id: liveVideoId })
expect(video.views).to.equal(expected)
}
}
const liveAttributes = {
name: 'live video',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
- const live = await servers[0].liveCommand.create({ fields: liveAttributes })
+ const live = await servers[0].live.create({ fields: liveAttributes })
liveVideoId = live.uuid
- command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId })
+ command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId })
await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
await waitJobs(servers)
})
it('Should view a live twice and display 1 view', async function () {
this.timeout(30000)
- await servers[0].videosCommand.view({ id: liveVideoId })
- await servers[0].videosCommand.view({ id: liveVideoId })
+ await servers[0].videos.view({ id: liveVideoId })
+ await servers[0].videos.view({ id: liveVideoId })
await wait(7000)
it('Should view a live on a remote and on local and display 2 views', async function () {
this.timeout(30000)
- await servers[0].videosCommand.view({ id: liveVideoId })
- await servers[1].videosCommand.view({ id: liveVideoId })
- await servers[1].videosCommand.view({ id: liveVideoId })
+ await servers[0].videos.view({ id: liveVideoId })
+ await servers[1].videos.view({ id: liveVideoId })
+ await servers[1].videos.view({ id: liveVideoId })
await wait(7000)
await waitJobs(servers)
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- commands = servers.map(s => s.liveCommand)
+ commands = servers.map(s => s.live)
})
describe('Live creation, update and delete', function () {
language: 'fr',
description: 'super live description',
support: 'support field',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
nsfw: false,
waitTranscoding: false,
name: 'my super live',
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: liveVideoUUID })
+ const video = await server.videos.get({ id: liveVideoUUID })
expect(video.category.id).to.equal(1)
expect(video.licence.id).to.equal(2)
expect(video.description).to.equal('super live description')
expect(video.support).to.equal('support field')
- expect(video.channel.name).to.equal(servers[0].videoChannel.name)
- expect(video.channel.host).to.equal(servers[0].videoChannel.host)
+ expect(video.channel.name).to.equal(servers[0].store.channel.name)
+ expect(video.channel.host).to.equal(servers[0].store.channel.host)
expect(video.isLive).to.be.true
await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
await testImage(server.url, 'video_short1.webm', video.thumbnailPath)
- const live = await server.liveCommand.get({ videoId: liveVideoUUID })
+ const live = await server.live.get({ videoId: liveVideoUUID })
if (server.url === servers[0].url) {
expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
const attributes: LiveVideoCreate = {
name: 'default live thumbnail',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.UNLISTED,
nsfw: true
}
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED)
expect(video.nsfw).to.be.true
it('Should not have the live listed since nobody streams into', async function () {
for (const server of servers) {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
it('Have the live updated', async function () {
for (const server of servers) {
- const live = await server.liveCommand.get({ videoId: liveVideoUUID })
+ const live = await server.live.get({ videoId: liveVideoUUID })
if (server.url === servers[0].url) {
expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
it('Delete the live', async function () {
this.timeout(10000)
- await servers[0].videosCommand.remove({ id: liveVideoUUID })
+ await servers[0].videos.remove({ id: liveVideoUUID })
await waitJobs(servers)
})
it('Should have the live deleted', async function () {
for (const server of servers) {
- await server.videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
- await server.liveCommand.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.live.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
}
})
})
before(async function () {
this.timeout(120000)
- vodVideoId = (await servers[0].videosCommand.quickUpload({ name: 'vod video' })).uuid
+ vodVideoId = (await servers[0].videos.quickUpload({ name: 'vod video' })).uuid
- const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].videoChannel.id }
+ const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].store.channel.id }
const live = await commands[0].create({ fields: liveOptions })
liveVideoId = live.uuid
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId })
await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
await waitJobs(servers)
})
it('Should only display lives', async function () {
- const { data, total } = await servers[0].videosCommand.list({ isLive: true })
+ const { data, total } = await servers[0].videos.list({ isLive: true })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should not display lives', async function () {
- const { data, total } = await servers[0].videosCommand.list({ isLive: false })
+ const { data, total } = await servers[0].videos.list({ isLive: false })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
await stopFfmpeg(ffmpegCommand)
await waitJobs(servers)
- const { data } = await servers[0].videosCommand.listMyVideos({ isLive: true })
+ const { data } = await servers[0].videos.listMyVideos({ isLive: true })
const result = data.every(v => v.isLive)
expect(result).to.be.true
})
it('Should not display my lives', async function () {
- const { data } = await servers[0].videosCommand.listMyVideos({ isLive: false })
+ const { data } = await servers[0].videos.listMyVideos({ isLive: false })
const result = data.every(v => !v.isLive)
expect(result).to.be.true
})
after(async function () {
- await servers[0].videosCommand.remove({ id: vodVideoId })
- await servers[0].videosCommand.remove({ id: liveVideoId })
+ await servers[0].videos.remove({ id: vodVideoId })
+ await servers[0].videos.remove({ id: liveVideoId })
})
})
async function createLiveWrapper () {
const liveAttributes = {
name: 'user live',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
saveReplay: false
}
const { uuid } = await commands[0].create({ fields: liveAttributes })
const live = await commands[0].get({ videoId: uuid })
- const video = await servers[0].videosCommand.get({ id: uuid })
+ const video = await servers[0].videos.get({ id: uuid })
return Object.assign(video, live)
}
it('Should list this live now someone stream into it', async function () {
for (const server of servers) {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
liveVideo = await createLiveWrapper()
- await servers[0].blacklistCommand.add({ videoId: liveVideo.uuid })
+ await servers[0].blacklist.add({ videoId: liveVideo.uuid })
const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
await testFfmpegStreamError(command, true)
liveVideo = await createLiveWrapper()
- await servers[0].videosCommand.remove({ id: liveVideo.uuid })
+ await servers[0].videos.remove({ id: liveVideo.uuid })
const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
await testFfmpegStreamError(command, true)
async function createLiveWrapper (saveReplay: boolean) {
const liveAttributes = {
name: 'live video',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
saveReplay
}
async function testVideoResolutions (liveVideoId: string, resolutions: number[]) {
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data.find(v => v.uuid === liveVideoId)).to.exist
- const video = await server.videosCommand.get({ id: liveVideoId })
+ const video = await server.videos.get({ id: liveVideoId })
expect(video.streamingPlaylists).to.have.lengthOf(1)
const segmentName = `${i}-00000${segmentNum}.ts`
await commands[0].waitUntilSegmentGeneration({ videoUUID: video.uuid, resolution: i, segment: segmentNum })
- const subPlaylist = await servers[0].streamingPlaylistsCommand.get({
+ const subPlaylist = await servers[0].streamingPlaylists.get({
url: `${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8`
})
}
function updateConf (resolutions: number[]) {
- return servers[0].configCommand.updateCustomSubConfig({
+ return servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
}
for (const server of servers) {
- const video = await server.videosCommand.get({ id: liveVideoId })
+ const video = await server.videos.get({ id: liveVideoId })
expect(video.state.id).to.equal(VideoState.PUBLISHED)
expect(video.duration).to.be.greaterThan(1)
}
const filename = `${video.uuid}-${resolution}-fragmented.mp4`
- const segmentPath = servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
+ const segmentPath = servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
const probe = await ffprobePromise(segmentPath)
const videoStream = await getVideoStreamFromFile(segmentPath, probe)
async function createLiveWrapper (saveReplay: boolean) {
const liveAttributes = {
name: 'live video',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
saveReplay
}
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- commands = servers.map(s => s.abusesCommand)
+ commands = servers.map(s => s.abuses)
})
describe('Video abuses', function () {
name: 'my super name for server 1',
description: 'my super description for server 1'
}
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
}
{
name: 'my super name for server 2',
description: 'my super description for server 2'
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
}
// Wait videos propagation, server 2 has transcoding enabled
await waitJobs(servers)
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data.length).to.equal(2)
- servers[0].video = data.find(video => video.name === 'my super name for server 1')
- servers[1].video = data.find(video => video.name === 'my super name for server 2')
+ servers[0].store.video = data.find(video => video.name === 'my super name for server 1')
+ servers[1].store.video = data.find(video => video.name === 'my super name for server 2')
})
it('Should not have abuses', async function () {
this.timeout(15000)
const reason = 'my super bad reason'
- await commands[0].report({ videoId: servers[0].video.id, reason })
+ await commands[0].report({ videoId: servers[0].store.video.id, reason })
// We wait requests propagation, even if the server 1 is not supposed to make a request to server 2
await waitJobs(servers)
expect(abuse.reporterAccount.name).to.equal('root')
expect(abuse.reporterAccount.host).to.equal(servers[0].host)
- expect(abuse.video.id).to.equal(servers[0].video.id)
+ expect(abuse.video.id).to.equal(servers[0].store.video.id)
expect(abuse.video.channel).to.exist
expect(abuse.comment).to.be.null
this.timeout(10000)
const reason = 'my super bad reason 2'
- const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid })
+ const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
await commands[0].report({ videoId, reason })
// We wait requests propagation
expect(abuse1.reporterAccount.name).to.equal('root')
expect(abuse1.reporterAccount.host).to.equal(servers[0].host)
- expect(abuse1.video.id).to.equal(servers[0].video.id)
+ expect(abuse1.video.id).to.equal(servers[0].store.video.id)
expect(abuse1.video.countReports).to.equal(1)
expect(abuse1.video.nthReport).to.equal(1)
expect(abuse2.reporterAccount.name).to.equal('root')
expect(abuse2.reporterAccount.host).to.equal(servers[0].host)
- expect(abuse2.video.id).to.equal(servers[1].video.id)
+ expect(abuse2.video.id).to.equal(servers[1].store.video.id)
expect(abuse2.comment).to.be.null
this.timeout(10000)
{
- const videoId = await servers[1].videosCommand.getId({ uuid: servers[0].video.uuid })
+ const videoId = await servers[1].videos.getId({ uuid: servers[0].store.video.uuid })
await commands[1].report({ videoId, reason: 'will mute this' })
await waitJobs(servers)
const accountToBlock = 'root@' + servers[1].host
{
- await servers[0].blocklistCommand.addToServerBlocklist({ account: accountToBlock })
+ await servers[0].blocklist.addToServerBlocklist({ account: accountToBlock })
const body = await commands[0].getAdminList()
expect(body.total).to.equal(2)
}
{
- await servers[0].blocklistCommand.removeFromServerBlocklist({ account: accountToBlock })
+ await servers[0].blocklist.removeFromServerBlocklist({ account: accountToBlock })
const body = await commands[0].getAdminList()
expect(body.total).to.equal(3)
const serverToBlock = servers[1].host
{
- await servers[0].blocklistCommand.addToServerBlocklist({ server: serverToBlock })
+ await servers[0].blocklist.addToServerBlocklist({ server: serverToBlock })
const body = await commands[0].getAdminList()
expect(body.total).to.equal(2)
}
{
- await servers[0].blocklistCommand.removeFromServerBlocklist({ server: serverToBlock })
+ await servers[0].blocklist.removeFromServerBlocklist({ server: serverToBlock })
const body = await commands[0].getAdminList()
expect(body.total).to.equal(3)
it('Should keep the video abuse when deleting the video', async function () {
this.timeout(10000)
- await servers[1].videosCommand.remove({ id: abuseServer2.video.uuid })
+ await servers[1].videos.remove({ id: abuseServer2.video.uuid })
await waitJobs(servers)
// register a second user to have two reporters/reportees
const user = { username: 'user2', password: 'password' }
- await servers[0].usersCommand.create({ ...user })
- const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ await servers[0].users.create({ ...user })
+ const userAccessToken = await servers[0].login.getAccessToken(user)
// upload a third video via this user
const attributes = {
name: 'my second super name for server 1',
description: 'my second super description for server 1'
}
- const { id } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes })
+ const { id } = await servers[0].videos.upload({ token: userAccessToken, attributes })
const video3Id = id
// resume with the test
await commands[0].report({ videoId: video3Id, reason: reason3 })
const reason4 = 'my super bad reason 4'
- await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: reason4 })
+ await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: reason4 })
{
const body = await commands[0].getAdminList()
expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse")
expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse")
- const abuseServer1 = abuses.find(a => a.video.id === servers[0].video.id)
+ const abuseServer1 = abuses.find(a => a.video.id === servers[0].store.video.id)
expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse")
}
})
const reason5 = 'my super bad reason 5'
const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ]
const createRes = await commands[0].report({
- videoId: servers[0].video.id,
+ videoId: servers[0].store.video.id,
reason: reason5,
predefinedReasons: predefinedReasons5,
startAt: 1,
async function getComment (server: ServerInfo, videoIdArg: number | string) {
const videoId = typeof videoIdArg === 'string'
- ? await server.videosCommand.getId({ uuid: videoIdArg })
+ ? await server.videos.getId({ uuid: videoIdArg })
: videoIdArg
- const { data } = await server.commentsCommand.listThreads({ videoId })
+ const { data } = await server.comments.listThreads({ videoId })
return data[0]
}
before(async function () {
this.timeout(50000)
- servers[0].video = await await servers[0].videosCommand.quickUpload({ name: 'server 1' })
- servers[1].video = await await servers[1].videosCommand.quickUpload({ name: 'server 2' })
+ servers[0].store.video = await await servers[0].videos.quickUpload({ name: 'server 1' })
+ servers[1].store.video = await await servers[1].videos.quickUpload({ name: 'server 2' })
- await servers[0].commentsCommand.createThread({ videoId: servers[0].video.id, text: 'comment server 1' })
- await servers[1].commentsCommand.createThread({ videoId: servers[1].video.id, text: 'comment server 2' })
+ await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' })
+ await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' })
await waitJobs(servers)
})
it('Should report abuse on a comment', async function () {
this.timeout(15000)
- const comment = await getComment(servers[0], servers[0].video.id)
+ const comment = await getComment(servers[0], servers[0].store.video.id)
const reason = 'it is a bad comment'
await commands[0].report({ commentId: comment.id, reason })
it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () {
{
- const comment = await getComment(servers[0], servers[0].video.id)
+ const comment = await getComment(servers[0], servers[0].store.video.id)
const body = await commands[0].getAdminList({ filter: 'comment' })
expect(body.total).to.equal(1)
expect(abuse.comment.id).to.equal(comment.id)
expect(abuse.comment.text).to.equal(comment.text)
expect(abuse.comment.video.name).to.equal('server 1')
- expect(abuse.comment.video.id).to.equal(servers[0].video.id)
- expect(abuse.comment.video.uuid).to.equal(servers[0].video.uuid)
+ expect(abuse.comment.video.id).to.equal(servers[0].store.video.id)
+ expect(abuse.comment.video.uuid).to.equal(servers[0].store.video.uuid)
expect(abuse.countReportsForReporter).to.equal(5)
expect(abuse.countReportsForReportee).to.equal(5)
it('Should report abuse on a remote comment', async function () {
this.timeout(10000)
- const comment = await getComment(servers[0], servers[1].video.uuid)
+ const comment = await getComment(servers[0], servers[1].store.video.uuid)
const reason = 'it is a really bad comment'
await commands[0].report({ commentId: comment.id, reason })
})
it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () {
- const commentServer2 = await getComment(servers[0], servers[1].video.id)
+ const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
{
const body = await commands[0].getAdminList({ filter: 'comment' })
expect(abuse2.comment.id).to.equal(commentServer2.id)
expect(abuse2.comment.text).to.equal(commentServer2.text)
expect(abuse2.comment.video.name).to.equal('server 2')
- expect(abuse2.comment.video.uuid).to.equal(servers[1].video.uuid)
+ expect(abuse2.comment.video.uuid).to.equal(servers[1].store.video.uuid)
expect(abuse2.state.id).to.equal(AbuseState.PENDING)
expect(abuse2.state.label).to.equal('Pending')
it('Should keep the comment abuse when deleting the comment', async function () {
this.timeout(10000)
- const commentServer2 = await getComment(servers[0], servers[1].video.id)
+ const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
- await servers[0].commentsCommand.delete({ videoId: servers[1].video.uuid, commentId: commentServer2.id })
+ await servers[0].comments.delete({ videoId: servers[1].store.video.uuid, commentId: commentServer2.id })
await waitJobs(servers)
describe('Account abuses', function () {
function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) {
- return server.accountsCommand.get({ accountName: targetName + '@' + targetServer.host })
+ return server.accounts.get({ accountName: targetName + '@' + targetServer.host })
}
before(async function () {
this.timeout(50000)
- await servers[0].usersCommand.create({ username: 'user_1', password: 'donald' })
+ await servers[0].users.create({ username: 'user_1', password: 'donald' })
- const token = await servers[1].usersCommand.generateUserAndToken('user_2')
- await servers[1].videosCommand.upload({ token, attributes: { name: 'super video' } })
+ const token = await servers[1].users.generateUserAndToken('user_2')
+ await servers[1].videos.upload({ token, attributes: { name: 'super video' } })
await waitJobs(servers)
})
this.timeout(10000)
const account = await getAccountFromServer(servers[1], 'user_2', servers[1])
- await servers[1].usersCommand.remove({ userId: account.userId })
+ await servers[1].users.remove({ userId: account.userId })
await waitJobs(servers)
let userAccessToken: string
before(async function () {
- userAccessToken = await servers[0].usersCommand.generateUserAndToken('user_42')
+ userAccessToken = await servers[0].users.generateUserAndToken('user_42')
- await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: 'user reason 1' })
+ await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: 'user reason 1' })
- const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid })
+ const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' })
})
let abuseMessageModerationId: number
before(async function () {
- userToken = await servers[0].usersCommand.generateUserAndToken('user_43')
+ userToken = await servers[0].users.generateUserAndToken('user_43')
- const body = await commands[0].report({ token: userToken, videoId: servers[0].video.id, reason: 'user 43 reason 1' })
+ const body = await commands[0].report({ token: userToken, videoId: servers[0].store.video.id, reason: 'user 43 reason 1' })
abuseId = body.abuse.id
})
const expect = chai.expect
async function checkNotifications (server: ServerInfo, token: string, expected: UserNotificationType[]) {
- const { data } = await server.notificationsCommand.list({ token, start: 0, count: 10, unread: true })
+ const { data } = await server.notifications.list({ token, start: 0, count: 10, unread: true })
expect(data).to.have.lengthOf(expected.length)
for (const type of expected) {
async function resetState () {
try {
- await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host })
- await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host })
+ await servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host })
+ await servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host })
} catch {}
await waitJobs(servers)
- await servers[0].notificationsCommand.markAsReadAll({ token: userToken1 })
- await servers[0].notificationsCommand.markAsReadAll({ token: userToken2 })
+ await servers[0].notifications.markAsReadAll({ token: userToken1 })
+ await servers[0].notifications.markAsReadAll({ token: userToken2 })
{
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video' } })
videoUUID = uuid
await waitJobs(servers)
}
{
- await servers[1].commentsCommand.createThread({
+ await servers[1].comments.createThread({
token: remoteUserToken,
videoId: videoUUID,
text: '@user2@' + servers[0].host + ' hello'
{
- await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host })
- await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host })
+ await servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host })
+ await servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host })
}
await waitJobs(servers)
{
const user = { username: 'user1', password: 'password' }
- await servers[0].usersCommand.create({
+ await servers[0].users.create({
username: user.username,
password: user.password,
videoQuota: -1,
videoQuotaDaily: -1
})
- userToken1 = await servers[0].loginCommand.getAccessToken(user)
- await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video user 1' } })
+ userToken1 = await servers[0].login.getAccessToken(user)
+ await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video user 1' } })
}
{
const user = { username: 'user2', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- userToken2 = await servers[0].loginCommand.getAccessToken(user)
+ userToken2 = await servers[0].login.getAccessToken(user)
}
{
const user = { username: 'user3', password: 'password' }
- await servers[1].usersCommand.create({ username: user.username, password: user.password })
+ await servers[1].users.create({ username: user.username, password: user.password })
- remoteUserToken = await servers[1].loginCommand.getAccessToken(user)
+ remoteUserToken = await servers[1].login.getAccessToken(user)
}
await doubleFollow(servers[0], servers[1])
it('Should block an account', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
+ await servers[0].blocklist.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
await waitJobs(servers)
})
await checkNotifications(servers[0], userToken2, notifs)
- await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
+ await servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
})
})
it('Should block an account', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, server: servers[1].host })
+ await servers[0].blocklist.addToMyBlocklist({ token: userToken1, server: servers[1].host })
await waitJobs(servers)
})
await checkNotifications(servers[0], userToken2, notifs)
- await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, server: servers[1].host })
+ await servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, server: servers[1].host })
})
})
it('Should block an account', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToServerBlocklist({ account: 'user3@' + servers[1].host })
+ await servers[0].blocklist.addToServerBlocklist({ account: 'user3@' + servers[1].host })
await waitJobs(servers)
})
await checkNotifications(servers[0], userToken1, [])
await checkNotifications(servers[0], userToken2, [])
- await servers[0].blocklistCommand.removeFromServerBlocklist({ account: 'user3@' + servers[1].host })
+ await servers[0].blocklist.removeFromServerBlocklist({ account: 'user3@' + servers[1].host })
})
})
it('Should block an account', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToServerBlocklist({ server: servers[1].host })
+ await servers[0].blocklist.addToServerBlocklist({ server: servers[1].host })
await waitJobs(servers)
})
async function checkAllVideos (server: ServerInfo, token: string) {
{
- const { data } = await server.videosCommand.listWithToken({ token })
+ const { data } = await server.videos.listWithToken({ token })
expect(data).to.have.lengthOf(5)
}
{
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(5)
}
}
async function checkAllComments (server: ServerInfo, token: string, videoUUID: string) {
- const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token })
+ const { data } = await server.comments.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token })
const threads = data.filter(t => t.isDeleted === false)
expect(threads).to.have.lengthOf(2)
for (const thread of threads) {
- const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId: thread.id, token })
+ const tree = await server.comments.getThread({ videoId: videoUUID, threadId: thread.id, token })
expect(tree.children).to.have.lengthOf(1)
}
}
comment: { server: ServerInfo, token: string, videoUUID: string, text: string },
check: 'presence' | 'absence'
) {
- const command = comment.server.commentsCommand
+ const command = comment.server.comments
const { threadId, createdAt } = await command.createThread({ token: comment.token, videoId: comment.videoUUID, text: comment.text })
await waitJobs([ mainServer, comment.server ])
- const { data } = await mainServer.notificationsCommand.list({ start: 0, count: 30 })
+ const { data } = await mainServer.notifications.list({ start: 0, count: 30 })
const commentNotifications = data.filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt)
if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1)
servers = await flushAndRunMultipleServers(3)
await setAccessTokensToServers(servers)
- command = servers[0].blocklistCommand
- commentsCommand = servers.map(s => s.commentsCommand)
+ command = servers[0].blocklist
+ commentsCommand = servers.map(s => s.comments)
{
const user = { username: 'user1', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- userToken1 = await servers[0].loginCommand.getAccessToken(user)
- await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video user 1' } })
+ userToken1 = await servers[0].login.getAccessToken(user)
+ await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video user 1' } })
}
{
const user = { username: 'moderator', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- userModeratorToken = await servers[0].loginCommand.getAccessToken(user)
+ userModeratorToken = await servers[0].login.getAccessToken(user)
}
{
const user = { username: 'user2', password: 'password' }
- await servers[1].usersCommand.create({ username: user.username, password: user.password })
+ await servers[1].users.create({ username: user.username, password: user.password })
- userToken2 = await servers[1].loginCommand.getAccessToken(user)
- await servers[1].videosCommand.upload({ token: userToken2, attributes: { name: 'video user 2' } })
+ userToken2 = await servers[1].login.getAccessToken(user)
+ await servers[1].videos.upload({ token: userToken2, attributes: { name: 'video user 2' } })
}
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video server 1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video server 1' } })
videoUUID1 = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video server 2' } })
videoUUID2 = uuid
}
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 2 server 1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } })
videoUUID3 = uuid
}
})
it('Should hide its videos', async function () {
- const { data } = await servers[0].videosCommand.listWithToken()
+ const { data } = await servers[0].videos.listWithToken()
expect(data).to.have.lengthOf(4)
})
it('Should hide its videos', async function () {
- const { data } = await servers[0].videosCommand.listWithToken()
+ const { data } = await servers[0].videos.listWithToken()
expect(data).to.have.lengthOf(3)
// Server 1 and 3 should only have uploader comments
for (const server of [ servers[0], servers[2] ]) {
- const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
+ const { data } = await server.comments.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
expect(data).to.have.lengthOf(1)
expect(data[0].text).to.equal('uploader')
- const tree = await server.commentsCommand.getThread({ videoId: videoUUID3, threadId: data[0].id })
+ const tree = await server.comments.getThread({ videoId: videoUUID3, threadId: data[0].id })
if (server.serverNumber === 1) expect(tree.children).to.have.lengthOf(0)
else expect(tree.children).to.have.lengthOf(1)
})
it('Should display its videos', async function () {
- const { data } = await servers[0].videosCommand.listWithToken()
+ const { data } = await servers[0].videos.listWithToken()
expect(data).to.have.lengthOf(4)
const v = data.find(v => v.name === 'video user 2')
it('Should display its comments on my video', async function () {
for (const server of servers) {
- const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
+ const { data } = await server.comments.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
// Server 3 should not have 2 comment threads, because server 1 did not forward the server 2 comment
if (server.serverNumber === 3) {
expect(data[0].text).to.equal('uploader')
expect(data[1].text).to.equal('comment user 2')
- const tree = await server.commentsCommand.getThread({ videoId: videoUUID3, threadId: data[0].id })
+ const tree = await server.comments.getThread({ videoId: videoUUID3, threadId: data[0].id })
expect(tree.children).to.have.lengthOf(1)
expect(tree.children[0].comment.text).to.equal('reply by user 2')
expect(tree.children[0].children).to.have.lengthOf(1)
})
it('Should hide its videos', async function () {
- const { data } = await servers[0].videosCommand.listWithToken()
+ const { data } = await servers[0].videos.listWithToken()
expect(data).to.have.lengthOf(3)
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
- const { data } = await servers[0].videosCommand.listWithToken({ token })
+ const { data } = await servers[0].videos.listWithToken({ token })
expect(data).to.have.lengthOf(4)
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
- const { data } = await servers[0].videosCommand.listWithToken({ token })
+ const { data } = await servers[0].videos.listWithToken({ token })
expect(data).to.have.lengthOf(3)
it('Should display its videos', async function () {
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
- const { data } = await servers[0].videosCommand.listWithToken({ token })
+ const { data } = await servers[0].videos.listWithToken({ token })
expect(data).to.have.lengthOf(4)
const v = data.find(v => v.name === 'video user 2')
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
const requests = [
- servers[0].videosCommand.list(),
- servers[0].videosCommand.listWithToken({ token })
+ servers[0].videos.list(),
+ servers[0].videos.listWithToken({ token })
]
for (const req of requests) {
{
const now = new Date()
- await servers[1].followsCommand.unfollow({ target: servers[0] })
+ await servers[1].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
- await servers[1].followsCommand.follow({ targets: [ servers[0].host ] })
+ await servers[1].follows.follow({ targets: [ servers[0].host ] })
await waitJobs(servers)
- const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 })
+ const { data } = await servers[0].notifications.list({ start: 0, count: 30 })
const commentNotifications = data.filter(n => {
return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
})
{
const now = new Date()
- await servers[1].followsCommand.unfollow({ target: servers[0] })
+ await servers[1].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
- await servers[1].followsCommand.follow({ targets: [ servers[0].host ] })
+ await servers[1].follows.follow({ targets: [ servers[0].host ] })
await waitJobs(servers)
- const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 })
+ const { data } = await servers[0].notifications.list({ start: 0, count: 30 })
const commentNotifications = data.filter(n => {
return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
})
let command: BlacklistCommand
async function blacklistVideosOnServer (server: ServerInfo) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
for (const video of data) {
- await server.blacklistCommand.add({ videoId: video.id, reason: 'super reason' })
+ await server.blacklist.add({ videoId: video.id, reason: 'super reason' })
}
}
await doubleFollow(servers[0], servers[1])
// Upload 2 videos on server 2
- await servers[1].videosCommand.upload({ attributes: { name: 'My 1st video', description: 'A video on server 2' } })
- await servers[1].videosCommand.upload({ attributes: { name: 'My 2nd video', description: 'A video on server 2' } })
+ await servers[1].videos.upload({ attributes: { name: 'My 1st video', description: 'A video on server 2' } })
+ await servers[1].videos.upload({ attributes: { name: 'My 2nd video', description: 'A video on server 2' } })
// Wait videos propagation, server 2 has transcoding enabled
await waitJobs(servers)
- command = servers[0].blacklistCommand
+ command = servers[0].blacklist
// Blacklist the two videos on server 1
await blacklistVideosOnServer(servers[0])
it('Should not have the video blacklisted in videos list/search on server 1', async function () {
{
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(0)
expect(data).to.be.an('array')
}
{
- const body = await servers[0].searchCommand.searchVideos({ search: 'video' })
+ const body = await servers[0].search.searchVideos({ search: 'video' })
expect(body.total).to.equal(0)
expect(body.data).to.be.an('array')
it('Should have the blacklisted video in videos list/search on server 2', async function () {
{
- const { total, data } = await servers[1].videosCommand.list()
+ const { total, data } = await servers[1].videos.list()
expect(total).to.equal(2)
expect(data).to.be.an('array')
}
{
- const body = await servers[1].searchCommand.searchVideos({ search: 'video' })
+ const body = await servers[1].search.searchVideos({ search: 'video' })
expect(body.total).to.equal(2)
expect(body.data).to.be.an('array')
it('Should display blacklisted videos', async function () {
await blacklistVideosOnServer(servers[1])
- const { total, data } = await servers[1].videosCommand.listMyVideos()
+ const { total, data } = await servers[1].videos.listMyVideos()
expect(total).to.equal(2)
expect(data).to.have.lengthOf(2)
let blacklist = []
it('Should not have any video in videos list on server 1', async function () {
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(0)
expect(data).to.be.an('array')
expect(data.length).to.equal(0)
})
it('Should have the ex-blacklisted video in videos list on server 1', async function () {
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(1)
expect(data).to.be.an('array')
this.timeout(10000)
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'Video 3' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'Video 3' } })
video3UUID = uuid
}
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'Video 4' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'Video 4' } })
video4UUID = uuid
}
await waitJobs(servers)
{
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data.find(v => v.uuid === video3UUID)).to.be.undefined
}
{
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
expect(data.find(v => v.uuid === video3UUID)).to.not.be.undefined
}
})
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data.find(v => v.uuid === video4UUID)).to.be.undefined
}
})
it('Should have the video unfederated even after an Update AP message', async function () {
this.timeout(10000)
- await servers[0].videosCommand.update({ id: video4UUID, attributes: { description: 'super description' } })
+ await servers[0].videos.update({ id: video4UUID, attributes: { description: 'super description' } })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data.find(v => v.uuid === video4UUID)).to.be.undefined
}
})
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data.find(v => v.uuid === video4UUID)).to.not.be.undefined
}
})
{
const user = { username: 'user_without_flag', password: 'password' }
- await servers[0].usersCommand.create({
+ await servers[0].users.create({
username: user.username,
adminFlags: UserAdminFlag.NONE,
password: user.password,
role: UserRole.USER
})
- userWithoutFlag = await servers[0].loginCommand.getAccessToken(user)
+ userWithoutFlag = await servers[0].login.getAccessToken(user)
- const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: userWithoutFlag })
+ const { videoChannels } = await servers[0].users.getMyInfo({ token: userWithoutFlag })
channelOfUserWithoutFlag = videoChannels[0].id
}
{
const user = { username: 'user_with_flag', password: 'password' }
- await servers[0].usersCommand.create({
+ await servers[0].users.create({
username: user.username,
adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST,
password: user.password,
role: UserRole.USER
})
- userWithFlag = await servers[0].loginCommand.getAccessToken(user)
+ userWithFlag = await servers[0].login.getAccessToken(user)
}
await waitJobs(servers)
})
it('Should auto blacklist a video on upload', async function () {
- await servers[0].videosCommand.upload({ token: userWithoutFlag, attributes: { name: 'blacklisted' } })
+ await servers[0].videos.upload({ token: userWithoutFlag, attributes: { name: 'blacklisted' } })
const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(1)
name: 'URL import',
channelId: channelOfUserWithoutFlag
}
- await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes })
+ await servers[0].imports.importVideo({ token: userWithoutFlag, attributes })
const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(2)
name: 'Torrent import',
channelId: channelOfUserWithoutFlag
}
- await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes })
+ await servers[0].imports.importVideo({ token: userWithoutFlag, attributes })
const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(3)
})
it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', async function () {
- await servers[0].videosCommand.upload({ token: userWithFlag, attributes: { name: 'not blacklisted' } })
+ await servers[0].videos.upload({ token: userWithFlag, attributes: { name: 'not blacklisted' } })
const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(3)
token: server.accessToken
}
- await server.pluginsCommand.install({ npmName: 'peertube-plugin-hello-world' })
- await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' })
+ await server.plugins.install({ npmName: 'peertube-plugin-hello-world' })
+ await server.plugins.install({ npmName: 'peertube-theme-background-red' })
})
describe('Latest PeerTube version notification', function () {
it('Should send a notification to admins on new plugin version', async function () {
this.timeout(30000)
- await server.sqlCommand.setPluginVersion('hello-world', '0.0.1')
- await server.sqlCommand.setPluginLatestVersion('hello-world', '0.0.1')
+ await server.sql.setPluginVersion('hello-world', '0.0.1')
+ await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
await wait(6000)
await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'presence')
it('Should send a new notification after a new plugin release', async function () {
this.timeout(30000)
- await server.sqlCommand.setPluginVersion('hello-world', '0.0.1')
- await server.sqlCommand.setPluginLatestVersion('hello-world', '0.0.1')
+ await server.sql.setPluginVersion('hello-world', '0.0.1')
+ await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
await wait(6000)
expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2)
it('Should not send a new comment notification after a comment on another video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
const commentId = created.id
await waitJobs(servers)
it('Should not send a new comment notification if I comment my own video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const created = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: 'comment' })
+ const created = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: 'comment' })
const commentId = created.id
await waitJobs(servers)
it('Should not send a new comment notification if the account is muted', async function () {
this.timeout(20000)
- await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' })
+ await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
const commentId = created.id
await waitJobs(servers)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
- await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' })
+ await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
})
it('Should send a new comment notification after a local comment on my video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
const commentId = created.id
await waitJobs(servers)
it('Should send a new comment notification after a remote comment on my video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
await waitJobs(servers)
- await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ await servers[1].comments.createThread({ videoId: uuid, text: 'comment' })
await waitJobs(servers)
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid })
+ const { data } = await servers[0].comments.listThreads({ videoId: uuid })
expect(data).to.have.lengthOf(1)
const commentId = data[0].id
it('Should send a new comment notification after a local reply on my video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
- const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
+ const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
await waitJobs(servers)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence')
it('Should send a new comment notification after a remote reply on my video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
await waitJobs(servers)
{
- const created = await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const created = await servers[1].comments.createThread({ videoId: uuid, text: 'comment' })
const threadId = created.id
- await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
+ await servers[1].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
}
await waitJobs(servers)
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid })
+ const { data } = await servers[0].comments.listThreads({ videoId: uuid })
expect(data).to.have.lengthOf(1)
const threadId = data[0].id
- const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId })
+ const tree = await servers[0].comments.getThread({ videoId: uuid, threadId })
expect(tree.children).to.have.lengthOf(1)
const commentId = tree.children[0].comment.id
it('Should convert markdown in comment to html', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'cool video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'cool video' } })
- await servers[0].commentsCommand.createThread({ videoId: uuid, text: commentText })
+ await servers[0].comments.createThread({ videoId: uuid, text: commentText })
await waitJobs(servers)
token: userToken
}
- await servers[0].usersCommand.updateMe({ displayName: 'super root name' })
- await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' })
+ await servers[0].users.updateMe({ displayName: 'super root name' })
+ await servers[1].users.updateMe({ displayName: 'super root 2 name' })
})
it('Should not send a new mention comment notification if I mention the video owner', async function () {
this.timeout(10000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
+ const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
it('Should not send a new mention comment notification if I mention myself', async function () {
this.timeout(10000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const { id: commentId } = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
+ const { id: commentId } = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
it('Should not send a new mention notification if the account is muted', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' })
+ await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
+ const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
- await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' })
+ await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
})
it('Should not send a new mention notification if the remote account mention a local account', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
await waitJobs(servers)
- const { id: threadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
+ const { id: threadId } = await servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence')
it('Should send a new mention notification after local comments', async function () {
this.timeout(10000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
+ const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence')
- const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' })
+ const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence')
it('Should send a new mention notification after remote comments', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
await waitJobs(servers)
const text1 = `hello @user_1@localhost:${servers[0].port} 1`
- const { id: server2ThreadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: text1 })
+ const { id: server2ThreadId } = await servers[1].comments.createThread({ videoId: uuid, text: text1 })
await waitJobs(servers)
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid })
+ const { data } = await servers[0].comments.listThreads({ videoId: uuid })
expect(data).to.have.lengthOf(1)
const server1ThreadId = data[0].id
await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence')
const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`
- await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 })
+ await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 })
await waitJobs(servers)
- const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId: server1ThreadId })
+ const tree = await servers[0].comments.getThread({ videoId: uuid, threadId: server1ThreadId })
expect(tree.children).to.have.lengthOf(1)
const commentId = tree.children[0].comment.id
it('Should convert markdown in comment to html', async function () {
this.timeout(10000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello 1' })
+ const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello 1' })
- await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText })
+ await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText })
await waitJobs(servers)
this.timeout(20000)
const name = 'video for abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- await servers[0].abusesCommand.report({ videoId: video.id, reason: 'super reason' })
+ await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' })
await waitJobs(servers)
await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence')
this.timeout(20000)
const name = 'video for abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
await waitJobs(servers)
- const videoId = await servers[1].videosCommand.getId({ uuid: video.uuid })
- await servers[1].abusesCommand.report({ videoId, reason: 'super reason' })
+ const videoId = await servers[1].videos.getId({ uuid: video.uuid })
+ await servers[1].abuses.report({ videoId, reason: 'super reason' })
await waitJobs(servers)
await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence')
this.timeout(20000)
const name = 'video for abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
- const comment = await servers[0].commentsCommand.createThread({
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
+ const comment = await servers[0].comments.createThread({
token: userAccessToken,
videoId: video.id,
text: 'comment abuse ' + buildUUID()
await waitJobs(servers)
- await servers[0].abusesCommand.report({ commentId: comment.id, reason: 'super reason' })
+ await servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' })
await waitJobs(servers)
await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence')
this.timeout(20000)
const name = 'video for abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- await servers[0].commentsCommand.createThread({
+ await servers[0].comments.createThread({
token: userAccessToken,
videoId: video.id,
text: 'comment abuse ' + buildUUID()
await waitJobs(servers)
- const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.uuid })
+ const { data } = await servers[1].comments.listThreads({ videoId: video.uuid })
const commentId = data[0].id
- await servers[1].abusesCommand.report({ commentId, reason: 'super reason' })
+ await servers[1].abuses.report({ commentId, reason: 'super reason' })
await waitJobs(servers)
await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence')
this.timeout(20000)
const username = 'user' + new Date().getTime()
- const { account } = await servers[0].usersCommand.create({ username, password: 'donald' })
+ const { account } = await servers[0].users.create({ username, password: 'donald' })
const accountId = account.id
- await servers[0].abusesCommand.report({ accountId, reason: 'super reason' })
+ await servers[0].abuses.report({ accountId, reason: 'super reason' })
await waitJobs(servers)
await checkNewAccountAbuseForModerators(baseParams, username, 'presence')
this.timeout(20000)
const username = 'user' + new Date().getTime()
- const tmpToken = await servers[0].usersCommand.generateUserAndToken(username)
- await servers[0].videosCommand.upload({ token: tmpToken, attributes: { name: 'super video' } })
+ const tmpToken = await servers[0].users.generateUserAndToken(username)
+ await servers[0].videos.upload({ token: tmpToken, attributes: { name: 'super video' } })
await waitJobs(servers)
- const account = await servers[1].accountsCommand.get({ accountName: username + '@' + servers[0].host })
- await servers[1].abusesCommand.report({ accountId: account.id, reason: 'super reason' })
+ const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host })
+ await servers[1].abuses.report({ accountId: account.id, reason: 'super reason' })
await waitJobs(servers)
await checkNewAccountAbuseForModerators(baseParams, username, 'presence')
}
const name = 'abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
+ const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
abuseId = body.abuse.id
})
it('Should send a notification to reporter if the abuse has been accepted', async function () {
this.timeout(10000)
- await servers[0].abusesCommand.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
+ await servers[0].abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
await waitJobs(servers)
await checkAbuseStateChange(baseParams, abuseId, AbuseState.ACCEPTED, 'presence')
it('Should send a notification to reporter if the abuse has been rejected', async function () {
this.timeout(10000)
- await servers[0].abusesCommand.update({ abuseId, body: { state: AbuseState.REJECTED } })
+ await servers[0].abuses.update({ abuseId, body: { state: AbuseState.REJECTED } })
await waitJobs(servers)
await checkAbuseStateChange(baseParams, abuseId, AbuseState.REJECTED, 'presence')
}
const name = 'abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
{
- const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
+ const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
abuseId = body.abuse.id
}
{
- const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' })
+ const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' })
abuseId2 = body.abuse.id
}
})
this.timeout(10000)
const message = 'my super message to users'
- await servers[0].abusesCommand.addMessage({ abuseId, message })
+ await servers[0].abuses.addMessage({ abuseId, message })
await waitJobs(servers)
await checkNewAbuseMessage(baseParamsUser, abuseId, message, 'user_1@example.com', 'presence')
this.timeout(10000)
const message = 'my super message that should not be sent to the admin'
- await servers[0].abusesCommand.addMessage({ abuseId, message })
+ await servers[0].abuses.addMessage({ abuseId, message })
await waitJobs(servers)
await checkNewAbuseMessage(baseParamsAdmin, abuseId, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'absence')
this.timeout(10000)
const message = 'my super message to moderators'
- await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
+ await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
await waitJobs(servers)
await checkNewAbuseMessage(baseParamsAdmin, abuseId2, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'presence')
this.timeout(10000)
const message = 'my super message that should not be sent to reporter'
- await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
+ await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
await waitJobs(servers)
await checkNewAbuseMessage(baseParamsUser, abuseId2, message, 'user_1@example.com', 'absence')
this.timeout(10000)
const name = 'video for abuse ' + buildUUID()
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- await servers[0].blacklistCommand.add({ videoId: uuid })
+ await servers[0].blacklist.add({ videoId: uuid })
await waitJobs(servers)
await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist')
this.timeout(10000)
const name = 'video for abuse ' + buildUUID()
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- await servers[0].blacklistCommand.add({ videoId: uuid })
+ await servers[0].blacklist.add({ videoId: uuid })
await waitJobs(servers)
- await servers[0].blacklistCommand.remove({ videoId: uuid })
+ await servers[0].blacklist.remove({ videoId: uuid })
await waitJobs(servers)
await wait(500)
it('Should send a notification only to moderators when a user registers on the instance', async function () {
this.timeout(10000)
- await servers[0].usersCommand.register({ username: 'user_45' })
+ await servers[0].users.register({ username: 'user_45' })
await waitJobs(servers)
it('Should send a notification only to admin when there is a new instance follower', async function () {
this.timeout(20000)
- await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[2].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
it('Should send a notification on auto follow back', async function () {
this.timeout(40000)
- await servers[2].followsCommand.unfollow({ target: servers[0] })
+ await servers[2].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
const config = {
}
}
}
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
- await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[2].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence')
config.followings.instance.autoFollowBack.enabled = false
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
- await servers[0].followsCommand.unfollow({ target: servers[2] })
- await servers[2].followsCommand.unfollow({ target: servers[0] })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
+ await servers[0].follows.unfollow({ target: servers[2] })
+ await servers[2].follows.unfollow({ target: servers[0] })
})
it('Should send a notification on auto instances index follow', async function () {
this.timeout(30000)
- await servers[0].followsCommand.unfollow({ target: servers[1] })
+ await servers[0].follows.unfollow({ target: servers[1] })
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)
await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
config.followings.instance.autoFollowIndex.enabled = false
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
- await servers[0].followsCommand.unfollow({ target: servers[1] })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
+ await servers[0].follows.unfollow({ target: servers[1] })
})
})
token: userAccessToken
}
- currentCustomConfig = await servers[0].configCommand.getCustomConfig()
+ currentCustomConfig = await servers[0].config.getCustomConfig()
const autoBlacklistTestsCustomConfig = {
...currentCustomConfig,
// enable transcoding otherwise own publish notification after transcoding not expected
autoBlacklistTestsCustomConfig.transcoding.enabled = true
- await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
+ await servers[0].config.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
- await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
- await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
})
this.timeout(40000)
videoName = 'video with auto-blacklist ' + buildUUID()
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: videoName } })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } })
videoUUID = uuid
await waitJobs(servers)
it('Should send video published and unblacklist after video unblacklisted', async function () {
this.timeout(40000)
- await servers[0].blacklistCommand.remove({ videoId: videoUUID })
+ await servers[0].blacklist.remove({ videoId: videoUUID })
await waitJobs(servers)
}
}
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
- await servers[0].blacklistCommand.remove({ videoId: uuid })
+ await servers[0].blacklist.remove({ videoId: uuid })
await waitJobs(servers)
await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist')
}
}
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
await wait(6000)
await checkVideoIsPublished(userBaseParams, name, uuid, 'absence')
const name = 'video without auto-blacklist ' + buildUUID()
// admin with blacklist right will not be auto-blacklisted
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name } })
await waitJobs(servers)
await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence')
})
after(async () => {
- await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig })
+ await servers[0].config.updateCustomConfig({ newCustomConfig: currentCustomConfig })
- await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
- await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
})
})
userNotifications = res.userNotifications
server = res.servers[0]
- await server.subscriptionsCommand.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port })
+ await server.subscriptions.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port })
for (let i = 0; i < 10; i++) {
- await server.videosCommand.randomUpload({ wait: false })
+ await server.videos.randomUpload({ wait: false })
}
await waitJobs([ server ])
describe('Mark as read', function () {
it('Should mark as read some notifications', async function () {
- const { data } = await server.notificationsCommand.list({ token: userToken, start: 2, count: 3 })
+ const { data } = await server.notifications.list({ token: userToken, start: 2, count: 3 })
const ids = data.map(n => n.id)
- await server.notificationsCommand.markAsRead({ token: userToken, ids })
+ await server.notifications.markAsRead({ token: userToken, ids })
})
it('Should have the notifications marked as read', async function () {
- const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10 })
+ const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10 })
expect(data[0].read).to.be.false
expect(data[1].read).to.be.false
})
it('Should only list read notifications', async function () {
- const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: false })
+ const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: false })
for (const notification of data) {
expect(notification.read).to.be.true
})
it('Should only list unread notifications', async function () {
- const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true })
+ const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: true })
for (const notification of data) {
expect(notification.read).to.be.false
})
it('Should mark as read all notifications', async function () {
- await server.notificationsCommand.markAsReadAll({ token: userToken })
+ await server.notifications.markAsReadAll({ token: userToken })
- const body = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true })
+ const body = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: true })
expect(body.total).to.equal(0)
expect(body.data).to.have.lengthOf(0)
it('Should not have notifications', async function () {
this.timeout(20000)
- await server.notificationsCommand.updateMySettings({
+ await server.notifications.updateMySettings({
token: userToken,
settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.NONE }
})
{
- const info = await server.usersCommand.getMyInfo({ token: userToken })
+ const info = await server.users.getMyInfo({ token: userToken })
expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE)
}
- const { name, uuid } = await server.videosCommand.randomUpload()
+ const { name, uuid } = await server.videos.randomUpload()
const check = { web: true, mail: true }
await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
it('Should only have web notifications', async function () {
this.timeout(20000)
- await server.notificationsCommand.updateMySettings({
+ await server.notifications.updateMySettings({
token: userToken,
settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.WEB }
})
{
- const info = await server.usersCommand.getMyInfo({ token: userToken })
+ const info = await server.users.getMyInfo({ token: userToken })
expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
}
- const { name, uuid } = await server.videosCommand.randomUpload()
+ const { name, uuid } = await server.videos.randomUpload()
{
const check = { mail: true, web: false }
it('Should only have mail notifications', async function () {
this.timeout(20000)
- await server.notificationsCommand.updateMySettings({
+ await server.notifications.updateMySettings({
token: userToken,
settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.EMAIL }
})
{
- const info = await server.usersCommand.getMyInfo({ token: userToken })
+ const info = await server.users.getMyInfo({ token: userToken })
expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL)
}
- const { name, uuid } = await server.videosCommand.randomUpload()
+ const { name, uuid } = await server.videos.randomUpload()
{
const check = { mail: false, web: true }
it('Should have email and web notifications', async function () {
this.timeout(20000)
- await server.notificationsCommand.updateMySettings({
+ await server.notifications.updateMySettings({
token: userToken,
settings: {
...getAllNotificationsSettings(),
})
{
- const info = await server.usersCommand.getMyInfo({ token: userToken })
+ const info = await server.users.getMyInfo({ token: userToken })
expect(info.notificationSettings.newVideoFromSubscription).to.equal(
UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
)
}
- const { name, uuid } = await server.videosCommand.randomUpload()
+ const { name, uuid } = await server.videos.randomUpload()
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
})
await uploadRandomVideoOnServers(servers, 1)
- const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken })
+ const notification = await servers[0].notifications.getLastest({ token: userAccessToken })
expect(notification).to.be.undefined
expect(emails).to.have.lengthOf(0)
it('Should send a new video notification if the user follows the local video publisher', async function () {
this.timeout(15000)
- await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
await waitJobs(servers)
const { name, uuid } = await uploadRandomVideoOnServers(servers, 1)
it('Should send a new video notification from a remote account', async function () {
this.timeout(150000) // Server 2 has transcoding enabled
- await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port })
+ await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port })
await waitJobs(servers)
const { name, uuid } = await uploadRandomVideoOnServers(servers, 2)
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
- await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
+ await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
await waitJobs(servers)
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
- await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
+ await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
await waitJobs(servers)
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
const data = { privacy: VideoPrivacy.PRIVATE }
const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data)
- await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
+ await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
})
const data = { privacy: VideoPrivacy.PRIVATE }
const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data)
- await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
+ await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
await waitJobs(servers)
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
privacy: VideoPrivacy.PUBLIC,
targetUrl: ImportsCommand.getGoodVideoUrl()
}
- const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video } = await servers[0].imports.importVideo({ attributes })
await waitJobs(servers)
await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false })
await waitJobs(servers)
- const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken })
+ const notification = await servers[0].notifications.getLastest({ token: userAccessToken })
if (notification) {
expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED)
}
targetUrl: ImportsCommand.getGoodVideoUrl(),
waitTranscoding: true
}
- const { video } = await servers[1].importsCommand.importVideo({ attributes })
+ const { video } = await servers[1].imports.importVideo({ attributes })
await waitJobs(servers)
await checkVideoIsPublished(baseParams, name, video.uuid, 'presence')
privacy: VideoPrivacy.PRIVATE,
targetUrl: ImportsCommand.getBadVideoUrl()
}
- const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video } = await servers[0].imports.importVideo({ attributes })
await waitJobs(servers)
await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence')
privacy: VideoPrivacy.PRIVATE,
targetUrl: ImportsCommand.getGoodVideoUrl()
}
- const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video } = await servers[0].imports.importVideo({ attributes })
await waitJobs(servers)
await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence')
token: userAccessToken
}
- await servers[0].usersCommand.updateMe({ displayName: 'super root name' })
+ await servers[0].users.updateMe({ displayName: 'super root name' })
- await servers[0].usersCommand.updateMe({
+ await servers[0].users.updateMe({
token: userAccessToken,
displayName: myUserName
})
- await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' })
+ await servers[1].users.updateMe({ displayName: 'super root 2 name' })
- await servers[0].channelsCommand.update({
+ await servers[0].channels.update({
token: userAccessToken,
channelName: 'user_1_channel',
attributes: { displayName: myChannelName }
it('Should notify when a local channel is following one of our channel', async function () {
this.timeout(50000)
- await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
await waitJobs(servers)
await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence')
- await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
})
it('Should notify when a remote channel is following one of our channel', async function () {
this.timeout(50000)
- await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
await waitJobs(servers)
await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence')
- await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
})
// PeerTube does not support accout -> account follows
// Get the access tokens
await setAccessTokensToServers(servers)
- commands = servers.map(s => s.redundancyCommand)
+ commands = servers.map(s => s.redundancy)
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
video1Server2UUID = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2' } })
video2Server2UUID = uuid
}
this.timeout(120000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 10)
+ await servers[0].servers.waitUntilLog('Duplicated ', 10)
await waitJobs(servers)
const body = await commands[1].listVideos({ target: 'remote-videos' })
it('Should manually add a redundancy and list it', async function () {
this.timeout(120000)
- const uuid = (await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid
+ const uuid = (await servers[1].videos.quickUpload({ name: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid
await waitJobs(servers)
- const videoId = await servers[0].videosCommand.getId({ uuid })
+ const videoId = await servers[0].videos.getId({ uuid })
await commands[0].addVideo({ videoId })
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 15)
+ await servers[0].servers.waitUntilLog('Duplicated ', 15)
await waitJobs(servers)
{
async function uploadWrapper (videoName: string) {
// Wait for transcoding
- const { id } = await localServer.videosCommand.upload({ attributes: { name: 'to transcode', privacy: VideoPrivacy.PRIVATE } })
+ const { id } = await localServer.videos.upload({ attributes: { name: 'to transcode', privacy: VideoPrivacy.PRIVATE } })
await waitJobs([ localServer ])
// Update video to schedule a federation
- await localServer.videosCommand.update({ id, attributes: { name: videoName, privacy: VideoPrivacy.PUBLIC } })
+ await localServer.videos.update({ id, attributes: { name: videoName, privacy: VideoPrivacy.PUBLIC } })
}
async function getTotalRedundanciesLocalServer () {
- const body = await localServer.redundancyCommand.listVideos({ target: 'my-videos' })
+ const body = await localServer.redundancy.listVideos({ target: 'my-videos' })
return body.total
}
async function getTotalRedundanciesRemoteServer () {
- const body = await remoteServer.redundancyCommand.listVideos({ target: 'remote-videos' })
+ const body = await remoteServer.redundancy.listVideos({ target: 'remote-videos' })
return body.total
}
// Get the access tokens
await setAccessTokensToServers(servers)
- await localServer.videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
+ await localServer.videos.upload({ attributes: { name: 'video 1 server 2' } })
await waitJobs(servers)
// Server 1 and server 2 follow each other
- await remoteServer.followsCommand.follow({ targets: [ localServer.url ] })
+ await remoteServer.follows.follow({ targets: [ localServer.url ] })
await waitJobs(servers)
- await remoteServer.redundancyCommand.updateRedundancy({ host: localServer.host, redundancyAllowed: true })
+ await remoteServer.redundancy.updateRedundancy({ host: localServer.host, redundancyAllowed: true })
await waitJobs(servers)
})
this.timeout(120000)
await waitJobs(servers)
- await remoteServer.serversCommand.waitUntilLog('Duplicated ', 5)
+ await remoteServer.servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
{
await uploadWrapper('video 2 server 2')
- await remoteServer.serversCommand.waitUntilLog('Duplicated ', 10)
+ await remoteServer.servers.waitUntilLog('Duplicated ', 10)
await waitJobs(servers)
{
await uploadWrapper('video 3 server 2')
- await remoteServer.serversCommand.waitUntilLog('Duplicated ', 15)
+ await remoteServer.servers.waitUntilLog('Duplicated ', 15)
await waitJobs(servers)
{
it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () {
this.timeout(120000)
- await localServer.followsCommand.follow({ targets: [ remoteServer.url ] })
+ await localServer.follows.follow({ targets: [ remoteServer.url ] })
await waitJobs(servers)
await uploadWrapper('video 4 server 2')
- await remoteServer.serversCommand.waitUntilLog('Duplicated ', 20)
+ await remoteServer.servers.waitUntilLog('Duplicated ', 20)
await waitJobs(servers)
{
await setAccessTokensToServers(servers)
{
- const { uuid, id } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
+ const { uuid, id } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
video1Server2UUID = uuid
video1Server2Id = id
- await servers[1].videosCommand.view({ id: video1Server2UUID })
+ await servers[1].videos.view({ id: video1Server2UUID })
}
await waitJobs(servers)
for (const server of servers) {
// With token to avoid issues with video follow constraints
- const video = await server.videosCommand.getWithToken({ id: videoUUID })
+ const video = await server.videos.getWithToken({ id: videoUUID })
for (const f of video.files) {
checkMagnetWebseeds(f, webseeds, server)
]
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
for (const file of video.files) {
checkMagnetWebseeds(file, webseeds, server)
for (const server of servers) {
// With token to avoid issues with video follow constraints
- const video = await server.videosCommand.getWithToken({ id: videoUUID })
+ const video = await server.videos.getWithToken({ id: videoUUID })
expect(video.streamingPlaylists).to.be.an('array')
expect(video.streamingPlaylists).to.have.lengthOf(1)
if (!videoUUID) videoUUID = video1Server2UUID
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
expect(video.streamingPlaylists).to.have.lengthOf(1)
expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1)
const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls'
const baseUrlSegment = servers[0].url + '/static/redundancy/hls'
- const video = await servers[0].videosCommand.get({ id: videoUUID })
+ const video = await servers[0].videos.get({ id: videoUUID })
const hlsPlaylist = video.streamingPlaylists[0]
for (const resolution of [ 240, 360, 480, 720 ]) {
statsLength = 2
}
- const data = await servers[0].statsCommand.get()
+ const data = await servers[0].stats.get()
expect(data.videosRedundancy).to.have.lengthOf(statsLength)
const stat = data.videosRedundancy[0]
}
async function findServerFollows () {
- const body = await servers[0].followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
+ const body = await servers[0].follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
const follows = body.data
const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
}
async function enableRedundancyOnServer1 () {
- await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: true })
+ await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: true })
const { server2, server3 } = await findServerFollows()
}
async function disableRedundancyOnServer1 () {
- await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: false })
+ await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: false })
const { server2, server3 } = await findServerFollows()
this.timeout(80000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds()
this.timeout(80000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds()
it('Should unfollow on server 1 and remove duplicated videos', async function () {
this.timeout(80000)
- await servers[0].followsCommand.unfollow({ target: servers[1] })
+ await servers[0].follows.unfollow({ target: servers[1] })
await waitJobs(servers)
await wait(5000)
it('Should view 2 times the first video to have > min_views config', async function () {
this.timeout(80000)
- await servers[0].videosCommand.view({ id: video1Server2UUID })
- await servers[2].videosCommand.view({ id: video1Server2UUID })
+ await servers[0].videos.view({ id: video1Server2UUID })
+ await servers[2].videos.view({ id: video1Server2UUID })
await wait(10000)
await waitJobs(servers)
this.timeout(80000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds()
it('Should remove the video and the redundancy files', async function () {
this.timeout(20000)
- await servers[1].videosCommand.remove({ id: video1Server2UUID })
+ await servers[1].videos.remove({ id: video1Server2UUID })
await waitJobs(servers)
it('Should have 1 redundancy on the first video', async function () {
this.timeout(160000)
- await servers[0].videosCommand.view({ id: video1Server2UUID })
- await servers[2].videosCommand.view({ id: video1Server2UUID })
+ await servers[0].videos.view({ id: video1Server2UUID })
+ await servers[2].videos.view({ id: video1Server2UUID })
await wait(10000)
await waitJobs(servers)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 1)
+ await servers[0].servers.waitUntilLog('Duplicated ', 1)
await waitJobs(servers)
await check1PlaylistRedundancies()
it('Should remove the video and the redundancy files', async function () {
this.timeout(20000)
- await servers[1].videosCommand.remove({ id: video1Server2UUID })
+ await servers[1].videos.remove({ id: video1Server2UUID })
await waitJobs(servers)
})
it('Should create a redundancy on first video', async function () {
- await servers[0].redundancyCommand.addVideo({ videoId: video1Server2Id })
+ await servers[0].redundancy.addVideo({ videoId: video1Server2Id })
})
it('Should have 2 webseeds on the first video', async function () {
this.timeout(80000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds()
it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () {
this.timeout(80000)
- const body = await servers[0].redundancyCommand.listVideos({ target: 'remote-videos' })
+ const body = await servers[0].redundancy.listVideos({ target: 'remote-videos' })
const videos = body.data
expect(videos).to.have.lengthOf(1)
const video = videos[0]
for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) {
- await servers[0].redundancyCommand.removeVideo({ redundancyId: r.id })
+ await servers[0].redundancy.removeVideo({ redundancyId: r.id })
}
await waitJobs(servers)
async function checkContains (servers: ServerInfo[], str: string) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: video1Server2UUID })
+ const video = await server.videos.get({ id: video1Server2UUID })
for (const f of video.files) {
expect(f.magnetUri).to.contain(str)
async function checkNotContains (servers: ServerInfo[], str: string) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: video1Server2UUID })
+ const video = await server.videos.get({ id: video1Server2UUID })
for (const f of video.files) {
expect(f.magnetUri).to.not.contain(str)
await enableRedundancyOnServer1()
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds(video1Server2UUID)
await check1PlaylistRedundancies(video1Server2UUID)
await checkStatsWith1Redundancy(strategy)
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } })
video2Server2UUID = uuid
// Wait transcoding before federation
await waitJobs(servers)
- await servers[1].videosCommand.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } })
+ await servers[1].videos.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } })
})
it('Should cache video 2 webseeds on the first video', async function () {
await setAccessTokensToServers(servers)
{
- await servers[0].usersCommand.create({ username: 'user1_server1', password: 'password' })
+ await servers[0].users.create({ username: 'user1_server1', password: 'password' })
const channel = {
name: 'channel1_server1',
displayName: 'Channel 1 server 1'
}
- await servers[0].channelsCommand.create({ attributes: channel })
+ await servers[0].channels.create({ attributes: channel })
}
{
const user = { username: 'user1_server2', password: 'password' }
- await servers[1].usersCommand.create({ username: user.username, password: user.password })
- userServer2Token = await servers[1].loginCommand.getAccessToken(user)
+ await servers[1].users.create({ username: user.username, password: user.password })
+ userServer2Token = await servers[1].login.getAccessToken(user)
const channel = {
name: 'channel1_server2',
displayName: 'Channel 1 server 2'
}
- const created = await servers[1].channelsCommand.create({ token: userServer2Token, attributes: channel })
+ const created = await servers[1].channels.create({ token: userServer2Token, attributes: channel })
channelIdServer2 = created.id
const attributes = { name: 'video 1 server 2', channelId: channelIdServer2 }
- const { uuid } = await servers[1].videosCommand.upload({ token: userServer2Token, attributes })
+ const { uuid } = await servers[1].videos.upload({ token: userServer2Token, attributes })
videoServer2UUID = uuid
}
await waitJobs(servers)
- command = servers[0].searchCommand
+ command = servers[0].search
})
it('Should not find a remote video channel', async function () {
})
it('Should not list this remote video channel', async function () {
- const body = await servers[0].channelsCommand.list()
+ const body = await servers[0].channels.list()
expect(body.total).to.equal(3)
expect(body.data).to.have.lengthOf(3)
expect(body.data[0].name).to.equal('channel1_server1')
await waitJobs(servers)
- const { total, data } = await servers[0].videosCommand.listByChannel({
+ const { total, data } = await servers[0].videos.listByChannel({
token: null,
videoChannelName: 'channel1_server2@localhost:' + servers[1].port
})
})
it('Should list video channel videos of server 2 with token', async function () {
- const { total, data } = await servers[0].videosCommand.listByChannel({
+ const { total, data } = await servers[0].videos.listByChannel({
videoChannelName: 'channel1_server2@localhost:' + servers[1].port
})
it('Should update video channel of server 2, and refresh it on server 1', async function () {
this.timeout(60000)
- await servers[1].channelsCommand.update({
+ await servers[1].channels.update({
token: userServer2Token,
channelName: 'channel1_server2',
attributes: { displayName: 'channel updated' }
})
- await servers[1].usersCommand.updateMe({ token: userServer2Token, displayName: 'user updated' })
+ await servers[1].users.updateMe({ token: userServer2Token, displayName: 'user updated' })
await waitJobs(servers)
// Expire video channel
it('Should update and add a video on server 2, and update it on server 1 after a search', async function () {
this.timeout(60000)
- await servers[1].videosCommand.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } })
- await servers[1].videosCommand.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } })
+ await servers[1].videos.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } })
+ await servers[1].videos.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } })
await waitJobs(servers)
await waitJobs(servers)
const videoChannelName = 'channel1_server2@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName, sort: '-createdAt' })
+ const { total, data } = await servers[0].videos.listByChannel({ videoChannelName, sort: '-createdAt' })
expect(total).to.equal(2)
expect(data[0].name).to.equal('video 2 server 2')
it('Should delete video channel of server 2, and delete it on server 1', async function () {
this.timeout(60000)
- await servers[1].channelsCommand.delete({ token: userServer2Token, channelName: 'channel1_server2' })
+ await servers[1].channels.delete({ token: userServer2Token, channelName: 'channel1_server2' })
await waitJobs(servers)
// Expire video
await setDefaultVideoChannel(servers)
{
- const video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid
- const video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid
+ const video1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).uuid
+ const video2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).uuid
const attributes = {
displayName: 'playlist 1 on server 1',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[0].videoChannel.id
+ videoChannelId: servers[0].store.channel.id
}
- const created = await servers[0].playlistsCommand.create({ attributes })
+ const created = await servers[0].playlists.create({ attributes })
playlistServer1UUID = created.uuid
for (const videoId of [ video1, video2 ]) {
- await servers[0].playlistsCommand.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } })
+ await servers[0].playlists.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } })
}
}
{
- const videoId = (await servers[1].videosCommand.quickUpload({ name: 'video 1' })).uuid
- video2Server2 = (await servers[1].videosCommand.quickUpload({ name: 'video 2' })).uuid
+ const videoId = (await servers[1].videos.quickUpload({ name: 'video 1' })).uuid
+ video2Server2 = (await servers[1].videos.quickUpload({ name: 'video 2' })).uuid
const attributes = {
displayName: 'playlist 1 on server 2',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[1].videoChannel.id
+ videoChannelId: servers[1].store.channel.id
}
- const created = await servers[1].playlistsCommand.create({ attributes })
+ const created = await servers[1].playlists.create({ attributes })
playlistServer2UUID = created.uuid
- await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } })
+ await servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } })
}
await waitJobs(servers)
- command = servers[0].searchCommand
+ command = servers[0].search
})
it('Should not find a remote playlist', async function () {
})
it('Should not list this remote playlist', async function () {
- const body = await servers[0].playlistsCommand.list({ start: 0, count: 10 })
+ const body = await servers[0].playlists.list({ start: 0, count: 10 })
expect(body.total).to.equal(1)
expect(body.data).to.have.lengthOf(1)
expect(body.data[0].displayName).to.equal('playlist 1 on server 1')
it('Should update the playlist of server 2, and refresh it on server 1', async function () {
this.timeout(60000)
- await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } })
+ await servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } })
await waitJobs(servers)
// Expire playlist
it('Should delete playlist of server 2, and delete it on server 1', async function () {
this.timeout(60000)
- await servers[1].playlistsCommand.delete({ playlistId: playlistServer2UUID })
+ await servers[1].playlists.delete({ playlistId: playlistServer2UUID })
await waitJobs(servers)
// Expiration
await setAccessTokensToServers(servers)
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1 on server 1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 1 on server 1' } })
videoServer1UUID = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 on server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 1 on server 2' } })
videoServer2UUID = uuid
}
await waitJobs(servers)
- command = servers[0].searchCommand
+ command = servers[0].search
})
it('Should not find a remote video', async function () {
})
it('Should not list this remote video', async function () {
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
expect(data[0].name).to.equal('video 1 on server 1')
name: 'super_channel',
displayName: 'super channel'
}
- const created = await servers[1].channelsCommand.create({ attributes: channelAttributes })
+ const created = await servers[1].channels.create({ attributes: channelAttributes })
const videoChannelId = created.id
const attributes = {
privacy: VideoPrivacy.UNLISTED,
channelId: videoChannelId
}
- await servers[1].videosCommand.update({ id: videoServer2UUID, attributes })
+ await servers[1].videos.update({ id: videoServer2UUID, attributes })
await waitJobs(servers)
// Expire video
it('Should delete video of server 2, and delete it on server 1', async function () {
this.timeout(120000)
- await servers[1].videosCommand.remove({ id: videoServer2UUID })
+ await servers[1].videos.remove({ id: videoServer2UUID })
await waitJobs(servers)
// Expire video
await setAccessTokensToServers([ server ])
{
- await server.usersCommand.create({ username: 'user1', password: 'password' })
+ await server.users.create({ username: 'user1', password: 'password' })
const channel = {
name: 'squall_channel',
displayName: 'Squall channel'
}
- await server.channelsCommand.create({ attributes: channel })
+ await server.channels.create({ attributes: channel })
}
- command = server.searchCommand
+ command = server.search
})
it('Should make a simple search and not have results', async function () {
await setAccessTokensToServers([ server ])
- await server.videosCommand.upload({ attributes: { name: localVideoName } })
+ await server.videos.upload({ attributes: { name: localVideoName } })
- command = server.searchCommand
+ command = server.search
})
describe('Default search', async function () {
it('Should make a local videos search by default', async function () {
this.timeout(10000)
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
})
it('Should make an index videos search by default', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
})
it('Should make an index videos search if local search is disabled', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
let nsfwUUID: string
{
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'display' }
}
}
{
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'do_not_list' }
}
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
- const videoId = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
+ const videoId = (await server.videos.quickUpload({ name: 'video' })).uuid
{
const attributes = {
displayName: 'Dr. Kenzo Tenma hospital videos',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
- const created = await server.playlistsCommand.create({ attributes })
+ const created = await server.playlists.create({ attributes })
- await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } })
+ await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } })
}
{
const attributes = {
displayName: 'Johan & Anna Libert musics',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
- const created = await server.playlistsCommand.create({ attributes })
+ const created = await server.playlists.create({ attributes })
- await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } })
+ await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } })
}
{
const attributes = {
displayName: 'Inspector Lunge playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
- await server.playlistsCommand.create({ attributes })
+ await server.playlists.create({ attributes })
}
- command = server.searchCommand
+ command = server.search
})
it('Should make a simple search and not have results', async function () {
nsfw: false,
language: 'fr'
}
- await server.videosCommand.upload({ attributes: attributes1 })
+ await server.videos.upload({ attributes: attributes1 })
const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }
- await server.videosCommand.upload({ attributes: attributes2 })
+ await server.videos.upload({ attributes: attributes2 })
{
const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined }
- const { id, uuid } = await server.videosCommand.upload({ attributes: attributes3 })
+ const { id, uuid } = await server.videos.upload({ attributes: attributes3 })
videoUUID = uuid
- await server.captionsCommand.createVideoCaption({
+ await server.captions.createVideoCaption({
language: 'en',
videoId: id,
fixture: 'subtitle-good2.vtt',
mimeType: 'application/octet-stream'
})
- await server.captionsCommand.createVideoCaption({
+ await server.captions.createVideoCaption({
language: 'aa',
videoId: id,
fixture: 'subtitle-good2.vtt',
}
const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true }
- await server.videosCommand.upload({ attributes: attributes4 })
+ await server.videos.upload({ attributes: attributes4 })
await wait(1000)
startDate = new Date().toISOString()
const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined }
- await server.videosCommand.upload({ attributes: attributes5 })
+ await server.videos.upload({ attributes: attributes5 })
const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }
- await server.videosCommand.upload({ attributes: attributes6 })
+ await server.videos.upload({ attributes: attributes6 })
const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' }
- await server.videosCommand.upload({ attributes: attributes7 })
+ await server.videos.upload({ attributes: attributes7 })
const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 }
- await server.videosCommand.upload({ attributes: attributes8 })
+ await server.videos.upload({ attributes: attributes8 })
}
{
licence: 2,
language: 'en'
}
- await server.videosCommand.upload({ attributes: attributes })
+ await server.videos.upload({ attributes: attributes })
- await server.videosCommand.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } })
+ await server.videos.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } })
}
{
licence: 3,
language: 'pl'
}
- await server.videosCommand.upload({ attributes: attributes })
+ await server.videos.upload({ attributes: attributes })
}
{
tags: [ 'aaaa', 'bbbb', 'cccc' ],
category: 1
}
- await server.videosCommand.upload({ attributes: attributes1 })
- await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } })
+ await server.videos.upload({ attributes: attributes1 })
+ await server.videos.upload({ attributes: { ...attributes1, category: 2 } })
- await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } })
- await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } })
+ await server.videos.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } })
+ await server.videos.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } })
}
{
name: 'aaaa 2',
category: 1
}
- await server.videosCommand.upload({ attributes: attributes1 })
- await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } })
+ await server.videos.upload({ attributes: attributes1 })
+ await server.videos.upload({ attributes: { ...attributes1, category: 2 } })
}
- command = server.searchCommand
+ command = server.search
})
it('Should make a simple search and not have results', async function () {
},
live: { enabled: true }
}
- await server.configCommand.updateCustomSubConfig({ newConfig })
+ await server.config.updateCustomSubConfig({ newConfig })
}
{
}
{
- const liveCommand = server.liveCommand
+ const liveCommand = server.live
- const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id }
+ const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.store.channel.id }
const live = await liveCommand.create({ fields: liveAttributes })
const ffmpegCommand = await liveCommand.sendRTMPStreamInVideo({ videoId: live.id })
async function checkFollow (follower: ServerInfo, following: ServerInfo, exists: boolean) {
{
- const body = await following.followsCommand.getFollowers({ start: 0, count: 5, sort: '-createdAt' })
+ const body = await following.follows.getFollowers({ start: 0, count: 5, sort: '-createdAt' })
const follow = body.data.find(f => f.follower.host === follower.host && f.state === 'accepted')
if (exists === true) expect(follow).to.exist
}
{
- const body = await follower.followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
+ const body = await follower.follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
const follow = body.data.find(f => f.following.host === following.host && f.state === 'accepted')
if (exists === true) expect(follow).to.exist
}
async function server1Follows2 (servers: ServerInfo[]) {
- await servers[0].followsCommand.follow({ targets: [ servers[1].host ] })
+ await servers[0].follows.follow({ targets: [ servers[1].host ] })
await waitJobs(servers)
}
async function resetFollows (servers: ServerInfo[]) {
try {
- await servers[0].followsCommand.unfollow({ target: servers[1] })
- await servers[1].followsCommand.unfollow({ target: servers[0] })
+ await servers[0].follows.unfollow({ target: servers[1] })
+ await servers[1].follows.unfollow({ target: servers[0] })
} catch { /* empty */
}
}
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[1].config.updateCustomSubConfig({ newConfig: config })
await server1Follows2(servers)
}
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[1].config.updateCustomSubConfig({ newConfig: config })
await server1Follows2(servers)
await checkFollow(servers[0], servers[1], false)
await checkFollow(servers[1], servers[0], false)
- await servers[1].followsCommand.acceptFollower({ follower: 'peertube@' + servers[0].host })
+ await servers[1].follows.acceptFollower({ follower: 'peertube@' + servers[0].host })
await waitJobs(servers)
await checkFollow(servers[0], servers[1], true)
config.followings.instance.autoFollowBack.enabled = false
config.followers.instance.manualApproval = false
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[1].config.updateCustomSubConfig({ newConfig: config })
})
})
}
}
}
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)
{
const user = { username: 'user1', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- user1Token = await servers[0].loginCommand.getAccessToken(user)
+ user1Token = await servers[0].login.getAccessToken(user)
}
{
const user = { username: 'user2', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- user2Token = await servers[0].loginCommand.getAccessToken(user)
+ user2Token = await servers[0].login.getAccessToken(user)
}
{
const user = { username: 'user3', password: 'password' }
- await servers[1].usersCommand.create({ username: user.username, password: user.password })
+ await servers[1].users.create({ username: user.username, password: user.password })
- user3Token = await servers[1].loginCommand.getAccessToken(user)
+ user3Token = await servers[1].login.getAccessToken(user)
}
await doubleFollow(servers[0], servers[1])
describe('Bulk remove comments', function () {
async function checkInstanceCommentsRemoved () {
{
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
// Server 1 should not have these comments anymore
for (const video of data) {
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: video.id })
+ const { data } = await servers[0].comments.listThreads({ videoId: video.id })
const comment = data.find(c => c.text === 'comment by user 3')
expect(comment).to.not.exist
}
{
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
// Server 1 should not have these comments on videos of server 1
for (const video of data) {
- const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.id })
+ const { data } = await servers[1].comments.listThreads({ videoId: video.id })
const comment = data.find(c => c.text === 'comment by user 3')
if (video.account.host === 'localhost:' + servers[0].port) {
before(async function () {
this.timeout(120000)
- await servers[0].videosCommand.upload({ attributes: { name: 'video 1 server 1' } })
- await servers[0].videosCommand.upload({ attributes: { name: 'video 2 server 1' } })
- await servers[0].videosCommand.upload({ token: user1Token, attributes: { name: 'video 3 server 1' } })
+ await servers[0].videos.upload({ attributes: { name: 'video 1 server 1' } })
+ await servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } })
+ await servers[0].videos.upload({ token: user1Token, attributes: { name: 'video 3 server 1' } })
- await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
+ await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
await waitJobs(servers)
{
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
for (const video of data) {
- await servers[0].commentsCommand.createThread({ videoId: video.id, text: 'comment by root server 1' })
- await servers[0].commentsCommand.createThread({ token: user1Token, videoId: video.id, text: 'comment by user 1' })
- await servers[0].commentsCommand.createThread({ token: user2Token, videoId: video.id, text: 'comment by user 2' })
+ await servers[0].comments.createThread({ videoId: video.id, text: 'comment by root server 1' })
+ await servers[0].comments.createThread({ token: user1Token, videoId: video.id, text: 'comment by user 1' })
+ await servers[0].comments.createThread({ token: user2Token, videoId: video.id, text: 'comment by user 2' })
}
}
{
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
for (const video of data) {
- await servers[1].commentsCommand.createThread({ videoId: video.id, text: 'comment by root server 2' })
+ await servers[1].comments.createThread({ videoId: video.id, text: 'comment by root server 2' })
- const comment = await servers[1].commentsCommand.createThread({ token: user3Token, videoId: video.id, text: 'comment by user 3' })
+ const comment = await servers[1].comments.createThread({ token: user3Token, videoId: video.id, text: 'comment by user 3' })
commentsUser3.push({ videoId: video.id, commentId: comment.id })
}
}
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
for (const video of data) {
- const { data } = await server.commentsCommand.listThreads({ videoId: video.id })
+ const { data } = await server.comments.listThreads({ videoId: video.id })
const comment = data.find(c => c.text === 'comment by user 2')
if (video.name === 'video 3 server 1') expect(comment).to.not.exist
this.timeout(60000)
for (const obj of commentsUser3) {
- await servers[1].commentsCommand.addReply({
+ await servers[1].comments.addReply({
token: user3Token,
videoId: obj.videoId,
toCommentId: obj.commentId,
})
it('Should have a correct config on a server with registration enabled', async function () {
- const data = await server.configCommand.getConfig()
+ const data = await server.config.getConfig()
expect(data.signup.allowed).to.be.true
})
this.timeout(5000)
await Promise.all([
- server.usersCommand.register({ username: 'user1' }),
- server.usersCommand.register({ username: 'user2' }),
- server.usersCommand.register({ username: 'user3' })
+ server.users.register({ username: 'user1' }),
+ server.users.register({ username: 'user2' }),
+ server.users.register({ username: 'user3' })
])
- const data = await server.configCommand.getConfig()
+ const data = await server.config.getConfig()
expect(data.signup.allowed).to.be.false
})
it('Should have the correct video allowed extensions', async function () {
- const data = await server.configCommand.getConfig()
+ const data = await server.config.getConfig()
expect(data.video.file.extensions).to.have.lengthOf(3)
expect(data.video.file.extensions).to.contain('.mp4')
expect(data.video.file.extensions).to.contain('.webm')
expect(data.video.file.extensions).to.contain('.ogv')
- await server.videosCommand.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
- await server.videosCommand.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
+ await server.videos.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
+ await server.videos.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
expect(data.contactForm.enabled).to.be.true
})
it('Should get the customized configuration', async function () {
- const data = await server.configCommand.getCustomConfig()
+ const data = await server.config.getCustomConfig()
checkInitialConfig(server, data)
})
}
}
}
- await server.configCommand.updateCustomConfig({ newCustomConfig })
+ await server.config.updateCustomConfig({ newCustomConfig })
- const data = await server.configCommand.getCustomConfig()
+ const data = await server.config.getCustomConfig()
checkUpdatedConfig(data)
})
it('Should have the correct updated video allowed extensions', async function () {
this.timeout(10000)
- const data = await server.configCommand.getConfig()
+ const data = await server.config.getConfig()
expect(data.video.file.extensions).to.have.length.above(4)
expect(data.video.file.extensions).to.contain('.mp4')
expect(data.video.file.extensions).to.contain('.ogg')
expect(data.video.file.extensions).to.contain('.flac')
- await server.videosCommand.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.OK_200 })
- await server.videosCommand.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.OK_200 })
+ await server.videos.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.OK_200 })
+ await server.videos.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.OK_200 })
})
it('Should have the configuration updated after a restart', async function () {
await reRunServer(server)
- const data = await server.configCommand.getCustomConfig()
+ const data = await server.config.getCustomConfig()
checkUpdatedConfig(data)
})
it('Should fetch the about information', async function () {
- const data = await server.configCommand.getAbout()
+ const data = await server.config.getAbout()
expect(data.instance.name).to.equal('PeerTube updated')
expect(data.instance.shortDescription).to.equal('my short description')
it('Should remove the custom configuration', async function () {
this.timeout(10000)
- await server.configCommand.deleteCustomConfig()
+ await server.config.deleteCustomConfig()
- const data = await server.configCommand.getCustomConfig()
+ const data = await server.config.getCustomConfig()
checkInitialConfig(server, data)
})
server = await flushAndRunServer(1, overrideConfig)
await setAccessTokensToServers([ server ])
- command = server.contactFormCommand
+ command = server.contactForm
})
it('Should send a contact form', async function () {
await setAccessTokensToServers([ server ])
{
- const created = await server.usersCommand.create({ username: user.username, password: user.password })
+ const created = await server.users.create({ username: user.username, password: user.password })
userId = created.id
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ userAccessToken = await server.login.getAccessToken(user)
}
{
const attributes = { name: 'my super user video' }
- const { uuid } = await server.videosCommand.upload({ token: userAccessToken, attributes })
+ const { uuid } = await server.videos.upload({ token: userAccessToken, attributes })
videoUserUUID = uuid
}
const attributes = {
name: 'my super name'
}
- const { uuid, id } = await server.videosCommand.upload({ attributes })
+ const { uuid, id } = await server.videos.upload({ attributes })
videoUUID = uuid
videoId = id
}
it('Should ask to reset the password', async function () {
this.timeout(10000)
- await server.usersCommand.askResetPassword({ email: 'user_1@example.com' })
+ await server.users.askResetPassword({ email: 'user_1@example.com' })
await waitJobs(server)
expect(emails).to.have.lengthOf(1)
})
it('Should not reset the password with an invalid verification string', async function () {
- await server.usersCommand.resetPassword({
+ await server.users.resetPassword({
userId,
verificationString: verificationString + 'b',
password: 'super_password2',
})
it('Should reset the password', async function () {
- await server.usersCommand.resetPassword({ userId, verificationString, password: 'super_password2' })
+ await server.users.resetPassword({ userId, verificationString, password: 'super_password2' })
})
it('Should not reset the password with the same verification string', async function () {
- await server.usersCommand.resetPassword({
+ await server.users.resetPassword({
userId,
verificationString,
password: 'super_password3',
it('Should login with this new password', async function () {
user.password = 'super_password2'
- await server.loginCommand.getAccessToken(user)
+ await server.login.getAccessToken(user)
})
})
it('Should send a create password email', async function () {
this.timeout(10000)
- await server.usersCommand.create({ username: 'create_password', password: '' })
+ await server.users.create({ username: 'create_password', password: '' })
await waitJobs(server)
expect(emails).to.have.lengthOf(2)
})
it('Should not reset the password with an invalid verification string', async function () {
- await server.usersCommand.resetPassword({
+ await server.users.resetPassword({
userId: userId2,
verificationString: verificationString2 + 'c',
password: 'newly_created_password',
})
it('Should reset the password', async function () {
- await server.usersCommand.resetPassword({
+ await server.users.resetPassword({
userId: userId2,
verificationString: verificationString2,
password: 'newly_created_password'
})
it('Should login with this new password', async function () {
- await server.loginCommand.getAccessToken({
+ await server.login.getAccessToken({
username: 'create_password',
password: 'newly_created_password'
})
this.timeout(10000)
const reason = 'my super bad reason'
- await server.abusesCommand.report({ videoId, reason })
+ await server.abuses.report({ videoId, reason })
await waitJobs(server)
expect(emails).to.have.lengthOf(3)
this.timeout(10000)
const reason = 'my super bad reason'
- await server.usersCommand.banUser({ userId, reason })
+ await server.users.banUser({ userId, reason })
await waitJobs(server)
expect(emails).to.have.lengthOf(4)
it('Should send the notification email when unblocking a user', async function () {
this.timeout(10000)
- await server.usersCommand.unbanUser({ userId })
+ await server.users.unbanUser({ userId })
await waitJobs(server)
expect(emails).to.have.lengthOf(5)
this.timeout(10000)
const reason = 'my super reason'
- await server.blacklistCommand.add({ videoId: videoUserUUID, reason })
+ await server.blacklist.add({ videoId: videoUserUUID, reason })
await waitJobs(server)
expect(emails).to.have.lengthOf(6)
it('Should send the notification email', async function () {
this.timeout(10000)
- await server.blacklistCommand.remove({ videoId: videoUserUUID })
+ await server.blacklist.remove({ videoId: videoUserUUID })
await waitJobs(server)
expect(emails).to.have.lengthOf(7)
it('Should ask to send the verification email', async function () {
this.timeout(10000)
- await server.usersCommand.askSendVerifyEmail({ email: 'user_1@example.com' })
+ await server.users.askSendVerifyEmail({ email: 'user_1@example.com' })
await waitJobs(server)
expect(emails).to.have.lengthOf(8)
})
it('Should not verify the email with an invalid verification string', async function () {
- await server.usersCommand.verifyEmail({
+ await server.users.verifyEmail({
userId,
verificationString: verificationString + 'b',
isPendingEmail: false,
})
it('Should verify the email', async function () {
- await server.usersCommand.verifyEmail({ userId, verificationString })
+ await server.users.verifyEmail({ userId, verificationString })
})
})
await setAccessTokensToServers(servers)
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video server 1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video server 1' } })
video1UUID = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video server 2' } })
video2UUID = uuid
}
username: 'user1',
password: 'super_password'
}
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
- userToken = await servers[0].loginCommand.getAccessToken(user)
+ await servers[0].users.create({ username: user.username, password: user.password })
+ userToken = await servers[0].login.getAccessToken(user)
await doubleFollow(servers[0], servers[1])
})
describe('With an unlogged user', function () {
it('Should get the local video', async function () {
- await servers[0].videosCommand.get({ id: video1UUID })
+ await servers[0].videos.get({ id: video1UUID })
})
it('Should get the remote video', async function () {
- await servers[0].videosCommand.get({ id: video2UUID })
+ await servers[0].videos.get({ id: video2UUID })
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ accountName: 'root@localhost:' + servers[0].port })
+ const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ accountName: 'root@localhost:' + servers[1].port })
+ const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[1].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
it('Should list local channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
it('Should list remote channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
describe('With a logged user', function () {
it('Should get the local video', async function () {
- await servers[0].videosCommand.getWithToken({ token: userToken, id: video1UUID })
+ await servers[0].videos.getWithToken({ token: userToken, id: video1UUID })
})
it('Should get the remote video', async function () {
- await servers[0].videosCommand.getWithToken({ token: userToken, id: video2UUID })
+ await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
it('Should list local channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
it('Should list remote channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
before(async function () {
this.timeout(30000)
- await servers[0].followsCommand.unfollow({ target: servers[1] })
+ await servers[0].follows.unfollow({ target: servers[1] })
})
describe('With an unlogged user', function () {
it('Should get the local video', async function () {
- await servers[0].videosCommand.get({ id: video1UUID })
+ await servers[0].videos.get({ id: video1UUID })
})
it('Should not get the remote video', async function () {
- const body = await servers[0].videosCommand.get({ id: video2UUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ const body = await servers[0].videos.get({ id: video2UUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
const error = body as unknown as PeerTubeProblemDocument
const doc = 'https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/does_not_respect_follow_constraints'
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({
+ const { total, data } = await servers[0].videos.listByAccount({
token: undefined,
accountName: 'root@localhost:' + servers[0].port
})
})
it('Should not list remote account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({
+ const { total, data } = await servers[0].videos.listByAccount({
token: undefined,
accountName: 'root@localhost:' + servers[1].port
})
it('Should list local channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: undefined, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
it('Should not list remote channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: undefined, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
describe('With a logged user', function () {
it('Should get the local video', async function () {
- await servers[0].videosCommand.getWithToken({ token: userToken, id: video1UUID })
+ await servers[0].videos.getWithToken({ token: userToken, id: video1UUID })
})
it('Should get the remote video', async function () {
- await servers[0].videosCommand.getWithToken({ token: userToken, id: video2UUID })
+ await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
it('Should list local channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
it('Should list remote channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accepted') {
const fns = [
- servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand),
- servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand)
+ servers[0].follows.getFollowings.bind(servers[0].follows),
+ servers[1].follows.getFollowers.bind(servers[1].follows)
]
for (const fn of fns) {
async function checkNoFollowers (servers: ServerInfo[]) {
const fns = [
- servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand),
- servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand)
+ servers[0].follows.getFollowings.bind(servers[0].follows),
+ servers[1].follows.getFollowers.bind(servers[1].follows)
]
for (const fn of fns) {
// Get the access tokens
await setAccessTokensToServers(servers)
- commands = servers.map(s => s.followsCommand)
+ commands = servers.map(s => s.follows)
})
it('Should have server 1 following server 2', async function () {
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig })
+ await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
await commands[0].follow({ targets: [ servers[1].url ] })
await waitJobs(servers)
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig })
+ await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
await commands[0].follow({ targets: [ servers[1].url ] })
await waitJobs(servers)
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig })
- await servers[2].configCommand.updateCustomSubConfig({ newConfig: subConfig })
+ await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
+ await servers[2].config.updateCustomSubConfig({ newConfig: subConfig })
await commands[0].follow({ targets: [ servers[1].url ] })
await waitJobs(servers)
this.timeout(30000)
servers = await flushAndRunMultipleServers(3)
- followsCommands = servers.map(s => s.followsCommand)
+ followsCommands = servers.map(s => s.follows)
// Get the access tokens
await setAccessTokensToServers(servers)
it('Should not have followers', async function () {
for (const server of servers) {
- const body = await server.followsCommand.getFollowers({ start: 0, count: 5, sort: 'createdAt' })
+ const body = await server.follows.getFollowers({ start: 0, count: 5, sort: 'createdAt' })
expect(body.total).to.equal(0)
const follows = body.data
it('Should not have following', async function () {
for (const server of servers) {
- const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
+ const body = await server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
expect(body.total).to.equal(0)
const follows = body.data
it('Should have 0 followings on server 2 and 3', async function () {
for (const server of [ servers[1], servers[2] ]) {
- const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
+ const body = await server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
expect(body.total).to.equal(0)
const follows = body.data
it('Should have 1 followers on server 2 and 3', async function () {
for (const server of [ servers[1], servers[2] ]) {
- const body = await server.followsCommand.getFollowers({ start: 0, count: 1, sort: 'createdAt' })
+ const body = await server.follows.getFollowers({ start: 0, count: 1, sort: 'createdAt' })
expect(body.total).to.equal(1)
const follows = body.data
it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () {
this.timeout(60000)
- await servers[1].videosCommand.upload({ attributes: { name: 'server2' } })
- await servers[2].videosCommand.upload({ attributes: { name: 'server3' } })
+ await servers[1].videos.upload({ attributes: { name: 'server2' } })
+ await servers[2].videos.upload({ attributes: { name: 'server3' } })
await waitJobs(servers)
{
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(1)
expect(data[0].name).to.equal('server2')
}
{
- const { total, data } = await servers[1].videosCommand.list()
+ const { total, data } = await servers[1].videos.list()
expect(total).to.equal(1)
expect(data[0].name).to.equal('server2')
}
{
- const { total, data } = await servers[2].videosCommand.list()
+ const { total, data } = await servers[2].videos.list()
expect(total).to.equal(1)
expect(data[0].name).to.equal('server3')
}
tags: [ 'tag1', 'tag2', 'tag3' ]
}
- await servers[2].videosCommand.upload({ attributes: { name: 'server3-2' } })
- await servers[2].videosCommand.upload({ attributes: { name: 'server3-3' } })
- await servers[2].videosCommand.upload({ attributes: video4Attributes })
- await servers[2].videosCommand.upload({ attributes: { name: 'server3-5' } })
- await servers[2].videosCommand.upload({ attributes: { name: 'server3-6' } })
+ await servers[2].videos.upload({ attributes: { name: 'server3-2' } })
+ await servers[2].videos.upload({ attributes: { name: 'server3-3' } })
+ await servers[2].videos.upload({ attributes: video4Attributes })
+ await servers[2].videos.upload({ attributes: { name: 'server3-5' } })
+ await servers[2].videos.upload({ attributes: { name: 'server3-6' } })
{
- const userAccessToken = await servers[2].usersCommand.generateUserAndToken('captain')
+ const userAccessToken = await servers[2].users.generateUserAndToken('captain')
- const { data } = await servers[2].videosCommand.list()
+ const { data } = await servers[2].videos.list()
video4 = data.find(v => v.name === 'server3-4')
{
- await servers[2].videosCommand.rate({ id: video4.id, rating: 'like' })
- await servers[2].videosCommand.rate({ token: userAccessToken, id: video4.id, rating: 'dislike' })
+ await servers[2].videos.rate({ id: video4.id, rating: 'like' })
+ await servers[2].videos.rate({ token: userAccessToken, id: video4.id, rating: 'dislike' })
}
{
{
const text = 'my super first comment'
- const created = await servers[2].commentsCommand.createThread({ videoId: video4.id, text })
+ const created = await servers[2].comments.createThread({ videoId: video4.id, text })
const threadId = created.id
const text1 = 'my super answer to thread 1'
- const childComment = await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
+ const childComment = await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
const text2 = 'my super answer to answer of thread 1'
- await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text2 })
+ await servers[2].comments.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text2 })
const text3 = 'my second answer to thread 1'
- await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text3 })
+ await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text3 })
}
{
const text = 'will be deleted'
- const created = await servers[2].commentsCommand.createThread({ videoId: video4.id, text })
+ const created = await servers[2].comments.createThread({ videoId: video4.id, text })
const threadId = created.id
const text1 = 'answer to deleted'
- await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
+ await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
const text2 = 'will also be deleted'
- const childComment = await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text2 })
+ const childComment = await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text2 })
const text3 = 'my second answer to deleted'
- await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text3 })
+ await servers[2].comments.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text3 })
- await servers[2].commentsCommand.delete({ videoId: video4.id, commentId: threadId })
- await servers[2].commentsCommand.delete({ videoId: video4.id, commentId: childComment.id })
+ await servers[2].comments.delete({ videoId: video4.id, commentId: threadId })
+ await servers[2].comments.delete({ videoId: video4.id, commentId: childComment.id })
}
}
{
- await servers[2].captionsCommand.createVideoCaption({
+ await servers[2].captions.createVideoCaption({
language: 'ar',
videoId: video4.id,
fixture: 'subtitle-good2.vtt'
})
it('Should have propagated videos', async function () {
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(7)
const video2 = data.find(v => v.name === 'server3-2')
})
it('Should have propagated comments', async function () {
- const { total, data } = await servers[0].commentsCommand.listThreads({ videoId: video4.id, sort: 'createdAt' })
+ const { total, data } = await servers[0].comments.listThreads({ videoId: video4.id, sort: 'createdAt' })
expect(total).to.equal(2)
expect(data).to.be.an('array')
const threadId = comment.threadId
- const tree = await servers[0].commentsCommand.getThread({ videoId: video4.id, threadId })
+ const tree = await servers[0].comments.getThread({ videoId: video4.id, threadId })
expect(tree.comment.text).equal('my super first comment')
expect(tree.children).to.have.lengthOf(2)
expect(deletedComment.totalReplies).to.equal(2)
expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
- const tree = await servers[0].commentsCommand.getThread({ videoId: video4.id, threadId: deletedComment.threadId })
+ const tree = await servers[0].comments.getThread({ videoId: video4.id, threadId: deletedComment.threadId })
const [ commentRoot, deletedChildRoot ] = tree.children
expect(deletedChildRoot).to.not.be.undefined
})
it('Should have propagated captions', async function () {
- const body = await servers[0].captionsCommand.listVideoCaptions({ videoId: video4.id })
+ const body = await servers[0].captions.listVideoCaptions({ videoId: video4.id })
expect(body.total).to.equal(1)
expect(body.data).to.have.lengthOf(1)
await waitJobs(servers)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(1)
})
this.timeout(30000)
servers = await flushAndRunMultipleServers(3)
- commentCommands = servers.map(s => s.commentsCommand)
+ commentCommands = servers.map(s => s.comments)
checkAttributes = {
name: 'my super name for server 1',
this.timeout(240000)
// Server 2 and 3 follow server 1
- await servers[1].followsCommand.follow({ targets: [ servers[0].url ] })
- await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[1].follows.follow({ targets: [ servers[0].url ] })
+ await servers[2].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
// Upload a video to server 1
- await servers[0].videosCommand.upload({ attributes: videoAttributes })
+ await servers[0].videos.upload({ attributes: videoAttributes })
await waitJobs(servers)
// And check all servers have this video
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.be.an('array')
expect(data).to.have.lengthOf(1)
}
// Remove server 2 follower
for (let i = 0; i < 10; i++) {
- await servers[0].videosCommand.upload({ attributes: videoAttributes })
+ await servers[0].videos.upload({ attributes: videoAttributes })
}
await waitJobs([ servers[0], servers[2] ])
// Kill server 3
await killallServers([ servers[2] ])
- missedVideo1 = await servers[0].videosCommand.upload({ attributes: videoAttributes })
+ missedVideo1 = await servers[0].videos.upload({ attributes: videoAttributes })
- missedVideo2 = await servers[0].videosCommand.upload({ attributes: videoAttributes })
+ missedVideo2 = await servers[0].videos.upload({ attributes: videoAttributes })
// Unlisted video
- unlistedVideo = await servers[0].videosCommand.upload({ attributes: unlistedVideoAttributes })
+ unlistedVideo = await servers[0].videos.upload({ attributes: unlistedVideoAttributes })
// Add comments to video 2
{
await wait(11000)
// Only server 3 is still a follower of server 1
- const body = await servers[0].followsCommand.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
+ const body = await servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(1)
expect(body.data[0].follower.host).to.equal('localhost:' + servers[2].port)
const states: JobState[] = [ 'waiting', 'active' ]
for (const state of states) {
- const body = await servers[0].jobsCommand.getJobsList({
+ const body = await servers[0].jobs.getJobsList({
state: state,
start: 0,
count: 50,
await reRunServer(servers[1])
await reRunServer(servers[2])
- await servers[1].followsCommand.unfollow({ target: servers[0] })
+ await servers[1].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
- await servers[1].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[1].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
- const body = await servers[0].followsCommand.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
+ const body = await servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(2)
})
this.timeout(15000)
{
- const { data } = await servers[2].videosCommand.list()
+ const { data } = await servers[2].videos.list()
expect(data).to.be.an('array')
expect(data).to.have.lengthOf(11)
}
- await servers[0].videosCommand.update({ id: missedVideo1.uuid })
- await servers[0].videosCommand.update({ id: unlistedVideo.uuid })
+ await servers[0].videos.update({ id: missedVideo1.uuid })
+ await servers[0].videos.update({ id: unlistedVideo.uuid })
await waitJobs(servers)
{
- const { data } = await servers[2].videosCommand.list()
+ const { data } = await servers[2].videos.list()
expect(data).to.be.an('array')
// 1 video is unlisted
expect(data).to.have.lengthOf(12)
}
// Check unlisted video
- const video = await servers[2].videosCommand.get({ id: unlistedVideo.uuid })
+ const video = await servers[2].videos.get({ id: unlistedVideo.uuid })
await completeVideoCheck(servers[2], video, unlistedCheckAttributes)
})
await waitJobs(servers)
- await servers[2].videosCommand.get({ id: missedVideo2.uuid })
+ await servers[2].videos.get({ id: missedVideo2.uuid })
{
- const { data } = await servers[2].commentsCommand.listThreads({ videoId: missedVideo2.uuid })
+ const { data } = await servers[2].comments.listThreads({ videoId: missedVideo2.uuid })
expect(data).to.be.an('array')
expect(data).to.have.lengthOf(1)
threadIdServer2 = data[0].id
- const tree = await servers[2].commentsCommand.getThread({ videoId: missedVideo2.uuid, threadId: threadIdServer2 })
+ const tree = await servers[2].comments.getThread({ videoId: missedVideo2.uuid, threadId: threadIdServer2 })
expect(tree.comment.text).equal('thread 1')
expect(tree.children).to.have.lengthOf(1)
it('Should correctly reply to the comment', async function () {
this.timeout(15000)
- await servers[2].commentsCommand.addReply({ videoId: missedVideo2.uuid, toCommentId: commentIdServer2, text: 'comment 1-4' })
+ await servers[2].comments.addReply({ videoId: missedVideo2.uuid, toCommentId: commentIdServer2, text: 'comment 1-4' })
await waitJobs(servers)
this.timeout(120000)
for (let i = 0; i < 10; i++) {
- const uuid = (await servers[0].videosCommand.quickUpload({ name: 'video ' + i })).uuid
+ const uuid = (await servers[0].videos.quickUpload({ name: 'video ' + i })).uuid
videoIdsServer1.push(uuid)
}
await waitJobs(servers)
for (const id of videoIdsServer1) {
- await servers[1].videosCommand.get({ id })
+ await servers[1].videos.get({ id })
}
await waitJobs(servers)
- await servers[1].sqlCommand.setActorFollowScores(20)
+ await servers[1].sql.setActorFollowScores(20)
// Wait video expiration
await wait(11000)
// Refresh video -> score + 10 = 30
- await servers[1].videosCommand.get({ id: videoIdsServer1[0] })
+ await servers[1].videos.get({ id: videoIdsServer1[0] })
await waitJobs(servers)
})
for (let i = 0; i < 5; i++) {
try {
- await servers[1].videosCommand.get({ id: videoIdsServer1[i] })
+ await servers[1].videos.get({ id: videoIdsServer1[i] })
await waitJobs([ servers[1] ])
await wait(1500)
} catch {}
}
for (const id of videoIdsServer1) {
- await servers[1].videosCommand.get({ id, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[1].videos.get({ id, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
}
})
const expect = chai.expect
async function getHomepageState (server: ServerInfo) {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
return config.homepage.enabled
}
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- command = server.customPageCommand
+ command = server.customPage
})
it('Should not have a homepage', async function () {
it('Should create some jobs', async function () {
this.timeout(120000)
- await servers[1].videosCommand.upload({ attributes: { name: 'video1' } })
- await servers[1].videosCommand.upload({ attributes: { name: 'video2' } })
+ await servers[1].videos.upload({ attributes: { name: 'video1' } })
+ await servers[1].videos.upload({ attributes: { name: 'video2' } })
await waitJobs(servers)
})
it('Should list jobs', async function () {
- const body = await servers[1].jobsCommand.getJobsList({ state: 'completed' })
+ const body = await servers[1].jobs.getJobsList({ state: 'completed' })
expect(body.total).to.be.above(2)
expect(body.data).to.have.length.above(2)
})
it('Should list jobs with sort, pagination and job type', async function () {
{
- const body = await servers[1].jobsCommand.getJobsList({
+ const body = await servers[1].jobs.getJobsList({
state: 'completed',
start: 1,
count: 2,
}
{
- const body = await servers[1].jobsCommand.getJobsList({
+ const body = await servers[1].jobs.getJobsList({
state: 'completed',
start: 0,
count: 100,
})
it('Should list all jobs', async function () {
- const body = await servers[1].jobsCommand.getJobsList()
+ const body = await servers[1].jobs.getJobsList()
expect(body.total).to.be.above(2)
const jobs = body.data
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- logsCommand = server.logsCommand
+ logsCommand = server.logs
})
describe('With the standard log file', function () {
it('Should get logs with a start date', async function () {
this.timeout(20000)
- await server.videosCommand.upload({ attributes: { name: 'video 1' } })
+ await server.videos.upload({ attributes: { name: 'video 1' } })
await waitJobs([ server ])
const now = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 2' } })
+ await server.videos.upload({ attributes: { name: 'video 2' } })
await waitJobs([ server ])
const body = await logsCommand.getLogs({ startDate: now })
it('Should get logs with an end date', async function () {
this.timeout(30000)
- await server.videosCommand.upload({ attributes: { name: 'video 3' } })
+ await server.videos.upload({ attributes: { name: 'video 3' } })
await waitJobs([ server ])
const now1 = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 4' } })
+ await server.videos.upload({ attributes: { name: 'video 4' } })
await waitJobs([ server ])
const now2 = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 5' } })
+ await server.videos.upload({ attributes: { name: 'video 5' } })
await waitJobs([ server ])
const body = await logsCommand.getLogs({ startDate: now1, endDate: now2 })
const now = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 6' } })
+ await server.videos.upload({ attributes: { name: 'video 6' } })
await waitJobs([ server ])
{
const now = new Date()
- await server.serversCommand.ping()
+ await server.servers.ping()
const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
const logsString = JSON.stringify(body)
const now = new Date()
- await server.serversCommand.ping()
+ await server.servers.ping()
const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
const logsString = JSON.stringify(body)
it('Should get logs with a start date', async function () {
this.timeout(20000)
- await server.videosCommand.upload({ attributes: { name: 'video 7' } })
+ await server.videos.upload({ attributes: { name: 'video 7' } })
await waitJobs([ server ])
const now = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 8' } })
+ await server.videos.upload({ attributes: { name: 'video 8' } })
await waitJobs([ server ])
const body = await logsCommand.getAuditLogs({ startDate: now })
it('Should get logs with an end date', async function () {
this.timeout(30000)
- await server.videosCommand.upload({ attributes: { name: 'video 9' } })
+ await server.videos.upload({ attributes: { name: 'video 9' } })
await waitJobs([ server ])
const now1 = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 10' } })
+ await server.videos.upload({ attributes: { name: 'video 10' } })
await waitJobs([ server ])
const now2 = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 11' } })
+ await server.videos.upload({ attributes: { name: 'video 11' } })
await waitJobs([ server ])
const body = await logsCommand.getAuditLogs({ startDate: now1, endDate: now2 })
server = await flushAndRunServer(1, configOverride)
await setAccessTokensToServers([ server ])
- command = server.pluginsCommand
+ command = server.plugins
})
it('Should list and search available plugins and themes', async function () {
})
it('Should have the plugin loaded in the configuration', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const theme = config.theme.registered.find(r => r.name === 'background-red')
expect(theme).to.not.be.undefined
})
it('Should update the default theme in the configuration', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
theme: { default: 'background-red' }
}
})
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
expect(config.theme.default).to.equal('background-red')
})
it('Should update my default theme', async function () {
- await server.usersCommand.updateMe({ theme: 'background-red' })
+ await server.users.updateMe({ theme: 'background-red' })
- const user = await server.usersCommand.getMyInfo()
+ const user = await server.users.getMyInfo()
expect(user.theme).to.equal('background-red')
})
it('Should have watched settings changes', async function () {
this.timeout(10000)
- await server.serversCommand.waitUntilLog('Settings changed!')
+ await server.servers.waitUntilLog('Settings changed!')
})
it('Should get a plugin and a theme', async function () {
await wait(6000)
// Fake update our plugin version
- await server.sqlCommand.setPluginVersion('hello-world', '0.0.1')
+ await server.sql.setPluginVersion('hello-world', '0.0.1')
// Fake update package.json
const packageJSON = await command.getPackageJSON('peertube-plugin-hello-world')
})
it('Should have updated the configuration', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
expect(config.theme.default).to.equal('default')
})
it('Should have updated the user theme', async function () {
- const user = await server.usersCommand.getMyInfo()
+ const user = await server.users.getMyInfo()
expect(user.theme).to.equal('instance-default')
})
server = await flushAndRunServer(1, config)
await setAccessTokensToServers([ server ])
- const { uuid } = await server.videosCommand.upload()
+ const { uuid } = await server.videos.upload()
videoId = uuid
})
it('Should view a video only once with the same IP by default', async function () {
this.timeout(20000)
- await server.videosCommand.view({ id: videoId })
- await server.videosCommand.view({ id: videoId })
+ await server.videos.view({ id: videoId })
+ await server.videos.view({ id: videoId })
// Wait the repeatable job
await wait(8000)
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.views).to.equal(1)
})
it('Should view a video 2 times with the X-Forwarded-For header set', async function () {
this.timeout(20000)
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.1,127.0.0.1' })
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.2,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.1,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.2,127.0.0.1' })
// Wait the repeatable job
await wait(8000)
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.views).to.equal(3)
})
it('Should view a video only once with the same client IP in the X-Forwarded-For header', async function () {
this.timeout(20000)
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.4,0.0.0.3,::ffff:127.0.0.1' })
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.5,0.0.0.3,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.4,0.0.0.3,::ffff:127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.5,0.0.0.3,127.0.0.1' })
// Wait the repeatable job
await wait(8000)
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.views).to.equal(4)
})
it('Should view a video two times with a different client IP in the X-Forwarded-For header', async function () {
this.timeout(20000)
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.6,127.0.0.1' })
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.7,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.6,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.7,127.0.0.1' })
// Wait the repeatable job
await wait(8000)
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.views).to.equal(6)
})
const user = { username: 'root', password: 'fail' }
for (let i = 0; i < 19; i++) {
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+ await server.login.login({ user, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
})
it('Should rate limit signup', async function () {
for (let i = 0; i < 10; i++) {
try {
- await server.usersCommand.register({ username: 'test' + i })
+ await server.users.register({ username: 'test' + i })
} catch {
// empty
}
}
- await server.usersCommand.register({ username: 'test42', expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+ await server.users.register({ username: 'test42', expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
})
it('Should not rate limit failed signup', async function () {
await wait(7000)
for (let i = 0; i < 3; i++) {
- await server.usersCommand.register({ username: 'test' + i, expectedStatus: HttpStatusCode.CONFLICT_409 })
+ await server.users.register({ username: 'test' + i, expectedStatus: HttpStatusCode.CONFLICT_409 })
}
- await server.usersCommand.register({ username: 'test43', expectedStatus: HttpStatusCode.NO_CONTENT_204 })
+ await server.users.register({ username: 'test43', expectedStatus: HttpStatusCode.NO_CONTENT_204 })
})
for (let i = 0; i < 100; i++) {
try {
- await server.videosCommand.get({ id: videoId })
+ await server.videos.get({ id: videoId })
} catch {
// don't care if it fails
}
}
- await server.videosCommand.get({ id: videoId, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+ await server.videos.get({ id: videoId, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
})
after(async function () {
{
const attributes = { name: 'my super name' }
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
video = data[0]
}
{
- const created = await server.playlistsCommand.create({
+ const created = await server.playlists.create({
attributes: {
displayName: 'The Life and Times of Scrooge McDuck',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
})
playlistUUID = created.uuid
playlistDisplayName = 'The Life and Times of Scrooge McDuck'
- await server.playlistsCommand.addElement({
+ await server.playlists.addElement({
playlistId: created.id,
attributes: {
videoId: video.id
for (const basePath of [ '/videos/watch/', '/w/' ]) {
const oembedUrl = 'http://localhost:' + server.port + basePath + video.uuid
- const res = await server.servicesCommand.getOEmbed({ oembedUrl })
+ const res = await server.services.getOEmbed({ oembedUrl })
const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
`title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal(video.name)
- expect(res.body.author_name).to.equal(server.videoChannel.displayName)
+ expect(res.body.author_name).to.equal(server.store.channel.displayName)
expect(res.body.width).to.equal(560)
expect(res.body.height).to.equal(315)
expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
for (const basePath of [ '/videos/watch/playlist/', '/w/p/' ]) {
const oembedUrl = 'http://localhost:' + server.port + basePath + playlistUUID
- const res = await server.servicesCommand.getOEmbed({ oembedUrl })
+ const res = await server.services.getOEmbed({ oembedUrl })
const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
`title="${playlistDisplayName}" src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` +
'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal('The Life and Times of Scrooge McDuck')
- expect(res.body.author_name).to.equal(server.videoChannel.displayName)
+ expect(res.body.author_name).to.equal(server.store.channel.displayName)
expect(res.body.width).to.equal(560)
expect(res.body.height).to.equal(315)
expect(res.body.thumbnail_url).exist
const maxHeight = 50
const maxWidth = 50
- const res = await server.servicesCommand.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
+ const res = await server.services.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
`title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal(video.name)
- expect(res.body.author_name).to.equal(server.videoChannel.displayName)
+ expect(res.body.author_name).to.equal(server.store.channel.displayName)
expect(res.body.height).to.equal(50)
expect(res.body.width).to.equal(50)
expect(res.body).to.not.have.property('thumbnail_url')
await doubleFollow(servers[0], servers[1])
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { fixture: 'video_short.webm' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { fixture: 'video_short.webm' } })
- await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
- await servers[0].videosCommand.view({ id: uuid })
+ await servers[0].videos.view({ id: uuid })
// Wait the video views repeatable job
await wait(8000)
- await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[2].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
})
it('Should have the correct stats on instance 1', async function () {
- const data = await servers[0].statsCommand.get()
+ const data = await servers[0].stats.get()
expect(data.totalLocalVideoComments).to.equal(1)
expect(data.totalLocalVideos).to.equal(1)
})
it('Should have the correct stats on instance 2', async function () {
- const data = await servers[1].statsCommand.get()
+ const data = await servers[1].stats.get()
expect(data.totalLocalVideoComments).to.equal(0)
expect(data.totalLocalVideos).to.equal(0)
})
it('Should have the correct stats on instance 3', async function () {
- const data = await servers[2].statsCommand.get()
+ const data = await servers[2].stats.get()
expect(data.totalLocalVideoComments).to.equal(0)
expect(data.totalLocalVideos).to.equal(0)
it('Should have the correct total videos stats after an unfollow', async function () {
this.timeout(15000)
- await servers[2].followsCommand.unfollow({ target: servers[0] })
+ await servers[2].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
- const data = await servers[2].statsCommand.get()
+ const data = await servers[2].stats.get()
expect(data.totalVideos).to.equal(0)
})
const server = servers[0]
{
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalDailyActiveUsers).to.equal(1)
expect(data.totalWeeklyActiveUsers).to.equal(1)
}
{
- await server.loginCommand.getAccessToken(user)
+ await server.login.getAccessToken(user)
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalDailyActiveUsers).to.equal(2)
expect(data.totalWeeklyActiveUsers).to.equal(2)
const server = servers[0]
{
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
name: 'stats_channel',
displayName: 'My stats channel'
}
- const created = await server.channelsCommand.create({ attributes })
+ const created = await server.channels.create({ attributes })
channelId = created.id
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
}
{
- await server.videosCommand.upload({ attributes: { fixture: 'video_short.webm', channelId } })
+ await server.videos.upload({ attributes: { fixture: 'video_short.webm', channelId } })
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalDailyActiveVideoChannels).to.equal(2)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2)
const server = servers[0]
{
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalPlaylists).to.equal(0)
}
{
- await server.playlistsCommand.create({
+ await server.playlists.create({
attributes: {
displayName: 'playlist for count',
privacy: VideoPlaylistPrivacy.PUBLIC,
}
})
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalPlaylists).to.equal(1)
}
})
it('Should correctly count video file sizes if transcoding is enabled', async function () {
this.timeout(60000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: true,
}
})
- await servers[0].videosCommand.upload({ attributes: { name: 'video', fixture: 'video_short.webm' } })
+ await servers[0].videos.upload({ attributes: { name: 'video', fixture: 'video_short.webm' } })
await waitJobs(servers)
{
- const data = await servers[1].statsCommand.get()
+ const data = await servers[1].stats.get()
expect(data.totalLocalVideoFilesSize).to.equal(0)
}
{
- const data = await servers[0].statsCommand.get()
+ const data = await servers[0].stats.get()
expect(data.totalLocalVideoFilesSize).to.be.greaterThan(500000)
expect(data.totalLocalVideoFilesSize).to.be.lessThan(600000)
}
it('Should have the correct AP stats', async function () {
this.timeout(60000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: false
}
})
- const first = await servers[1].statsCommand.get()
+ const first = await servers[1].stats.get()
for (let i = 0; i < 10; i++) {
- await servers[0].videosCommand.upload({ attributes: { name: 'video' } })
+ await servers[0].videos.upload({ attributes: { name: 'video' } })
}
await waitJobs(servers)
await wait(6000)
- const second = await servers[1].statsCommand.get()
+ const second = await servers[1].stats.get()
expect(second.totalActivityPubMessagesProcessed).to.be.greaterThan(first.totalActivityPubMessagesProcessed)
const apTypes: ActivityType[] = [
await wait(6000)
- const third = await servers[1].statsCommand.get()
+ const third = await servers[1].stats.get()
expect(third.totalActivityPubMessagesWaiting).to.equal(0)
expect(third.activityPubMessagesProcessedPerSecond).to.be.lessThan(second.activityPubMessagesProcessedPerSecond)
})
await setAccessTokensToServers([ server ])
{
- const { uuid } = await server.videosCommand.upload()
- const video = await server.videosCommand.get({ id: uuid })
+ const { uuid } = await server.videos.upload()
+ const video = await server.videos.get({ id: uuid })
goodMagnet = video.files[0].magnetUri
const parsed = magnetUtil.decode(goodMagnet)
{
for (const server of servers) {
const user = { username: 'user' + server.serverNumber, password: 'password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- const accessToken = await server.loginCommand.getAccessToken(user)
+ const accessToken = await server.login.getAccessToken(user)
users.push({ accessToken })
const videoName1 = 'video 1-' + server.serverNumber
- await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName1 } })
+ await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } })
const videoName2 = 'video 2-' + server.serverNumber
- await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName2 } })
+ await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } })
}
}
await waitJobs(servers)
- command = servers[0].subscriptionsCommand
+ command = servers[0].subscriptions
})
it('Should display videos of server 2 on server 1', async function () {
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(4)
})
await waitJobs(servers)
- const { uuid } = await servers[2].videosCommand.upload({ attributes: { name: 'video server 3 added after follow' } })
+ const { uuid } = await servers[2].videos.upload({ attributes: { name: 'video server 3 added after follow' } })
video3UUID = uuid
await waitJobs(servers)
})
it('Should not display videos of server 3 on server 1', async function () {
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(4)
for (const video of data) {
this.timeout(60000)
const videoName = 'video server 1 added after follow'
- await servers[0].videosCommand.upload({ attributes: { name: videoName } })
+ await servers[0].videos.upload({ attributes: { name: videoName } })
await waitJobs(servers)
}
{
- const { data, total } = await servers[0].videosCommand.list()
+ const { data, total } = await servers[0].videos.list()
expect(total).to.equal(5)
for (const video of data) {
it('Should have server 1 follow server 3 and display server 3 videos', async function () {
this.timeout(60000)
- await servers[0].followsCommand.follow({ targets: [ servers[2].url ] })
+ await servers[0].follows.follow({ targets: [ servers[2].url ] })
await waitJobs(servers)
- const { data, total } = await servers[0].videosCommand.list()
+ const { data, total } = await servers[0].videos.list()
expect(total).to.equal(8)
const names = [ '1-3', '2-3', 'video server 3 added after follow' ]
it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () {
this.timeout(60000)
- await servers[0].followsCommand.unfollow({ target: servers[2] })
+ await servers[0].follows.unfollow({ target: servers[2] })
await waitJobs(servers)
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(5)
for (const video of data) {
it('Should update a video of server 3 and see the updated video on server 1', async function () {
this.timeout(30000)
- await servers[2].videosCommand.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } })
+ await servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } })
await waitJobs(servers)
})
it('Should correctly display public videos on server 1', async function () {
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(5)
for (const video of data) {
}
{
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(5)
for (const video of data) {
await doubleFollow(servers[1], servers[2])
// The root user of server 1 is propagated to servers 2 and 3
- await servers[0].videosCommand.upload()
+ await servers[0].videos.upload()
{
const user = {
username: 'user1',
password: 'password'
}
- const created = await servers[0].usersCommand.create(user)
+ const created = await servers[0].users.create(user)
userId = created.id
- userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ userAccessToken = await servers[0].login.getAccessToken(user)
}
{
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken })
videoUUID = uuid
}
it('Should be able to update my display name', async function () {
this.timeout(10000)
- await servers[0].usersCommand.updateMe({ displayName: 'my super display name' })
+ await servers[0].users.updateMe({ displayName: 'my super display name' })
- user = await servers[0].usersCommand.getMyInfo()
+ user = await servers[0].users.getMyInfo()
expect(user.account.displayName).to.equal('my super display name')
await waitJobs(servers)
it('Should be able to update my description', async function () {
this.timeout(10_000)
- await servers[0].usersCommand.updateMe({ description: 'my super description updated' })
+ await servers[0].users.updateMe({ description: 'my super description updated' })
- user = await servers[0].usersCommand.getMyInfo()
+ user = await servers[0].users.getMyInfo()
expect(user.account.displayName).to.equal('my super display name')
expect(user.account.description).to.equal('my super description updated')
const fixture = 'avatar2.png'
- await servers[0].usersCommand.updateMyAvatar({ fixture })
+ await servers[0].users.updateMyAvatar({ fixture })
- user = await servers[0].usersCommand.getMyInfo()
+ user = await servers[0].users.getMyInfo()
userAvatarFilename = user.account.avatar.path
await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png')
let createdAt: string | Date
for (const server of servers) {
- const body = await server.accountsCommand.list({ sort: '-createdAt' })
+ const body = await server.accounts.list({ sort: '-createdAt' })
const resList = body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port)
expect(resList).not.to.be.undefined
- const account = await server.accountsCommand.get({ accountName: resList.name + '@' + resList.host })
+ const account = await server.accounts.get({ accountName: resList.name + '@' + resList.host })
if (!createdAt) createdAt = account.createdAt
it('Should list account videos', async function () {
for (const server of servers) {
- const { total, data } = await server.videosCommand.listByAccount({ accountName: 'user1@localhost:' + servers[0].port })
+ const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.be.an('array')
it('Should search through account videos', async function () {
this.timeout(10_000)
- const created = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'Kami no chikara' } })
+ const created = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'Kami no chikara' } })
await waitJobs(servers)
for (const server of servers) {
- const { total, data } = await server.videosCommand.listByAccount({ accountName: 'user1@localhost:' + servers[0].port, search: 'Kami' })
+ const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port, search: 'Kami' })
expect(total).to.equal(1)
expect(data).to.be.an('array')
this.timeout(10_000)
for (const server of servers) {
- const body = await server.accountsCommand.list({ sort: '-createdAt' })
+ const body = await server.accounts.list({ sort: '-createdAt' })
const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
expect(accountDeleted).not.to.be.undefined
- const { data } = await server.channelsCommand.list()
+ const { data } = await server.channels.list()
const videoChannelDeleted = data.find(a => a.displayName === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port)
expect(videoChannelDeleted).not.to.be.undefined
}
- await servers[0].usersCommand.remove({ userId })
+ await servers[0].users.remove({ userId })
await waitJobs(servers)
for (const server of servers) {
- const body = await server.accountsCommand.list({ sort: '-createdAt' })
+ const body = await server.accounts.list({ sort: '-createdAt' })
const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
expect(accountDeleted).to.be.undefined
- const { data } = await server.channelsCommand.list()
+ const { data } = await server.channels.list()
const videoChannelDeleted = data.find(a => a.name === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port)
expect(videoChannelDeleted).to.be.undefined
}
it('Should register user and send verification email if verification required', async function () {
this.timeout(30000)
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
signup: {
enabled: true,
}
})
- await server.usersCommand.register(user1)
+ await server.users.register(user1)
await waitJobs(server)
expectedEmailsLength++
userId = parseInt(userIdMatches[1], 10)
- const body = await server.usersCommand.get({ userId })
+ const body = await server.users.get({ userId })
expect(body.emailVerified).to.be.false
})
it('Should not allow login for user with unverified email', async function () {
- const { detail } = await server.loginCommand.login({ user: user1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const { detail } = await server.login.login({ user: user1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(detail).to.contain('User email is not verified.')
})
it('Should verify the user via email and allow login', async function () {
- await server.usersCommand.verifyEmail({ userId, verificationString })
+ await server.users.verifyEmail({ userId, verificationString })
- const body = await server.loginCommand.login({ user: user1 })
+ const body = await server.login.login({ user: user1 })
userAccessToken = body.access_token
- const user = await server.usersCommand.get({ userId })
+ const user = await server.users.get({ userId })
expect(user.emailVerified).to.be.true
})
let updateVerificationString: string
{
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userAccessToken,
email: 'updated@example.com',
currentPassword: user1.password
}
{
- const me = await server.usersCommand.getMyInfo({ token: userAccessToken })
+ const me = await server.users.getMyInfo({ token: userAccessToken })
expect(me.email).to.equal('user_1@example.com')
expect(me.pendingEmail).to.equal('updated@example.com')
}
{
- await server.usersCommand.verifyEmail({ userId, verificationString: updateVerificationString, isPendingEmail: true })
+ await server.users.verifyEmail({ userId, verificationString: updateVerificationString, isPendingEmail: true })
- const me = await server.usersCommand.getMyInfo({ token: userAccessToken })
+ const me = await server.users.getMyInfo({ token: userAccessToken })
expect(me.email).to.equal('updated@example.com')
expect(me.pendingEmail).to.be.null
}
it('Should register user not requiring email verification if setting not enabled', async function () {
this.timeout(5000)
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
signup: {
enabled: true,
}
})
- await server.usersCommand.register(user2)
+ await server.users.register(user2)
await waitJobs(server)
expect(emails).to.have.lengthOf(expectedEmailsLength)
- const accessToken = await server.loginCommand.getAccessToken(user2)
+ const accessToken = await server.login.getAccessToken(user2)
- const user = await server.usersCommand.getMyInfo({ token: accessToken })
+ const user = await server.users.getMyInfo({ token: accessToken })
expect(user.emailVerified).to.be.null
})
it('Should allow login for user with unverified email when setting later enabled', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
signup: {
enabled: true,
}
})
- await server.loginCommand.getAccessToken(user2)
+ await server.login.getAccessToken(user2)
})
after(async function () {
await setAccessTokensToServers([ server ])
- await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' })
+ await server.plugins.install({ npmName: 'peertube-theme-background-red' })
})
describe('OAuth client', function () {
it('Should remove the last client')
it('Should not login with an invalid client id', async function () {
- const client = { id: 'client', secret: server.client.secret }
- const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const client = { id: 'client', secret: server.store.client.secret }
+ const body = await server.login.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
expect(body.error).to.contain('client is invalid')
})
it('Should not login with an invalid client secret', async function () {
- const client = { id: server.client.id, secret: 'coucou' }
- const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const client = { id: server.store.client.id, secret: 'coucou' }
+ const body = await server.login.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
expect(body.error).to.contain('client is invalid')
describe('Login', function () {
it('Should not login with an invalid username', async function () {
- const user = { username: 'captain crochet', password: server.user.password }
- const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const user = { username: 'captain crochet', password: server.store.user.password }
+ const body = await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
expect(body.error).to.contain('credentials are invalid')
})
it('Should not login with an invalid password', async function () {
- const user = { username: server.user.username, password: 'mew_three' }
- const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const user = { username: server.store.user.username, password: 'mew_three' }
+ const body = await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
expect(body.error).to.contain('credentials are invalid')
it('Should not be able to upload a video', async function () {
token = 'my_super_token'
- await server.videosCommand.upload({ token, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.videos.upload({ token, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to follow', async function () {
token = 'my_super_token'
- await server.followsCommand.follow({
+ await server.follows.follow({
targets: [ 'http://example.com' ],
token,
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
it('Should not be able to unfollow')
it('Should be able to login', async function () {
- const body = await server.loginCommand.login({ expectedStatus: HttpStatusCode.OK_200 })
+ const body = await server.login.login({ expectedStatus: HttpStatusCode.OK_200 })
token = body.access_token
})
it('Should be able to login with an insensitive username', async function () {
- const user = { username: 'RoOt', password: server.user.password }
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.OK_200 })
+ const user = { username: 'RoOt', password: server.store.user.password }
+ await server.login.login({ user, expectedStatus: HttpStatusCode.OK_200 })
- const user2 = { username: 'rOoT', password: server.user.password }
- await server.loginCommand.login({ user: user2, expectedStatus: HttpStatusCode.OK_200 })
+ const user2 = { username: 'rOoT', password: server.store.user.password }
+ await server.login.login({ user: user2, expectedStatus: HttpStatusCode.OK_200 })
- const user3 = { username: 'ROOt', password: server.user.password }
- await server.loginCommand.login({ user: user3, expectedStatus: HttpStatusCode.OK_200 })
+ const user3 = { username: 'ROOt', password: server.store.user.password }
+ await server.login.login({ user: user3, expectedStatus: HttpStatusCode.OK_200 })
})
})
describe('Upload', function () {
it('Should upload the video with the correct token', async function () {
- await server.videosCommand.upload({ token })
- const { data } = await server.videosCommand.list()
+ await server.videos.upload({ token })
+ const { data } = await server.videos.list()
const video = data[0]
expect(video.account.name).to.equal('root')
})
it('Should upload the video again with the correct token', async function () {
- await server.videosCommand.upload({ token })
+ await server.videos.upload({ token })
})
})
describe('Ratings', function () {
it('Should retrieve a video rating', async function () {
- await server.videosCommand.rate({ id: videoId, rating: 'like' })
- const rating = await server.usersCommand.getMyRating({ token, videoId })
+ await server.videos.rate({ id: videoId, rating: 'like' })
+ const rating = await server.users.getMyRating({ token, videoId })
expect(rating.videoId).to.equal(videoId)
expect(rating.rating).to.equal('like')
})
it('Should retrieve ratings list', async function () {
- await server.videosCommand.rate({ id: videoId, rating: 'like' })
+ await server.videos.rate({ id: videoId, rating: 'like' })
- const body = await server.accountsCommand.listRatings({ accountName: server.user.username })
+ const body = await server.accounts.listRatings({ accountName: server.store.user.username })
expect(body.total).to.equal(1)
expect(body.data[0].video.id).to.equal(videoId)
it('Should retrieve ratings list by rating type', async function () {
{
- const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'like' })
+ const body = await server.accounts.listRatings({ accountName: server.store.user.username, rating: 'like' })
expect(body.data.length).to.equal(1)
}
{
- const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'dislike' })
+ const body = await server.accounts.listRatings({ accountName: server.store.user.username, rating: 'dislike' })
expect(body.data.length).to.equal(0)
}
})
describe('Remove video', function () {
it('Should not be able to remove the video with an incorrect token', async function () {
- await server.videosCommand.remove({ token: 'bad_token', id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.videos.remove({ token: 'bad_token', id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to remove the video with the token of another account')
it('Should be able to remove the video with the correct token', async function () {
- await server.videosCommand.remove({ token, id: videoId })
+ await server.videos.remove({ token, id: videoId })
})
})
describe('Logout', function () {
it('Should logout (revoke token)', async function () {
- await server.loginCommand.logout({ token: server.accessToken })
+ await server.login.logout({ token: server.accessToken })
})
it('Should not be able to get the user information', async function () {
- await server.usersCommand.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to upload a video', async function () {
- await server.videosCommand.upload({ attributes: { name: 'video' }, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.videos.upload({ attributes: { name: 'video' }, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to rate a video', async function () {
})
it('Should be able to login again', async function () {
- const body = await server.loginCommand.login()
+ const body = await server.login.login()
server.accessToken = body.access_token
server.refreshToken = body.refresh_token
})
it('Should be able to get my user information again', async function () {
- await server.usersCommand.getMyInfo()
+ await server.users.getMyInfo()
})
it('Should have an expired access token', async function () {
this.timeout(15000)
- await server.sqlCommand.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString())
- await server.sqlCommand.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString())
+ await server.sql.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString())
+ await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString())
await killallServers([ server ])
await reRunServer(server)
- await server.usersCommand.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to refresh an access token with an expired refresh token', async function () {
- await server.loginCommand.refreshToken({ refreshToken: server.refreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.refreshToken({ refreshToken: server.refreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should refresh the token', async function () {
this.timeout(15000)
const futureDate = new Date(new Date().getTime() + 1000 * 60).toISOString()
- await server.sqlCommand.setTokenField(server.accessToken, 'refreshTokenExpiresAt', futureDate)
+ await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', futureDate)
await killallServers([ server ])
await reRunServer(server)
- const res = await server.loginCommand.refreshToken({ refreshToken: server.refreshToken })
+ const res = await server.login.refreshToken({ refreshToken: server.refreshToken })
server.accessToken = res.body.access_token
server.refreshToken = res.body.refresh_token
})
it('Should be able to get my user information again', async function () {
- await server.usersCommand.getMyInfo()
+ await server.users.getMyInfo()
})
})
describe('Creating a user', function () {
it('Should be able to create a new user', async function () {
- await server.usersCommand.create({ ...user, videoQuota: 2 * 1024 * 1024, adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST })
+ await server.users.create({ ...user, videoQuota: 2 * 1024 * 1024, adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST })
})
it('Should be able to login with this user', async function () {
- userToken = await server.loginCommand.getAccessToken(user)
+ userToken = await server.login.getAccessToken(user)
})
it('Should be able to get user information', async function () {
- const userMe = await server.usersCommand.getMyInfo({ token: userToken })
+ const userMe = await server.users.getMyInfo({ token: userToken })
- const userGet = await server.usersCommand.get({ userId: userMe.id, withStats: true })
+ const userGet = await server.users.get({ userId: userMe.id, withStats: true })
for (const user of [ userMe, userGet ]) {
expect(user.username).to.equal('user_1')
name: 'super user video',
fixture: 'video_short.webm'
}
- await server.videosCommand.upload({ token: userToken, attributes })
+ await server.videos.upload({ token: userToken, attributes })
})
it('Should have video quota updated', async function () {
- const quota = await server.usersCommand.getMyQuotaUsed({ token: userToken })
+ const quota = await server.users.getMyQuotaUsed({ token: userToken })
expect(quota.videoQuotaUsed).to.equal(218910)
- const { data } = await server.usersCommand.list()
+ const { data } = await server.users.list()
const tmpUser = data.find(u => u.username === user.username)
expect(tmpUser.videoQuotaUsed).to.equal(218910)
})
it('Should be able to list my videos', async function () {
- const { total, data } = await server.videosCommand.listMyVideos({ token: userToken })
+ const { total, data } = await server.videos.listMyVideos({ token: userToken })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
it('Should be able to search in my videos', async function () {
{
- const { total, data } = await server.videosCommand.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' })
+ const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
}
{
- const { total, data } = await server.videosCommand.listMyVideos({ token: userToken, sort: '-createdAt', search: 'toto' })
+ const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'toto' })
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
}
this.timeout(60000)
{
- const config = await server.configCommand.getCustomConfig()
+ const config = await server.config.getCustomConfig()
config.transcoding.webtorrent.enabled = false
config.transcoding.hls.enabled = true
config.transcoding.enabled = true
- await server.configCommand.updateCustomSubConfig({ newConfig: config })
+ await server.config.updateCustomSubConfig({ newConfig: config })
}
{
name: 'super user video 2',
fixture: 'video_short.webm'
}
- await server.videosCommand.upload({ token: userToken, attributes })
+ await server.videos.upload({ token: userToken, attributes })
await waitJobs([ server ])
}
{
- const data = await server.usersCommand.getMyQuotaUsed({ token: userToken })
+ const data = await server.users.getMyQuotaUsed({ token: userToken })
expect(data.videoQuotaUsed).to.be.greaterThan(220000)
}
})
describe('Users listing', function () {
it('Should list all the users', async function () {
- const { data, total } = await server.usersCommand.list()
+ const { data, total } = await server.users.list()
expect(total).to.equal(2)
expect(data).to.be.an('array')
})
it('Should list only the first user by username asc', async function () {
- const { total, data } = await server.usersCommand.list({ start: 0, count: 1, sort: 'username' })
+ const { total, data } = await server.users.list({ start: 0, count: 1, sort: 'username' })
expect(total).to.equal(2)
expect(data.length).to.equal(1)
})
it('Should list only the first user by username desc', async function () {
- const { total, data } = await server.usersCommand.list({ start: 0, count: 1, sort: '-username' })
+ const { total, data } = await server.users.list({ start: 0, count: 1, sort: '-username' })
expect(total).to.equal(2)
expect(data.length).to.equal(1)
})
it('Should list only the second user by createdAt desc', async function () {
- const { data, total } = await server.usersCommand.list({ start: 0, count: 1, sort: '-createdAt' })
+ const { data, total } = await server.users.list({ start: 0, count: 1, sort: '-createdAt' })
expect(total).to.equal(2)
expect(data.length).to.equal(1)
})
it('Should list all the users by createdAt asc', async function () {
- const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt' })
+ const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt' })
expect(total).to.equal(2)
expect(data.length).to.equal(2)
})
it('Should search user by username', async function () {
- const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'oot' })
+ const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'oot' })
expect(total).to.equal(1)
expect(data.length).to.equal(1)
expect(data[0].username).to.equal('root')
it('Should search user by email', async function () {
{
- const { total, data } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'r_1@exam' })
+ const { total, data } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'r_1@exam' })
expect(total).to.equal(1)
expect(data.length).to.equal(1)
expect(data[0].username).to.equal('user_1')
}
{
- const { total, data } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'example' })
+ const { total, data } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'example' })
expect(total).to.equal(2)
expect(data.length).to.equal(2)
expect(data[0].username).to.equal('root')
describe('Update my account', function () {
it('Should update my password', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
currentPassword: 'super password',
password: 'new password'
})
user.password = 'new password'
- await server.loginCommand.login({ user })
+ await server.login.login({ user })
})
it('Should be able to change the NSFW display attribute', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
nsfwPolicy: 'do_not_list'
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
expect(user.nsfwPolicy).to.equal('do_not_list')
})
it('Should be able to change the autoPlayVideo attribute', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
autoPlayVideo: false
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.autoPlayVideo).to.be.false
})
it('Should be able to change the autoPlayNextVideo attribute', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
autoPlayNextVideo: true
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.autoPlayNextVideo).to.be.true
})
it('Should be able to change the email attribute', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
currentPassword: 'new password',
email: 'updated@example.com'
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated@example.com')
expect(user.nsfwPolicy).to.equal('do_not_list')
it('Should be able to update my avatar with a gif', async function () {
const fixture = 'avatar.gif'
- await server.usersCommand.updateMyAvatar({ token: userToken, fixture })
+ await server.users.updateMyAvatar({ token: userToken, fixture })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.gif')
})
for (const extension of [ '.png', '.gif' ]) {
const fixture = 'avatar' + extension
- await server.usersCommand.updateMyAvatar({ token: userToken, fixture })
+ await server.users.updateMyAvatar({ token: userToken, fixture })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
await testImage(server.url, 'avatar-resized', user.account.avatar.path, extension)
}
})
it('Should be able to update my display name', async function () {
- await server.usersCommand.updateMe({ token: userToken, displayName: 'new display name' })
+ await server.users.updateMe({ token: userToken, displayName: 'new display name' })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated@example.com')
expect(user.nsfwPolicy).to.equal('do_not_list')
})
it('Should be able to update my description', async function () {
- await server.usersCommand.updateMe({ token: userToken, description: 'my super description updated' })
+ await server.users.updateMe({ token: userToken, description: 'my super description updated' })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated@example.com')
expect(user.nsfwPolicy).to.equal('do_not_list')
it('Should be able to update my theme', async function () {
for (const theme of [ 'background-red', 'default', 'instance-default' ]) {
- await server.usersCommand.updateMe({ token: userToken, theme })
+ await server.users.updateMe({ token: userToken, theme })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.theme).to.equal(theme)
}
})
it('Should be able to update my modal preferences', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
noInstanceConfigWarningModal: true,
noWelcomeModal: true
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.noWelcomeModal).to.be.true
expect(user.noInstanceConfigWarningModal).to.be.true
})
describe('Updating another user', function () {
it('Should be able to update another user', async function () {
- await server.usersCommand.update({
+ await server.users.update({
userId,
token,
email: 'updated2@example.com',
pluginAuth: 'toto'
})
- const user = await server.usersCommand.get({ token, userId })
+ const user = await server.users.get({ token, userId })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated2@example.com')
})
it('Should reset the auth plugin', async function () {
- await server.usersCommand.update({ userId, token, pluginAuth: null })
+ await server.users.update({ userId, token, pluginAuth: null })
- const user = await server.usersCommand.get({ token, userId })
+ const user = await server.users.get({ token, userId })
expect(user.pluginAuth).to.be.null
})
it('Should have removed the user token', async function () {
- await server.usersCommand.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- userToken = await server.loginCommand.getAccessToken(user)
+ userToken = await server.login.getAccessToken(user)
})
it('Should be able to update another user password', async function () {
- await server.usersCommand.update({ userId, token, password: 'password updated' })
+ await server.users.update({ userId, token, password: 'password updated' })
- await server.usersCommand.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
user.password = 'password updated'
- userToken = await server.loginCommand.getAccessToken(user)
+ userToken = await server.login.getAccessToken(user)
})
})
describe('Video blacklists', function () {
it('Should be able to list video blacklist by a moderator', async function () {
- await server.blacklistCommand.list({ token: userToken })
+ await server.blacklist.list({ token: userToken })
})
})
describe('Remove a user', function () {
it('Should be able to remove this user', async function () {
- await server.usersCommand.remove({ userId, token })
+ await server.users.remove({ userId, token })
})
it('Should not be able to login with this user', async function () {
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not have videos of this user', async function () {
- const { data, total } = await server.videosCommand.list()
+ const { data, total } = await server.videos.list()
expect(total).to.equal(1)
const video = data[0]
const user = { displayName: 'super user 15', username: 'user_15', password: 'my super password' }
const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' }
- await server.usersCommand.register({ ...user, channel })
+ await server.users.register({ ...user, channel })
})
it('Should be able to login with this registered user', async function () {
password: 'my super password'
}
- user15AccessToken = await server.loginCommand.getAccessToken(user15)
+ user15AccessToken = await server.login.getAccessToken(user15)
})
it('Should have the correct display name', async function () {
- const user = await server.usersCommand.getMyInfo({ token: user15AccessToken })
+ const user = await server.users.getMyInfo({ token: user15AccessToken })
expect(user.account.displayName).to.equal('super user 15')
})
it('Should have the correct video quota', async function () {
- const user = await server.usersCommand.getMyInfo({ token: user15AccessToken })
+ const user = await server.users.getMyInfo({ token: user15AccessToken })
expect(user.videoQuota).to.equal(5 * 1024 * 1024)
})
it('Should have created the channel', async function () {
- const { displayName } = await server.channelsCommand.get({ channelName: 'my_user_15_channel' })
+ const { displayName } = await server.channels.get({ channelName: 'my_user_15_channel' })
expect(displayName).to.equal('my channel rocks')
})
it('Should remove me', async function () {
{
- const { data } = await server.usersCommand.list()
+ const { data } = await server.users.list()
expect(data.find(u => u.username === 'user_15')).to.not.be.undefined
}
- await server.usersCommand.deleteMe({ token: user15AccessToken })
+ await server.users.deleteMe({ token: user15AccessToken })
{
- const { data } = await server.usersCommand.list()
+ const { data } = await server.users.list()
expect(data.find(u => u.username === 'user_15')).to.be.undefined
}
})
}
it('Should block a user', async function () {
- const user = await server.usersCommand.create({ ...user16 })
+ const user = await server.users.create({ ...user16 })
user16Id = user.id
- user16AccessToken = await server.loginCommand.getAccessToken(user16)
+ user16AccessToken = await server.login.getAccessToken(user16)
- await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
- await server.usersCommand.banUser({ userId: user16Id })
+ await server.users.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
+ await server.users.banUser({ userId: user16Id })
- await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- await server.loginCommand.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.users.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.login.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should search user by banned status', async function () {
{
- const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', blocked: true })
+ const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', blocked: true })
expect(total).to.equal(1)
expect(data.length).to.equal(1)
}
{
- const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', blocked: false })
+ const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', blocked: false })
expect(total).to.equal(1)
expect(data.length).to.equal(1)
})
it('Should unblock a user', async function () {
- await server.usersCommand.unbanUser({ userId: user16Id })
- user16AccessToken = await server.loginCommand.getAccessToken(user16)
- await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
+ await server.users.unbanUser({ userId: user16Id })
+ user16AccessToken = await server.login.getAccessToken(user16)
+ await server.users.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
})
})
username: 'user_17',
password: 'my super password'
}
- const created = await server.usersCommand.create({ ...user17 })
+ const created = await server.users.create({ ...user17 })
user17Id = created.id
- user17AccessToken = await server.loginCommand.getAccessToken(user17)
+ user17AccessToken = await server.login.getAccessToken(user17)
- const user = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user = await server.users.get({ userId: user17Id, withStats: true })
expect(user.videosCount).to.equal(0)
expect(user.videoCommentsCount).to.equal(0)
expect(user.abusesCount).to.equal(0)
it('Should report correct videos count', async function () {
const attributes = { name: 'video to test user stats' }
- await server.videosCommand.upload({ token: user17AccessToken, attributes })
+ await server.videos.upload({ token: user17AccessToken, attributes })
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
videoId = data.find(video => video.name === attributes.name).id
- const user = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user = await server.users.get({ userId: user17Id, withStats: true })
expect(user.videosCount).to.equal(1)
})
it('Should report correct video comments for user', async function () {
const text = 'super comment'
- await server.commentsCommand.createThread({ token: user17AccessToken, videoId, text })
+ await server.comments.createThread({ token: user17AccessToken, videoId, text })
- const user = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user = await server.users.get({ userId: user17Id, withStats: true })
expect(user.videoCommentsCount).to.equal(1)
})
it('Should report correct abuses counts', async function () {
const reason = 'my super bad reason'
- await server.abusesCommand.report({ token: user17AccessToken, videoId, reason })
+ await server.abuses.report({ token: user17AccessToken, videoId, reason })
- const body1 = await server.abusesCommand.getAdminList()
+ const body1 = await server.abuses.getAdminList()
const abuseId = body1.data[0].id
- const user2 = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user2 = await server.users.get({ userId: user17Id, withStats: true })
expect(user2.abusesCount).to.equal(1) // number of incriminations
expect(user2.abusesCreatedCount).to.equal(1) // number of reports created
- await server.abusesCommand.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
+ await server.abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
- const user3 = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user3 = await server.users.get({ userId: user17Id, withStats: true })
expect(user3.abusesAcceptedCount).to.equal(1) // number of reports created accepted
})
})
it('Should upload a video and transcode it', async function () {
this.timeout(120000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'audio only' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } })
videoUUID = uuid
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
expect(video.streamingPlaylists).to.have.lengthOf(1)
for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
it('0p transcoded video should not have video', async function () {
const paths = [
- servers[0].serversCommand.buildDirectory(join('videos', videoUUID + '-0.mp4')),
- servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
+ servers[0].servers.buildDirectory(join('videos', videoUUID + '-0.mp4')),
+ servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
]
for (const path of paths) {
displayName: 'my channel',
description: 'super channel'
}
- await servers[0].channelsCommand.create({ attributes: videoChannel })
- const { data } = await servers[0].channelsCommand.list({ start: 0, count: 1 })
+ await servers[0].channels.create({ attributes: videoChannel })
+ const { data } = await servers[0].channels.list({ start: 0, count: 1 })
videoChannelId = data[0].id
}
it('Should not have videos for all servers', async function () {
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.be.an('array')
expect(data.length).to.equal(0)
}
channelId: videoChannelId,
fixture: 'video_short1.webm'
}
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
await waitJobs(servers)
]
}
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.be.an('array')
expect(data.length).to.equal(1)
const video = data[0]
username: 'user1',
password: 'super_password'
}
- await servers[1].usersCommand.create({ username: user.username, password: user.password })
- const userAccessToken = await servers[1].loginCommand.getAccessToken(user)
+ await servers[1].users.create({ username: user.username, password: user.password })
+ const userAccessToken = await servers[1].login.getAccessToken(user)
const attributes = {
name: 'my super name for server 2',
thumbnailfile: 'thumbnail.jpg',
previewfile: 'preview.jpg'
}
- await servers[1].videosCommand.upload({ token: userAccessToken, attributes, mode: 'resumable' })
+ await servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' })
// Transcoding
await waitJobs(servers)
previewfile: 'preview'
}
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.be.an('array')
expect(data.length).to.equal(2)
const video = data[1]
tags: [ 'tag1p3' ],
fixture: 'video_short3.webm'
}
- await servers[2].videosCommand.upload({ attributes })
+ await servers[2].videos.upload({ attributes })
}
{
tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
fixture: 'video_short.webm'
}
- await servers[2].videosCommand.upload({ attributes })
+ await servers[2].videos.upload({ attributes })
}
await waitJobs(servers)
// All servers should have this video
for (const server of servers) {
const isLocal = server.url === 'http://localhost:' + servers[2].port
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.be.an('array')
expect(data.length).to.equal(4)
describe('It should list local videos', function () {
it('Should list only local videos on server 1', async function () {
- const { data, total } = await servers[0].videosCommand.list({ filter: 'local' })
+ const { data, total } = await servers[0].videos.list({ filter: 'local' })
expect(total).to.equal(1)
expect(data).to.be.an('array')
})
it('Should list only local videos on server 2', async function () {
- const { data, total } = await servers[1].videosCommand.list({ filter: 'local' })
+ const { data, total } = await servers[1].videos.list({ filter: 'local' })
expect(total).to.equal(1)
expect(data).to.be.an('array')
})
it('Should list only local videos on server 3', async function () {
- const { data, total } = await servers[2].videosCommand.list({ filter: 'local' })
+ const { data, total } = await servers[2].videos.list({ filter: 'local' })
expect(total).to.equal(2)
expect(data).to.be.an('array')
it('Should add the file 1 by asking server 3', async function () {
this.timeout(10000)
- const { data } = await servers[2].videosCommand.list()
+ const { data } = await servers[2].videos.list()
const video = data[0]
toRemove.push(data[2])
toRemove.push(data[3])
- const videoDetails = await servers[2].videosCommand.get({ id: video.id })
+ const videoDetails = await servers[2].videos.get({ id: video.id })
const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
expect(torrent.files).to.be.an('array')
expect(torrent.files.length).to.equal(1)
it('Should add the file 2 by asking server 1', async function () {
this.timeout(10000)
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
const video = data[1]
- const videoDetails = await servers[0].videosCommand.get({ id: video.id })
+ const videoDetails = await servers[0].videos.get({ id: video.id })
const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
expect(torrent.files).to.be.an('array')
it('Should add the file 3 by asking server 2', async function () {
this.timeout(10000)
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
const video = data[2]
- const videoDetails = await servers[1].videosCommand.get({ id: video.id })
+ const videoDetails = await servers[1].videos.get({ id: video.id })
const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
expect(torrent.files).to.be.an('array')
it('Should add the file 3-2 by asking server 1', async function () {
this.timeout(10000)
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
const video = data[3]
- const videoDetails = await servers[0].videosCommand.get({ id: video.id })
+ const videoDetails = await servers[0].videos.get({ id: video.id })
const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
expect(torrent.files).to.be.an('array')
it('Should add the file 2 in 360p by asking server 1', async function () {
this.timeout(10000)
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
const video = data.find(v => v.name === 'my super name for server 2')
- const videoDetails = await servers[0].videosCommand.get({ id: video.id })
+ const videoDetails = await servers[0].videos.get({ id: video.id })
const file = videoDetails.files.find(f => f.resolution.id === 360)
expect(file).not.to.be.undefined
before(async function () {
{
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
}
{
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
}
{
- const { data } = await servers[2].videosCommand.list()
+ const { data } = await servers[2].videos.list()
localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
}
it('Should view multiple videos on owned servers', async function () {
this.timeout(30000)
- await servers[2].videosCommand.view({ id: localVideosServer3[0] })
+ await servers[2].videos.view({ id: localVideosServer3[0] })
await wait(1000)
- await servers[2].videosCommand.view({ id: localVideosServer3[0] })
- await servers[2].videosCommand.view({ id: localVideosServer3[1] })
+ await servers[2].videos.view({ id: localVideosServer3[0] })
+ await servers[2].videos.view({ id: localVideosServer3[1] })
await wait(1000)
- await servers[2].videosCommand.view({ id: localVideosServer3[0] })
- await servers[2].videosCommand.view({ id: localVideosServer3[0] })
+ await servers[2].videos.view({ id: localVideosServer3[0] })
+ await servers[2].videos.view({ id: localVideosServer3[0] })
await waitJobs(servers)
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video0 = data.find(v => v.uuid === localVideosServer3[0])
const video1 = data.find(v => v.uuid === localVideosServer3[1])
this.timeout(45000)
const tasks: Promise<any>[] = []
- tasks.push(servers[0].videosCommand.view({ id: remoteVideosServer1[0] }))
- tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] }))
- tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] }))
- tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[0] }))
- tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] }))
- tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] }))
- tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] }))
- tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] }))
- tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] }))
- tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] }))
+ tasks.push(servers[0].videos.view({ id: remoteVideosServer1[0] }))
+ tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
+ tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
+ tasks.push(servers[2].videos.view({ id: remoteVideosServer3[0] }))
+ tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
+ tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
+ tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
+ tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
+ tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
+ tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
await Promise.all(tasks)
let baseVideos = null
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
// Initialize base videos for future comparisons
if (baseVideos === null) {
it('Should like and dislikes videos on different services', async function () {
this.timeout(50000)
- await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' })
+ await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
await wait(500)
- await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
+ await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
await wait(500)
- await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' })
- await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'like' })
+ await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
+ await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' })
await wait(500)
- await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'dislike' })
- await servers[2].videosCommand.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
+ await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' })
+ await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
await wait(500)
- await servers[2].videosCommand.rate({ id: remoteVideosServer3[0], rating: 'like' })
+ await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' })
await waitJobs(servers)
await wait(5000)
let baseVideos = null
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
// Initialize base videos for future comparisons
if (baseVideos === null) {
previewfile: 'preview.jpg'
}
- await servers[2].videosCommand.update({ id: toRemove[0].id, attributes })
+ await servers[2].videos.update({ id: toRemove[0].id, attributes })
await waitJobs(servers)
})
this.timeout(10000)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const videoUpdated = data.find(video => video.name === 'my super video updated')
expect(!!videoUpdated).to.be.true
it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
this.timeout(10000)
- await servers[2].videosCommand.remove({ id: toRemove[0].id })
- await servers[2].videosCommand.remove({ id: toRemove[1].id })
+ await servers[2].videos.remove({ id: toRemove[0].id })
+ await servers[2].videos.remove({ id: toRemove[1].id })
await waitJobs(servers)
})
it('Should have videos 1 and 3 on each server', async function () {
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.be.an('array')
expect(data.length).to.equal(2)
it('Should get the same video by UUID on each server', async function () {
let baseVideo = null
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
if (baseVideo === null) {
baseVideo = video
it('Should get the preview from each server', async function () {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
}
{
const text = 'my super first comment'
- await servers[0].commentsCommand.createThread({ videoId: videoUUID, text })
+ await servers[0].comments.createThread({ videoId: videoUUID, text })
}
{
const text = 'my super second comment'
- await servers[2].commentsCommand.createThread({ videoId: videoUUID, text })
+ await servers[2].comments.createThread({ videoId: videoUUID, text })
}
await waitJobs(servers)
{
- const threadId = await servers[1].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
+ const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
const text = 'my super answer to thread 1'
- await servers[1].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text })
+ await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text })
}
await waitJobs(servers)
{
- const threadId = await servers[2].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
+ const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
- const body = await servers[2].commentsCommand.getThread({ videoId: videoUUID, threadId })
+ const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId })
const childCommentId = body.children[0].comment.id
const text3 = 'my second answer to thread 1'
- await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
+ await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
const text2 = 'my super answer to answer of thread 1'
- await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
+ await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
}
await waitJobs(servers)
it('Should have these threads', async function () {
for (const server of servers) {
- const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
+ const body = await server.comments.listThreads({ videoId: videoUUID })
expect(body.total).to.equal(2)
expect(body.data).to.be.an('array')
it('Should have these comments', async function () {
for (const server of servers) {
- const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
+ const body = await server.comments.listThreads({ videoId: videoUUID })
const threadId = body.data.find(c => c.text === 'my super first comment').id
- const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId })
+ const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
expect(tree.comment.text).equal('my super first comment')
expect(tree.comment.account.name).equal('root')
it('Should delete a reply', async function () {
this.timeout(10000)
- await servers[2].commentsCommand.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
+ await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
await waitJobs(servers)
})
it('Should have this comment marked as deleted', async function () {
for (const server of servers) {
- const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID })
+ const { data } = await server.comments.listThreads({ videoId: videoUUID })
const threadId = data.find(c => c.text === 'my super first comment').id
- const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId })
+ const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
expect(tree.comment.text).equal('my super first comment')
const firstChild = tree.children[0]
it('Should delete the thread comments', async function () {
this.timeout(10000)
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID })
+ const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
const commentId = data.find(c => c.text === 'my super first comment').id
- await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId })
+ await servers[0].comments.delete({ videoId: videoUUID, commentId })
await waitJobs(servers)
})
it('Should have the threads marked as deleted on other servers too', async function () {
for (const server of servers) {
- const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
+ const body = await server.comments.listThreads({ videoId: videoUUID })
expect(body.total).to.equal(2)
expect(body.data).to.be.an('array')
it('Should delete a remote thread by the origin server', async function () {
this.timeout(5000)
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID })
+ const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
const commentId = data.find(c => c.text === 'my super second comment').id
- await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId })
+ await servers[0].comments.delete({ videoId: videoUUID, commentId })
await waitJobs(servers)
})
it('Should have the threads marked as deleted on other servers too', async function () {
for (const server of servers) {
- const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
+ const body = await server.comments.listThreads({ videoId: videoUUID })
expect(body.total).to.equal(2)
expect(body.data).to.have.lengthOf(2)
downloadEnabled: false
}
- await servers[0].videosCommand.update({ id: videoUUID, attributes })
+ await servers[0].videos.update({ id: videoUUID, attributes })
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
expect(video.commentsEnabled).to.be.false
expect(video.downloadEnabled).to.be.false
const text = 'my super forbidden comment'
- await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
+ await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
}
})
})
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === 'minimum parameters')
const isLocal = server.url === 'http://localhost:' + servers[1].port
const attributes = {
name: 'video',
- channelId: server.videoChannel.id,
+ channelId: server.store.channel.id,
privacy: VideoPrivacy.PUBLIC,
fixture: defaultFixture
}
const mimetype = 'video/mp4'
- const res = await server.videosCommand.prepareResumableUpload({ attributes, size, mimetype })
+ const res = await server.videos.prepareResumableUpload({ attributes, size, mimetype })
return res.header['location'].split('?')[1]
}
const size = await buildSize(defaultFixture, options.size)
const absoluteFilePath = buildAbsoluteFixturePath(defaultFixture)
- return server.videosCommand.sendResumableChunks({
+ return server.videos.sendResumableChunks({
pathUploadId,
videoFilePath: absoluteFilePath,
size,
const uploadId = uploadIdArg.replace(/^upload_id=/, '')
const subPath = join('tmp', 'resumable-uploads', uploadId)
- const filePath = server.serversCommand.buildDirectory(subPath)
+ const filePath = server.servers.buildDirectory(subPath)
const exists = await pathExists(filePath)
if (expectedSize === null) {
async function countResumableUploads () {
const subPath = join('tmp', 'resumable-uploads')
- const filePath = server.serversCommand.buildDirectory(subPath)
+ const filePath = server.servers.buildDirectory(subPath)
const files = await readdir(filePath)
return files.length
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
- const body = await server.usersCommand.getMyInfo()
+ const body = await server.users.getMyInfo()
rootId = body.id
- await server.usersCommand.update({ userId: rootId, videoQuota: 10_000_000 })
+ await server.users.update({ userId: rootId, videoQuota: 10_000_000 })
})
describe('Directory cleaning', function () {
})
it('Should not delete recent uploads', async function () {
- await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } })
+ await server.debug.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } })
expect(await countResumableUploads()).to.equal(2)
})
it('Should delete old uploads', async function () {
- await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } })
+ await server.debug.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } })
expect(await countResumableUploads()).to.equal(0)
})
})
it('Should list video categories', async function () {
- const categories = await server.videosCommand.getCategories()
+ const categories = await server.videos.getCategories()
expect(Object.keys(categories)).to.have.length.above(10)
expect(categories[11]).to.equal('News & Politics')
})
it('Should list video licences', async function () {
- const licences = await server.videosCommand.getLicences()
+ const licences = await server.videos.getLicences()
expect(Object.keys(licences)).to.have.length.above(5)
expect(licences[3]).to.equal('Attribution - No Derivatives')
})
it('Should list video languages', async function () {
- const languages = await server.videosCommand.getLanguages()
+ const languages = await server.videos.getLanguages()
expect(Object.keys(languages)).to.have.length.above(5)
expect(languages['ru']).to.equal('Russian')
})
it('Should list video privacies', async function () {
- const privacies = await server.videosCommand.getPrivacies()
+ const privacies = await server.videos.getPrivacies()
expect(Object.keys(privacies)).to.have.length.at.least(3)
expect(privacies[3]).to.equal('Private')
})
it('Should not have videos', async function () {
- const { data, total } = await server.videosCommand.list()
+ const { data, total } = await server.videos.list()
expect(total).to.equal(0)
expect(data).to.be.an('array')
licence: 6,
tags: [ 'tag1', 'tag2', 'tag3' ]
}
- const video = await server.videosCommand.upload({ attributes, mode })
+ const video = await server.videos.upload({ attributes, mode })
expect(video).to.not.be.undefined
expect(video.id).to.equal(1)
expect(video.uuid).to.have.length.above(5)
it('Should get and seed the uploaded video', async function () {
this.timeout(5000)
- const { data, total } = await server.videosCommand.list()
+ const { data, total } = await server.videos.list()
expect(total).to.equal(1)
expect(data).to.be.an('array')
it('Should get the video by UUID', async function () {
this.timeout(5000)
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
await completeVideoCheck(server, video, getCheckAttributes())
})
it('Should have the views updated', async function () {
this.timeout(20000)
- await server.videosCommand.view({ id: videoId })
- await server.videosCommand.view({ id: videoId })
- await server.videosCommand.view({ id: videoId })
+ await server.videos.view({ id: videoId })
+ await server.videos.view({ id: videoId })
+ await server.videos.view({ id: videoId })
await wait(1500)
- await server.videosCommand.view({ id: videoId })
- await server.videosCommand.view({ id: videoId })
+ await server.videos.view({ id: videoId })
+ await server.videos.view({ id: videoId })
await wait(1500)
- await server.videosCommand.view({ id: videoId })
- await server.videosCommand.view({ id: videoId })
+ await server.videos.view({ id: videoId })
+ await server.videos.view({ id: videoId })
// Wait the repeatable job
await wait(8000)
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.views).to.equal(3)
})
it('Should remove the video', async function () {
- await server.videosCommand.remove({ id: videoId })
+ await server.videos.remove({ id: videoId })
await checkVideoFilesWereRemoved(videoUUID, server)
})
it('Should not have videos', async function () {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(0)
expect(data).to.be.an('array')
fixture: video
}
- await server.videosCommand.upload({ attributes, mode })
+ await server.videos.upload({ attributes, mode })
}
})
it('Should have the correct durations', async function () {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(6)
expect(data).to.be.an('array')
})
it('Should have the correct thumbnails', async function () {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
// For the next test
videosListBase = data
})
it('Should list only the two first videos', async function () {
- const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: 'name' })
+ const { total, data } = await server.videos.list({ start: 0, count: 2, sort: 'name' })
expect(total).to.equal(6)
expect(data.length).to.equal(2)
})
it('Should list only the next three videos', async function () {
- const { total, data } = await server.videosCommand.list({ start: 2, count: 3, sort: 'name' })
+ const { total, data } = await server.videos.list({ start: 2, count: 3, sort: 'name' })
expect(total).to.equal(6)
expect(data.length).to.equal(3)
})
it('Should list the last video', async function () {
- const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name' })
+ const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name' })
expect(total).to.equal(6)
expect(data.length).to.equal(1)
})
it('Should not have the total field', async function () {
- const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name', skipCount: true })
+ const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name', skipCount: true })
expect(total).to.not.exist
expect(data.length).to.equal(1)
})
it('Should list and sort by name in descending order', async function () {
- const { total, data } = await server.videosCommand.list({ sort: '-name' })
+ const { total, data } = await server.videos.list({ sort: '-name' })
expect(total).to.equal(6)
expect(data.length).to.equal(6)
})
it('Should list and sort by trending in descending order', async function () {
- const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-trending' })
+ const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-trending' })
expect(total).to.equal(6)
expect(data.length).to.equal(2)
})
it('Should list and sort by hotness in descending order', async function () {
- const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-hot' })
+ const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-hot' })
expect(total).to.equal(6)
expect(data.length).to.equal(2)
})
it('Should list and sort by best in descending order', async function () {
- const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-best' })
+ const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-best' })
expect(total).to.equal(6)
expect(data.length).to.equal(2)
downloadEnabled: false,
tags: [ 'tagup1', 'tagup2' ]
}
- await server.videosCommand.update({ id: videoId, attributes })
+ await server.videos.update({ id: videoId, attributes })
})
it('Should filter by tags and category', async function () {
{
- const { data, total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] })
+ const { data, total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] })
expect(total).to.equal(1)
expect(data[0].name).to.equal('my super video updated')
}
{
- const { total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] })
+ const { total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] })
expect(total).to.equal(0)
}
})
it('Should have the video updated', async function () {
this.timeout(60000)
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
await completeVideoCheck(server, video, updateCheckAttributes())
})
const attributes = {
tags: [ 'supertag', 'tag1', 'tag2' ]
}
- await server.videosCommand.update({ id: videoId, attributes })
+ await server.videos.update({ id: videoId, attributes })
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
await completeVideoCheck(server, video, Object.assign(updateCheckAttributes(), attributes))
})
const attributes = {
description: 'hello everybody'
}
- await server.videosCommand.update({ id: videoId, attributes })
+ await server.videos.update({ id: videoId, attributes })
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes)
await completeVideoCheck(server, video, expectedAttributes)
})
it('Should like a video', async function () {
- await server.videosCommand.rate({ id: videoId, rating: 'like' })
+ await server.videos.rate({ id: videoId, rating: 'like' })
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.likes).to.equal(1)
expect(video.dislikes).to.equal(0)
})
it('Should dislike the same video', async function () {
- await server.videosCommand.rate({ id: videoId, rating: 'dislike' })
+ await server.videos.rate({ id: videoId, rating: 'dislike' })
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.likes).to.equal(0)
expect(video.dislikes).to.equal(1)
{
const now = new Date()
const attributes = { originallyPublishedAt: now.toISOString() }
- await server.videosCommand.update({ id: videoId, attributes })
+ await server.videos.update({ id: videoId, attributes })
- const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' })
+ const { data } = await server.videos.list({ sort: '-originallyPublishedAt' })
const names = data.map(v => v.name)
expect(names[0]).to.equal('my super video updated')
{
const now = new Date()
const attributes = { originallyPublishedAt: now.toISOString() }
- await server.videosCommand.update({ id: videoId2, attributes })
+ await server.videos.update({ id: videoId2, attributes })
- const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' })
+ const { data } = await server.videos.list({ sort: '-originallyPublishedAt' })
const names = data.map(v => v.name)
expect(names[0]).to.equal('video_short1.webm name')
await waitJobs(servers)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'my video name' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'my video name' } })
videoUUID = uuid
await waitJobs(servers)
it('Should list the captions and return an empty list', async function () {
for (const server of servers) {
- const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
expect(body.total).to.equal(0)
expect(body.data).to.have.lengthOf(0)
}
it('Should create two new captions', async function () {
this.timeout(30000)
- await servers[0].captionsCommand.createVideoCaption({
+ await servers[0].captions.createVideoCaption({
language: 'ar',
videoId: videoUUID,
fixture: 'subtitle-good1.vtt'
})
- await servers[0].captionsCommand.createVideoCaption({
+ await servers[0].captions.createVideoCaption({
language: 'zh',
videoId: videoUUID,
fixture: 'subtitle-good2.vtt',
it('Should list these uploaded captions', async function () {
for (const server of servers) {
- const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
expect(body.total).to.equal(2)
expect(body.data).to.have.lengthOf(2)
it('Should replace an existing caption', async function () {
this.timeout(30000)
- await servers[0].captionsCommand.createVideoCaption({
+ await servers[0].captions.createVideoCaption({
language: 'ar',
videoId: videoUUID,
fixture: 'subtitle-good2.vtt'
it('Should have this caption updated', async function () {
for (const server of servers) {
- const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
expect(body.total).to.equal(2)
expect(body.data).to.have.lengthOf(2)
it('Should replace an existing caption with a srt file and convert it', async function () {
this.timeout(30000)
- await servers[0].captionsCommand.createVideoCaption({
+ await servers[0].captions.createVideoCaption({
language: 'ar',
videoId: videoUUID,
fixture: 'subtitle-good.srt'
it('Should have this caption updated and converted', async function () {
for (const server of servers) {
- const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
expect(body.total).to.equal(2)
expect(body.data).to.have.lengthOf(2)
it('Should remove one caption', async function () {
this.timeout(30000)
- await servers[0].captionsCommand.deleteVideoCaption({ videoId: videoUUID, language: 'ar' })
+ await servers[0].captions.deleteVideoCaption({ videoId: videoUUID, language: 'ar' })
await waitJobs(servers)
})
it('Should only list the caption that was not deleted', async function () {
for (const server of servers) {
- const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
+ const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
expect(body.total).to.equal(1)
expect(body.data).to.have.lengthOf(1)
})
it('Should remove the video, and thus all video captions', async function () {
- await servers[0].videosCommand.remove({ id: videoUUID })
+ await servers[0].videos.remove({ id: videoUUID })
await checkVideoFilesWereRemoved(videoUUID, servers[0])
})
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: false
}
})
- firstUserToken = await servers[0].usersCommand.generateUserAndToken(firstUser)
- secondUserToken = await servers[0].usersCommand.generateUserAndToken(secondUser)
+ firstUserToken = await servers[0].users.generateUserAndToken(firstUser)
+ secondUserToken = await servers[0].users.generateUserAndToken(secondUser)
{
- const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: firstUserToken })
+ const { videoChannels } = await servers[0].users.getMyInfo({ token: firstUserToken })
firstUserChannelId = videoChannels[0].id
}
{
- const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: secondUserToken })
+ const { videoChannels } = await servers[0].users.getMyInfo({ token: secondUserToken })
secondUserChannelId = videoChannels[0].id
}
name: 'my super name',
description: 'my super description'
}
- const { id } = await servers[0].videosCommand.upload({ token: firstUserToken, attributes })
+ const { id } = await servers[0].videos.upload({ token: firstUserToken, attributes })
- servers[0].video = await servers[0].videosCommand.get({ id })
+ servers[0].store.video = await servers[0].videos.get({ id })
}
{
const attributes = { name: 'live', channelId: firstUserChannelId, privacy: VideoPrivacy.PUBLIC }
- const video = await servers[0].liveCommand.create({ token: firstUserToken, fields: attributes })
+ const video = await servers[0].live.create({ token: firstUserToken, fields: attributes })
liveId = video.id
}
- command = servers[0].changeOwnershipCommand
+ command = servers[0].changeOwnership
await doubleFollow(servers[0], servers[1])
})
it('Should send a request to change ownership of a video', async function () {
this.timeout(15000)
- await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser })
+ await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser })
})
it('Should only return a request to change ownership for the second user', async function () {
it('Should accept the same change ownership request without crashing', async function () {
this.timeout(10000)
- await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser })
+ await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser })
})
it('Should not create multiple change ownership requests while one is waiting', async function () {
it('Should send a new request to change ownership of a video', async function () {
this.timeout(15000)
- await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser })
+ await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser })
})
it('Should return two requests to change ownership for the second user', async function () {
it('Should have the channel of the video updated', async function () {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: servers[0].video.uuid })
+ const video = await server.videos.get({ id: servers[0].store.video.uuid })
expect(video.name).to.equal('my super name')
expect(video.channel.displayName).to.equal('Main second channel')
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: servers[0].video.uuid })
+ const video = await server.videos.get({ id: servers[0].store.video.uuid })
expect(video.name).to.equal('my super name')
expect(video.channel.displayName).to.equal('Main second channel')
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.usersCommand.create({ username: secondUser, videoQuota: 10 })
+ await server.users.create({ username: secondUser, videoQuota: 10 })
- firstUserToken = await server.usersCommand.generateUserAndToken(firstUser)
- secondUserToken = await server.loginCommand.getAccessToken(secondUser)
+ firstUserToken = await server.users.generateUserAndToken(firstUser)
+ secondUserToken = await server.login.getAccessToken(secondUser)
// Upload some videos on the server
const attributes = {
name: 'my super name',
description: 'my super description'
}
- await server.videosCommand.upload({ token: firstUserToken, attributes })
+ await server.videos.upload({ token: firstUserToken, attributes })
await waitJobs(server)
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data.length).to.equal(1)
- server.video = data.find(video => video.name === 'my super name')
+ server.store.video = data.find(video => video.name === 'my super name')
})
it('Should send a request to change ownership of a video', async function () {
this.timeout(15000)
- await server.changeOwnershipCommand.create({ token: firstUserToken, videoId: server.video.id, username: secondUser })
+ await server.changeOwnership.create({ token: firstUserToken, videoId: server.store.video.id, username: secondUser })
})
it('Should only return a request to change ownership for the second user', async function () {
{
- const body = await server.changeOwnershipCommand.list({ token: firstUserToken })
+ const body = await server.changeOwnership.list({ token: firstUserToken })
expect(body.total).to.equal(0)
expect(body.data).to.be.an('array')
}
{
- const body = await server.changeOwnershipCommand.list({ token: secondUserToken })
+ const body = await server.changeOwnership.list({ token: secondUserToken })
expect(body.total).to.equal(1)
expect(body.data).to.be.an('array')
it('Should not be possible to accept the change of ownership from second user because of exceeded quota', async function () {
this.timeout(10000)
- const { videoChannels } = await server.usersCommand.getMyInfo({ token: secondUserToken })
+ const { videoChannels } = await server.users.getMyInfo({ token: secondUserToken })
const channelId = videoChannels[0].id
- await server.changeOwnershipCommand.accept({
+ await server.changeOwnership.accept({
token: secondUserToken,
ownershipId: lastRequestId,
channelId,
const expect = chai.expect
async function findChannel (server: ServerInfo, channelId: number) {
- const body = await server.channelsCommand.list({ sort: '-name' })
+ const body = await server.channels.list({ sort: '-name' })
return body.data.find(c => c.id === channelId)
}
})
it('Should have one video channel (created with root)', async () => {
- const body = await servers[0].channelsCommand.list({ start: 0, count: 2 })
+ const body = await servers[0].channels.list({ start: 0, count: 2 })
expect(body.total).to.equal(1)
expect(body.data).to.be.an('array')
description: 'super video channel description',
support: 'super video channel support text'
}
- const created = await servers[0].channelsCommand.create({ attributes: videoChannel })
+ const created = await servers[0].channels.create({ attributes: videoChannel })
secondVideoChannelId = created.id
}
// The channel is 1 is propagated to servers 2
{
const attributes = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' }
- const { uuid } = await servers[0].videosCommand.upload({ attributes })
+ const { uuid } = await servers[0].videos.upload({ attributes })
videoUUID = uuid
}
})
it('Should have two video channels when getting my information', async () => {
- userInfo = await servers[0].usersCommand.getMyInfo()
+ userInfo = await servers[0].users.getMyInfo()
expect(userInfo.videoChannels).to.be.an('array')
expect(userInfo.videoChannels).to.have.lengthOf(2)
})
it('Should have two video channels when getting account channels on server 1', async function () {
- const body = await servers[0].channelsCommand.listByAccount({ accountName })
+ const body = await servers[0].channels.listByAccount({ accountName })
expect(body.total).to.equal(2)
const videoChannels = body.data
it('Should paginate and sort account channels', async function () {
{
- const body = await servers[0].channelsCommand.listByAccount({
+ const body = await servers[0].channels.listByAccount({
accountName,
start: 0,
count: 1,
}
{
- const body = await servers[0].channelsCommand.listByAccount({
+ const body = await servers[0].channels.listByAccount({
accountName,
start: 0,
count: 1,
}
{
- const body = await servers[0].channelsCommand.listByAccount({
+ const body = await servers[0].channels.listByAccount({
accountName,
start: 1,
count: 1,
})
it('Should have one video channel when getting account channels on server 2', async function () {
- const body = await servers[1].channelsCommand.listByAccount({ accountName })
+ const body = await servers[1].channels.listByAccount({ accountName })
expect(body.total).to.equal(1)
expect(body.data).to.be.an('array')
})
it('Should list video channels', async function () {
- const body = await servers[0].channelsCommand.list({ start: 1, count: 1, sort: '-name' })
+ const body = await servers[0].channels.list({ start: 1, count: 1, sort: '-name' })
expect(body.total).to.equal(2)
expect(body.data).to.be.an('array')
support: 'support updated'
}
- await servers[0].channelsCommand.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes })
+ await servers[0].channels.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes })
await waitJobs(servers)
})
it('Should have video channel updated', async function () {
for (const server of servers) {
- const body = await server.channelsCommand.list({ start: 0, count: 1, sort: '-name' })
+ const body = await server.channels.list({ start: 0, count: 1, sort: '-name' })
expect(body.total).to.equal(2)
expect(body.data).to.be.an('array')
it('Should not have updated the video support field', async function () {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
expect(video.support).to.equal('video support field')
}
})
bulkVideosSupportUpdate: true
}
- await servers[0].channelsCommand.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes })
+ await servers[0].channels.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes })
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
expect(video.support).to.equal(videoChannelAttributes.support)
}
})
const fixture = 'avatar.png'
- await servers[0].channelsCommand.updateImage({
+ await servers[0].channels.updateImage({
channelName: 'second_video_channel',
fixture,
type: 'avatar'
await testImage(server.url, 'avatar-resized', avatarPaths[server.port], '.png')
await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true)
- const row = await server.sqlCommand.getActorImage(basename(avatarPaths[server.port]))
+ const row = await server.sql.getActorImage(basename(avatarPaths[server.port]))
expect(row.height).to.equal(ACTOR_IMAGES_SIZE.AVATARS.height)
expect(row.width).to.equal(ACTOR_IMAGES_SIZE.AVATARS.width)
}
const fixture = 'banner.jpg'
- await servers[0].channelsCommand.updateImage({
+ await servers[0].channels.updateImage({
channelName: 'second_video_channel',
fixture,
type: 'banner'
await waitJobs(servers)
for (const server of servers) {
- const videoChannel = await server.channelsCommand.get({ channelName: 'second_video_channel@' + servers[0].host })
+ const videoChannel = await server.channels.get({ channelName: 'second_video_channel@' + servers[0].host })
bannerPaths[server.port] = videoChannel.banner.path
await testImage(server.url, 'banner-resized', bannerPaths[server.port])
await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true)
- const row = await server.sqlCommand.getActorImage(basename(bannerPaths[server.port]))
+ const row = await server.sql.getActorImage(basename(bannerPaths[server.port]))
expect(row.height).to.equal(ACTOR_IMAGES_SIZE.BANNERS.height)
expect(row.width).to.equal(ACTOR_IMAGES_SIZE.BANNERS.width)
}
it('Should delete the video channel avatar', async function () {
this.timeout(15000)
- await servers[0].channelsCommand.deleteImage({ channelName: 'second_video_channel', type: 'avatar' })
+ await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' })
await waitJobs(servers)
it('Should delete the video channel banner', async function () {
this.timeout(15000)
- await servers[0].channelsCommand.deleteImage({ channelName: 'second_video_channel', type: 'banner' })
+ await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'banner' })
await waitJobs(servers)
for (const server of servers) {
const channelURI = 'second_video_channel@localhost:' + servers[0].port
- const { total, data } = await server.videosCommand.listByChannel({ videoChannelName: channelURI })
+ const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI })
expect(total).to.equal(1)
expect(data).to.be.an('array')
it('Should change the video channel of a video', async function () {
this.timeout(10000)
- await servers[0].videosCommand.update({ id: videoUUID, attributes: { channelId: servers[0].videoChannel.id } })
+ await servers[0].videos.update({ id: videoUUID, attributes: { channelId: servers[0].store.channel.id } })
await waitJobs(servers)
})
for (const server of servers) {
{
const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
- const { total } = await server.videosCommand.listByChannel({ videoChannelName: secondChannelURI })
+ const { total } = await server.videos.listByChannel({ videoChannelName: secondChannelURI })
expect(total).to.equal(0)
}
{
const channelURI = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await server.videosCommand.listByChannel({ videoChannelName: channelURI })
+ const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI })
expect(total).to.equal(1)
expect(data).to.be.an('array')
})
it('Should delete video channel', async function () {
- await servers[0].channelsCommand.delete({ channelName: 'second_video_channel' })
+ await servers[0].channels.delete({ channelName: 'second_video_channel' })
})
it('Should have video channel deleted', async function () {
- const body = await servers[0].channelsCommand.list({ start: 0, count: 10 })
+ const body = await servers[0].channels.list({ start: 0, count: 10 })
expect(body.total).to.equal(1)
expect(body.data).to.be.an('array')
it('Should create the main channel with an uuid if there is a conflict', async function () {
{
const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' }
- const created = await servers[0].channelsCommand.create({ attributes: videoChannel })
+ const created = await servers[0].channels.create({ attributes: videoChannel })
totoChannel = created.id
}
{
- await servers[0].usersCommand.create({ username: 'toto', password: 'password' })
- const accessToken = await servers[0].loginCommand.getAccessToken({ username: 'toto', password: 'password' })
+ await servers[0].users.create({ username: 'toto', password: 'password' })
+ const accessToken = await servers[0].login.getAccessToken({ username: 'toto', password: 'password' })
- const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: accessToken })
+ const { videoChannels } = await servers[0].users.getMyInfo({ token: accessToken })
const videoChannel = videoChannels[0]
expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)
}
this.timeout(10000)
{
- const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true })
+ const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true })
for (const channel of data) {
expect(channel).to.haveOwnProperty('viewsPerDay')
}
{
- // video has been posted on channel servers[0].videoChannel.id since last update
- await servers[0].videosCommand.view({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1' })
- await servers[0].videosCommand.view({ id: videoUUID, xForwardedFor: '0.0.0.2,127.0.0.1' })
+ // video has been posted on channel servers[0].store.videoChannel.id since last update
+ await servers[0].videos.view({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1' })
+ await servers[0].videos.view({ id: videoUUID, xForwardedFor: '0.0.0.2,127.0.0.1' })
// Wait the repeatable job
await wait(8000)
- const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true })
- const channelWithView = data.find(channel => channel.id === servers[0].videoChannel.id)
+ const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true })
+ const channelWithView = data.find(channel => channel.id === servers[0].store.channel.id)
expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2)
}
})
it('Should report correct videos count', async function () {
- const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true })
+ const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true })
const totoChannel = data.find(c => c.name === 'toto_channel')
const rootChannel = data.find(c => c.name === 'root_channel')
it('Should search among account video channels', async function () {
{
- const body = await servers[0].channelsCommand.listByAccount({ accountName, search: 'root' })
+ const body = await servers[0].channels.listByAccount({ accountName, search: 'root' })
expect(body.total).to.equal(1)
const channels = body.data
}
{
- const body = await servers[0].channelsCommand.listByAccount({ accountName, search: 'does not exist' })
+ const body = await servers[0].channels.listByAccount({ accountName, search: 'does not exist' })
expect(body.total).to.equal(0)
const channels = body.data
it('Should list channels by updatedAt desc if a video has been uploaded', async function () {
this.timeout(30000)
- await servers[0].videosCommand.upload({ attributes: { channelId: totoChannel } })
+ await servers[0].videos.upload({ attributes: { channelId: totoChannel } })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.channelsCommand.listByAccount({ accountName, sort: '-updatedAt' })
+ const { data } = await server.channels.listByAccount({ accountName, sort: '-updatedAt' })
expect(data[0].name).to.equal('toto_channel')
expect(data[1].name).to.equal('root_channel')
}
- await servers[0].videosCommand.upload({ attributes: { channelId: servers[0].videoChannel.id } })
+ await servers[0].videos.upload({ attributes: { channelId: servers[0].store.channel.id } })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.channelsCommand.listByAccount({ accountName, sort: '-updatedAt' })
+ const { data } = await server.channels.listByAccount({ accountName, sort: '-updatedAt' })
expect(data[0].name).to.equal('root_channel')
expect(data[1].name).to.equal('toto_channel')
await setAccessTokensToServers([ server ])
- const { id, uuid } = await server.videosCommand.upload()
+ const { id, uuid } = await server.videos.upload()
videoUUID = uuid
videoId = id
- await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' })
+ await server.users.updateMyAvatar({ fixture: 'avatar.png' })
- userAccessTokenServer1 = await server.usersCommand.generateUserAndToken('user1')
+ userAccessTokenServer1 = await server.users.generateUserAndToken('user1')
- command = server.commentsCommand
+ command = server.comments
})
describe('User comments', function () {
const attributes = {
description: longDescription
}
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
await waitJobs(servers)
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
videoId = data[0].id
videoUUID = data[0].uuid
it('Should have a truncated description on each server', async function () {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
// 30 characters * 6 -> 240 characters
const truncatedDescription = 'my super description for server 1'.repeat(7) +
it('Should fetch long description on each server', async function () {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
- const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath })
+ const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
expect(description).to.equal(longDescription)
}
})
const attributes = {
description: 'short description'
}
- await servers[0].videosCommand.update({ id: videoId, attributes })
+ await servers[0].videos.update({ id: videoId, attributes })
await waitJobs(servers)
})
it('Should have a small description on each server', async function () {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
expect(video.description).to.equal('short description')
- const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath })
+ const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
expect(description).to.equal('short description')
}
})
async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) {
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videoUUID })
+ const videoDetails = await server.videos.get({ id: videoUUID })
const baseUrl = `http://${videoDetails.account.host}`
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
{
await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions })
- const masterPlaylist = await server.streamingPlaylistsCommand.get({ url: hlsPlaylist.playlistUrl })
+ const masterPlaylist = await server.streamingPlaylists.get({ url: hlsPlaylist.playlistUrl })
for (const resolution of resolutions) {
expect(masterPlaylist).to.contain(`${resolution}.m3u8`)
{
for (const resolution of resolutions) {
- const subPlaylist = await server.streamingPlaylistsCommand.get({
+ const subPlaylist = await server.streamingPlaylists.get({
url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`
})
it('Should upload a video and transcode it to HLS', async function () {
this.timeout(120000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } })
videoUUID = uuid
await waitJobs(servers)
it('Should upload an audio file and transcode it to HLS', async function () {
this.timeout(120000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } })
videoAudioUUID = uuid
await waitJobs(servers)
it('Should update the video', async function () {
this.timeout(10000)
- await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video 1 updated' } })
+ await servers[0].videos.update({ id: videoUUID, attributes: { name: 'video 1 updated' } })
await waitJobs(servers)
it('Should delete videos', async function () {
this.timeout(10000)
- await servers[0].videosCommand.remove({ id: videoUUID })
- await servers[0].videosCommand.remove({ id: videoAudioUUID })
+ await servers[0].videos.remove({ id: videoUUID })
+ await servers[0].videos.remove({ id: videoAudioUUID })
await waitJobs(servers)
for (const server of servers) {
- await server.videosCommand.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
- await server.videosCommand.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.videos.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.videos.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
}
})
describe('With only HLS enabled', function () {
before(async function () {
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: true,
if (areHttpImportTestsDisabled()) return
async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) {
- const videoHttp = await server.videosCommand.get({ id: idHttp })
+ const videoHttp = await server.videos.get({ id: idHttp })
expect(videoHttp.name).to.equal('small video - youtube')
// FIXME: youtube-dl seems broken
expect(originallyPublishedAt.getMonth()).to.equal(0)
expect(originallyPublishedAt.getFullYear()).to.equal(2019)
- const videoMagnet = await server.videosCommand.get({ id: idMagnet })
- const videoTorrent = await server.videosCommand.get({ id: idTorrent })
+ const videoMagnet = await server.videos.get({ id: idMagnet })
+ const videoTorrent = await server.videos.get({ id: idTorrent })
for (const video of [ videoMagnet, videoTorrent ]) {
expect(video.category.label).to.equal('Misc')
expect(videoTorrent.name).to.contain('ä½ å¥½ 世界 720p.mp4')
expect(videoMagnet.name).to.contain('super peertube2 video')
- const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: idHttp })
+ const bodyCaptions = await server.captions.listVideoCaptions({ videoId: idHttp })
expect(bodyCaptions.total).to.equal(2)
}
async function checkVideoServer2 (server: ServerInfo, id: number | string) {
- const video = await server.videosCommand.get({ id })
+ const video = await server.videos.get({ id })
expect(video.name).to.equal('my super name')
expect(video.category.label).to.equal('Entertainment')
expect(video.files).to.have.lengthOf(1)
- const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: id })
+ const bodyCaptions = await server.captions.listVideoCaptions({ videoId: id })
expect(bodyCaptions.total).to.equal(2)
}
await setAccessTokensToServers(servers)
{
- const { videoChannels } = await servers[0].usersCommand.getMyInfo()
+ const { videoChannels } = await servers[0].users.getMyInfo()
channelIdServer1 = videoChannels[0].id
}
{
- const { videoChannels } = await servers[1].usersCommand.getMyInfo()
+ const { videoChannels } = await servers[1].users.getMyInfo()
channelIdServer2 = videoChannels[0].id
}
{
const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() }
- const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video } = await servers[0].imports.importVideo({ attributes })
expect(video.name).to.equal('small video - youtube')
expect(video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`))
await testImage(servers[0].url, 'video_import_thumbnail', video.thumbnailPath)
await testImage(servers[0].url, 'video_import_preview', video.previewPath)
- const bodyCaptions = await servers[0].captionsCommand.listVideoCaptions({ videoId: video.id })
+ const bodyCaptions = await servers[0].captions.listVideoCaptions({ videoId: video.id })
const videoCaptions = bodyCaptions.data
expect(videoCaptions).to.have.lengthOf(2)
description: 'this is a super torrent description',
tags: [ 'tag_torrent1', 'tag_torrent2' ]
}
- const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video } = await servers[0].imports.importVideo({ attributes })
expect(video.name).to.equal('super peertube2 video')
}
description: 'this is a super torrent description',
tags: [ 'tag_torrent1', 'tag_torrent2' ]
}
- const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video } = await servers[0].imports.importVideo({ attributes })
expect(video.name).to.equal('ä½ å¥½ 世界 720p.mp4')
}
})
it('Should list the videos to import in my videos on server 1', async function () {
- const { total, data } = await servers[0].videosCommand.listMyVideos({ sort: 'createdAt' })
+ const { total, data } = await servers[0].videos.listMyVideos({ sort: 'createdAt' })
expect(total).to.equal(3)
})
it('Should list the videos to import in my imports on server 1', async function () {
- const { total, data: videoImports } = await servers[0].importsCommand.getMyVideoImports({ sort: '-createdAt' })
+ const { total, data: videoImports } = await servers[0].imports.getMyVideoImports({ sort: '-createdAt' })
expect(total).to.equal(3)
expect(videoImports).to.have.lengthOf(3)
await waitJobs(servers)
for (const server of servers) {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(3)
expect(data).to.have.lengthOf(3)
description: 'my super description',
tags: [ 'supertag1', 'supertag2' ]
}
- const { video } = await servers[1].importsCommand.importVideo({ attributes })
+ const { video } = await servers[1].imports.importVideo({ attributes })
expect(video.name).to.equal('my super name')
})
await waitJobs(servers)
for (const server of servers) {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(4)
expect(data).to.have.lengthOf(4)
channelId: channelIdServer2,
privacy: VideoPrivacy.PUBLIC
}
- const { video } = await servers[1].importsCommand.importVideo({ attributes })
+ const { video } = await servers[1].imports.importVideo({ attributes })
const videoUUID = video.uuid
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
expect(video.name).to.equal('transcoded video')
expect(video.files).to.have.lengthOf(4)
}
}
}
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
const attributes = {
name: 'hdr video',
channelId: channelIdServer1,
privacy: VideoPrivacy.PUBLIC
}
- const { video: videoImported } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video: videoImported } = await servers[0].imports.importVideo({ attributes })
const videoUUID = videoImported.uuid
await waitJobs(servers)
// test resolution
- const video = await servers[0].videosCommand.get({ id: videoUUID })
+ const video = await servers[0].videos.get({ id: videoUUID })
expect(video.name).to.equal('hdr video')
const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id }))
expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P)
let customConfig: CustomConfig
async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) {
- const user = await server.usersCommand.getMyInfo()
+ const user = await server.users.getMyInfo()
const videoChannelName = user.videoChannels[0].name
const accountName = user.account.name + '@' + user.account.host
const hasQuery = Object.keys(query).length !== 0
if (token) {
promises = [
- server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }),
- server.videosCommand.listWithToken({ token, ...query }),
- server.videosCommand.listByAccount({ token, accountName, ...query }),
- server.videosCommand.listByChannel({ token, videoChannelName, ...query })
+ server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }),
+ server.videos.listWithToken({ token, ...query }),
+ server.videos.listByAccount({ token, accountName, ...query }),
+ server.videos.listByChannel({ token, videoChannelName, ...query })
]
// Overviews do not support video filters
if (!hasQuery) {
- const p = server.overviewsCommand.getVideos({ page: 1, token })
+ const p = server.overviews.getVideos({ page: 1, token })
.then(res => createOverviewRes(res))
promises.push(p)
}
}
promises = [
- server.searchCommand.searchVideos({ search: 'n', sort: '-publishedAt' }),
- server.videosCommand.list(),
- server.videosCommand.listByAccount({ accountName }),
- server.videosCommand.listByChannel({ videoChannelName })
+ server.search.searchVideos({ search: 'n', sort: '-publishedAt' }),
+ server.videos.list(),
+ server.videos.listByAccount({ accountName }),
+ server.videos.listByChannel({ videoChannelName })
]
// Overviews do not support video filters
if (!hasQuery) {
- const p = server.overviewsCommand.getVideos({ page: 1 })
+ const p = server.overviews.getVideos({ page: 1 })
.then(res => createOverviewRes(res))
promises.push(p)
}
{
const attributes = { name: 'nsfw', nsfw: true, category: 1 }
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
}
{
const attributes = { name: 'normal', nsfw: false, category: 1 }
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
}
- customConfig = await server.configCommand.getCustomConfig()
+ customConfig = await server.config.getCustomConfig()
})
describe('Instance default NSFW policy', function () {
it('Should display NSFW videos with display default NSFW policy', async function () {
- const serverConfig = await server.configCommand.getConfig()
+ const serverConfig = await server.config.getConfig()
expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display')
for (const body of await getVideosFunctions()) {
it('Should not display NSFW videos with do_not_list default NSFW policy', async function () {
customConfig.instance.defaultNSFWPolicy = 'do_not_list'
- await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig })
+ await server.config.updateCustomConfig({ newCustomConfig: customConfig })
- const serverConfig = await server.configCommand.getConfig()
+ const serverConfig = await server.config.getConfig()
expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list')
for (const body of await getVideosFunctions()) {
it('Should display NSFW videos with blur default NSFW policy', async function () {
customConfig.instance.defaultNSFWPolicy = 'blur'
- await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig })
+ await server.config.updateCustomConfig({ newCustomConfig: customConfig })
- const serverConfig = await server.configCommand.getConfig()
+ const serverConfig = await server.config.getConfig()
expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur')
for (const body of await getVideosFunctions()) {
it('Should create a user having the default nsfw policy', async function () {
const username = 'user1'
const password = 'my super password'
- await server.usersCommand.create({ username: username, password: password })
+ await server.users.create({ username: username, password: password })
- userAccessToken = await server.loginCommand.getAccessToken({ username, password })
+ userAccessToken = await server.login.getAccessToken({ username, password })
- const user = await server.usersCommand.getMyInfo({ token: userAccessToken })
+ const user = await server.users.getMyInfo({ token: userAccessToken })
expect(user.nsfwPolicy).to.equal('blur')
})
it('Should display NSFW videos with blur user NSFW policy', async function () {
customConfig.instance.defaultNSFWPolicy = 'do_not_list'
- await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig })
+ await server.config.updateCustomConfig({ newCustomConfig: customConfig })
for (const body of await getVideosFunctions(userAccessToken)) {
expect(body.total).to.equal(2)
})
it('Should display NSFW videos with display user NSFW policy', async function () {
- await server.usersCommand.updateMe({ nsfwPolicy: 'display' })
+ await server.users.updateMe({ nsfwPolicy: 'display' })
for (const body of await getVideosFunctions(server.accessToken)) {
expect(body.total).to.equal(2)
})
it('Should not display NSFW videos with do_not_list user NSFW policy', async function () {
- await server.usersCommand.updateMe({ nsfwPolicy: 'do_not_list' })
+ await server.users.updateMe({ nsfwPolicy: 'do_not_list' })
for (const body of await getVideosFunctions(server.accessToken)) {
expect(body.total).to.equal(1)
})
it('Should be able to see my NSFW videos even with do_not_list user NSFW policy', async function () {
- const { total, data } = await server.videosCommand.listMyVideos()
+ const { total, data } = await server.videos.listMyVideos()
expect(total).to.equal(2)
expect(data).to.have.lengthOf(2)
let video2: number
async function getPlaylistWithoutThumbnail (server: ServerInfo) {
- const body = await server.playlistsCommand.list({ start: 0, count: 10 })
+ const body = await server.playlists.list({ start: 0, count: 10 })
return body.data.find(p => p.displayName === 'playlist without thumbnail')
}
async function getPlaylistWithThumbnail (server: ServerInfo) {
- const body = await server.playlistsCommand.list({ start: 0, count: 10 })
+ const body = await server.playlists.list({ start: 0, count: 10 })
return body.data.find(p => p.displayName === 'playlist with thumbnail')
}
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).id
- video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).id
+ video1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).id
+ video2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).id
await waitJobs(servers)
})
it('Should automatically update the thumbnail when adding an element', async function () {
this.timeout(30000)
- const created = await servers[1].playlistsCommand.create({
+ const created = await servers[1].playlists.create({
attributes: {
displayName: 'playlist without thumbnail',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[1].videoChannel.id
+ videoChannelId: servers[1].store.channel.id
}
})
playlistWithoutThumbnailId = created.id
- const added = await servers[1].playlistsCommand.addElement({
+ const added = await servers[1].playlists.addElement({
playlistId: playlistWithoutThumbnailId,
attributes: { videoId: video1 }
})
it('Should not update the thumbnail if we explicitly uploaded a thumbnail', async function () {
this.timeout(30000)
- const created = await servers[1].playlistsCommand.create({
+ const created = await servers[1].playlists.create({
attributes: {
displayName: 'playlist with thumbnail',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[1].videoChannel.id,
+ videoChannelId: servers[1].store.channel.id,
thumbnailfile: 'thumbnail.jpg'
}
})
playlistWithThumbnailId = created.id
- const added = await servers[1].playlistsCommand.addElement({
+ const added = await servers[1].playlists.addElement({
playlistId: playlistWithThumbnailId,
attributes: { videoId: video1 }
})
it('Should automatically update the thumbnail when moving the first element', async function () {
this.timeout(30000)
- const added = await servers[1].playlistsCommand.addElement({
+ const added = await servers[1].playlists.addElement({
playlistId: playlistWithoutThumbnailId,
attributes: { videoId: video2 }
})
withoutThumbnailE2 = added.id
- await servers[1].playlistsCommand.reorderElements({
+ await servers[1].playlists.reorderElements({
playlistId: playlistWithoutThumbnailId,
attributes: {
startPosition: 1,
it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', async function () {
this.timeout(30000)
- const added = await servers[1].playlistsCommand.addElement({
+ const added = await servers[1].playlists.addElement({
playlistId: playlistWithThumbnailId,
attributes: { videoId: video2 }
})
withThumbnailE2 = added.id
- await servers[1].playlistsCommand.reorderElements({
+ await servers[1].playlists.reorderElements({
playlistId: playlistWithThumbnailId,
attributes: {
startPosition: 1,
it('Should automatically update the thumbnail when deleting the first element', async function () {
this.timeout(30000)
- await servers[1].playlistsCommand.removeElement({
+ await servers[1].playlists.removeElement({
playlistId: playlistWithoutThumbnailId,
elementId: withoutThumbnailE1
})
it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', async function () {
this.timeout(30000)
- await servers[1].playlistsCommand.removeElement({
+ await servers[1].playlists.removeElement({
playlistId: playlistWithThumbnailId,
elementId: withThumbnailE1
})
it('Should the thumbnail when we delete the last element', async function () {
this.timeout(30000)
- await servers[1].playlistsCommand.removeElement({
+ await servers[1].playlists.removeElement({
playlistId: playlistWithoutThumbnailId,
elementId: withoutThumbnailE2
})
it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', async function () {
this.timeout(30000)
- await servers[1].playlistsCommand.removeElement({
+ await servers[1].playlists.removeElement({
playlistId: playlistWithThumbnailId,
elementId: withThumbnailE2
})
total: number
) {
for (const server of servers) {
- const body = await server.playlistsCommand.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 })
+ const body = await server.playlists.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 })
expect(body.total).to.equal(total)
const videoElement = body.data.find(e => e.position === position)
// Server 1 and server 3 follow each other
await doubleFollow(servers[0], servers[2])
- commands = servers.map(s => s.playlistsCommand)
+ commands = servers.map(s => s.playlists)
{
- servers[0].videos = []
- servers[1].videos = []
- servers[2].videos = []
+ servers[0].store.videos = []
+ servers[1].store.videos = []
+ servers[2].store.videos = []
for (const server of servers) {
for (let i = 0; i < 7; i++) {
const name = `video ${i} server ${server.serverNumber}`
- const video = await server.videosCommand.upload({ attributes: { name, nsfw: false } })
+ const video = await server.videos.upload({ attributes: { name, nsfw: false } })
- server.videos.push(video)
+ server.store.videos.push(video)
}
}
}
- nsfwVideoServer1 = (await servers[0].videosCommand.quickUpload({ name: 'NSFW video', nsfw: true })).id
+ nsfwVideoServer1 = (await servers[0].videos.quickUpload({ name: 'NSFW video', nsfw: true })).id
- userTokenServer1 = await servers[0].usersCommand.generateUserAndToken('user1')
+ userTokenServer1 = await servers[0].users.generateUserAndToken('user1')
await waitJobs(servers)
})
})
it('Should get private playlist for a classic user', async function () {
- const token = await servers[0].usersCommand.generateUserAndToken('toto')
+ const token = await servers[0].users.generateUserAndToken('toto')
const body = await commands[0].listByAccount({ token, handle: 'toto' })
privacy: VideoPlaylistPrivacy.PUBLIC,
description: 'my super description',
thumbnailfile: 'thumbnail.jpg',
- videoChannelId: servers[0].videoChannel.id
+ videoChannelId: servers[0].store.channel.id
}
})
await wait(3000)
for (const server of servers) {
- const body = await server.playlistsCommand.list({ start: 0, count: 5 })
+ const body = await server.playlists.list({ start: 0, count: 5 })
expect(body.total).to.equal(1)
expect(body.data).to.have.lengthOf(1)
const playlistFromList = body.data[0]
- const playlistFromGet = await server.playlistsCommand.get({ playlistId: playlistFromList.uuid })
+ const playlistFromGet = await server.playlists.get({ playlistId: playlistFromList.uuid })
for (const playlist of [ playlistFromGet, playlistFromList ]) {
expect(playlist.id).to.be.a('number')
this.timeout(30000)
{
- const playlist = await servers[1].playlistsCommand.create({
+ const playlist = await servers[1].playlists.create({
attributes: {
displayName: 'playlist 2',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[1].videoChannel.id
+ videoChannelId: servers[1].store.channel.id
}
})
playlistServer2Id1 = playlist.id
}
{
- const playlist = await servers[1].playlistsCommand.create({
+ const playlist = await servers[1].playlists.create({
attributes: {
displayName: 'playlist 3',
privacy: VideoPlaylistPrivacy.PUBLIC,
thumbnailfile: 'thumbnail.jpg',
- videoChannelId: servers[1].videoChannel.id
+ videoChannelId: servers[1].store.channel.id
}
})
}
for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) {
- await servers[1].playlistsCommand.addElement({
+ await servers[1].playlists.addElement({
playlistId: id,
- attributes: { videoId: servers[1].videos[0].id, startTimestamp: 1, stopTimestamp: 2 }
+ attributes: { videoId: servers[1].store.videos[0].id, startTimestamp: 1, stopTimestamp: 2 }
})
- await servers[1].playlistsCommand.addElement({
+ await servers[1].playlists.addElement({
playlistId: id,
- attributes: { videoId: servers[1].videos[1].id }
+ attributes: { videoId: servers[1].store.videos[1].id }
})
}
await wait(3000)
for (const server of [ servers[0], servers[1] ]) {
- const body = await server.playlistsCommand.list({ start: 0, count: 5 })
+ const body = await server.playlists.list({ start: 0, count: 5 })
const playlist2 = body.data.find(p => p.displayName === 'playlist 2')
expect(playlist2).to.not.be.undefined
await testImage(server.url, 'thumbnail', playlist3.thumbnailPath)
}
- const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 })
+ const body = await servers[2].playlists.list({ start: 0, count: 5 })
expect(body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined
expect(body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined
})
// Server 2 and server 3 follow each other
await doubleFollow(servers[1], servers[2])
- const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 })
+ const body = await servers[2].playlists.list({ start: 0, count: 5 })
const playlist2 = body.data.find(p => p.displayName === 'playlist 2')
expect(playlist2).to.not.be.undefined
this.timeout(30000)
{
- const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: 'createdAt' })
+ const body = await servers[2].playlists.list({ start: 1, count: 2, sort: 'createdAt' })
expect(body.total).to.equal(3)
const data = body.data
}
{
- const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: '-createdAt' })
+ const body = await servers[2].playlists.list({ start: 1, count: 2, sort: '-createdAt' })
expect(body.total).to.equal(3)
const data = body.data
this.timeout(30000)
{
- const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' })
+ const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' })
expect(body.total).to.equal(2)
const data = body.data
}
{
- const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' })
+ const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' })
expect(body.total).to.equal(2)
const data = body.data
}
{
- const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' })
+ const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' })
expect(body.total).to.equal(1)
const data = body.data
}
{
- const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' })
+ const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' })
expect(body.total).to.equal(0)
const data = body.data
this.timeout(30000)
{
- unlistedPlaylist = await servers[1].playlistsCommand.create({
+ unlistedPlaylist = await servers[1].playlists.create({
attributes: {
displayName: 'playlist unlisted',
privacy: VideoPlaylistPrivacy.UNLISTED,
- videoChannelId: servers[1].videoChannel.id
+ videoChannelId: servers[1].store.channel.id
}
})
}
{
- privatePlaylist = await servers[1].playlistsCommand.create({
+ privatePlaylist = await servers[1].playlists.create({
attributes: {
displayName: 'playlist private',
privacy: VideoPlaylistPrivacy.PRIVATE
it('Should not list unlisted or private playlists', async function () {
for (const server of servers) {
const results = [
- await server.playlistsCommand.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }),
- await server.playlistsCommand.list({ start: 0, count: 2, sort: '-createdAt' })
+ await server.playlists.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }),
+ await server.playlists.list({ start: 0, count: 2, sort: '-createdAt' })
]
expect(results[0].total).to.equal(2)
})
it('Should not get unlisted playlist using only the id', async function () {
- await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 })
+ await servers[1].playlists.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 })
})
it('Should get unlisted plyaylist using uuid or shortUUID', async function () {
- await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.uuid })
- await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.shortUUID })
+ await servers[1].playlists.get({ playlistId: unlistedPlaylist.uuid })
+ await servers[1].playlists.get({ playlistId: unlistedPlaylist.shortUUID })
})
it('Should not get private playlist without token', async function () {
for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) {
- await servers[1].playlistsCommand.get({ playlistId: id, expectedStatus: 401 })
+ await servers[1].playlists.get({ playlistId: id, expectedStatus: 401 })
}
})
it('Should get private playlist with a token', async function () {
for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) {
- await servers[1].playlistsCommand.get({ token: servers[1].accessToken, playlistId: id })
+ await servers[1].playlists.get({ token: servers[1].accessToken, playlistId: id })
}
})
})
it('Should update a playlist', async function () {
this.timeout(30000)
- await servers[1].playlistsCommand.update({
+ await servers[1].playlists.update({
attributes: {
displayName: 'playlist 3 updated',
description: 'description updated',
privacy: VideoPlaylistPrivacy.UNLISTED,
thumbnailfile: 'thumbnail.jpg',
- videoChannelId: servers[1].videoChannel.id
+ videoChannelId: servers[1].store.channel.id
},
playlistId: playlistServer2Id2
})
await waitJobs(servers)
for (const server of servers) {
- const playlist = await server.playlistsCommand.get({ playlistId: playlistServer2UUID2 })
+ const playlist = await server.playlists.get({ playlistId: playlistServer2UUID2 })
expect(playlist.displayName).to.equal('playlist 3 updated')
expect(playlist.description).to.equal('description updated')
attributes: {
displayName: 'playlist 4',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[0].videoChannel.id
+ videoChannelId: servers[0].store.channel.id
}
})
playlistServer1Id = playlist.id
playlistServer1UUID = playlist.uuid
- await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 })
- await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 })
- await addVideo({ videoId: servers[2].videos[2].uuid })
+ await addVideo({ videoId: servers[0].store.videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 })
+ await addVideo({ videoId: servers[2].store.videos[1].uuid, startTimestamp: 35 })
+ await addVideo({ videoId: servers[2].store.videos[2].uuid })
{
- const element = await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 })
+ const element = await addVideo({ videoId: servers[0].store.videos[3].uuid, stopTimestamp: 35 })
playlistElementServer1Video4 = element.id
}
{
- const element = await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 })
+ const element = await addVideo({ videoId: servers[0].store.videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 })
playlistElementServer1Video5 = element.id
}
for (const server of servers) {
{
- const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
+ const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
expect(body.total).to.equal(8)
}
{
- const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 })
+ const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 })
expect(body.data).to.have.lengthOf(2)
}
}
attributes: {
displayName: 'playlist 56',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[0].videoChannel.id
+ videoChannelId: servers[0].store.channel.id
}
})
return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes })
}
- video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid
- video2 = (await servers[1].videosCommand.quickUpload({ name: 'video 90' })).uuid
- video3 = (await servers[0].videosCommand.quickUpload({ name: 'video 91', nsfw: true })).uuid
+ video1 = (await servers[0].videos.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid
+ video2 = (await servers[1].videos.quickUpload({ name: 'video 90' })).uuid
+ video3 = (await servers[0].videos.quickUpload({ name: 'video 91', nsfw: true })).uuid
await waitJobs(servers)
const position = 1
{
- await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } })
+ await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } })
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
}
{
- await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } })
+ await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } })
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
const position = 1
{
- await servers[0].blacklistCommand.add({ videoId: video1, reason: 'reason', unfederate: true })
+ await servers[0].blacklist.add({ videoId: video1, reason: 'reason', unfederate: true })
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
}
{
- await servers[0].blacklistCommand.remove({ videoId: video1 })
+ await servers[0].blacklist.remove({ videoId: video1 })
await waitJobs(servers)
await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
it('Should update the element type if the account or server of the video is blocked', async function () {
this.timeout(90000)
- const command = servers[0].blocklistCommand
+ const command = servers[0].blocklist
const name = 'video 90'
const position = 2
await waitJobs(servers)
for (const server of servers) {
- const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
+ const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
const names = body.data.map(v => v.video.name)
expect(names).to.deep.equal([
await waitJobs(servers)
for (const server of servers) {
- const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
+ const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
const names = body.data.map(v => v.video.name)
expect(names).to.deep.equal([
await waitJobs(servers)
for (const server of servers) {
- const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
+ const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
const names = elements.map(v => v.video.name)
expect(names).to.deep.equal([
await waitJobs(servers)
for (const server of servers) {
- const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
+ const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
expect(elements[0].video.name).to.equal('video 3 server 1')
expect(elements[0].position).to.equal(1)
it('Should check videos existence in my playlist', async function () {
const videoIds = [
- servers[0].videos[0].id,
+ servers[0].store.videos[0].id,
42000,
- servers[0].videos[3].id,
+ servers[0].store.videos[3].id,
43000,
- servers[0].videos[4].id
+ servers[0].store.videos[4].id
]
const obj = await commands[0].videosExist({ videoIds })
{
- const elem = obj[servers[0].videos[0].id]
+ const elem = obj[servers[0].store.videos[0].id]
expect(elem).to.have.lengthOf(1)
expect(elem[0].playlistElementId).to.exist
expect(elem[0].playlistId).to.equal(playlistServer1Id)
}
{
- const elem = obj[servers[0].videos[3].id]
+ const elem = obj[servers[0].store.videos[3].id]
expect(elem).to.have.lengthOf(1)
expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4)
expect(elem[0].playlistId).to.equal(playlistServer1Id)
}
{
- const elem = obj[servers[0].videos[4].id]
+ const elem = obj[servers[0].store.videos[4].id]
expect(elem).to.have.lengthOf(1)
expect(elem[0].playlistId).to.equal(playlistServer1Id)
expect(elem[0].startTimestamp).to.equal(45)
it('Should automatically update updatedAt field of playlists', async function () {
const server = servers[1]
- const videoId = servers[1].videos[5].id
+ const videoId = servers[1].store.videos[5].id
async function getPlaylistNames () {
- const { data } = await server.playlistsCommand.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' })
+ const { data } = await server.playlists.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' })
return data.map(p => p.displayName)
}
const attributes = { videoId }
- const element1 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id1, attributes })
- const element2 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id2, attributes })
+ const element1 = await server.playlists.addElement({ playlistId: playlistServer2Id1, attributes })
+ const element2 = await server.playlists.addElement({ playlistId: playlistServer2Id2, attributes })
const names1 = await getPlaylistNames()
expect(names1[0]).to.equal('playlist 3 updated')
expect(names1[1]).to.equal('playlist 2')
- await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id })
+ await server.playlists.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id })
const names2 = await getPlaylistNames()
expect(names2[0]).to.equal('playlist 2')
expect(names2[1]).to.equal('playlist 3 updated')
- await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id })
+ await server.playlists.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id })
const names3 = await getPlaylistNames()
expect(names3[0]).to.equal('playlist 3 updated')
await waitJobs(servers)
for (const server of servers) {
- const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
+ const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
expect(body.total).to.equal(6)
const elements = body.data
attributes: {
displayName: 'my super public playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[0].videoChannel.id
+ videoChannelId: servers[0].store.channel.id
}
})
await waitJobs(servers)
for (const server of servers) {
- await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 })
+ await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 })
}
const attributes = { privacy: VideoPlaylistPrivacy.PRIVATE }
await waitJobs(servers)
for (const server of [ servers[1], servers[2] ]) {
- await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
}
await commands[0].get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
await waitJobs(servers)
for (const server of servers) {
- await server.playlistsCommand.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.playlists.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
}
})
const finder = (data: VideoPlaylist[]) => data.find(p => p.displayName === 'my super playlist')
{
- const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 })
+ const body = await servers[2].playlists.list({ start: 0, count: 5 })
expect(body.total).to.equal(3)
expect(finder(body.data)).to.not.be.undefined
}
- await servers[2].followsCommand.unfollow({ target: servers[0] })
+ await servers[2].follows.unfollow({ target: servers[0] })
{
- const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 })
+ const body = await servers[2].playlists.list({ start: 0, count: 5 })
expect(body.total).to.equal(1)
expect(finder(body.data)).to.be.undefined
it('Should delete a channel and put the associated playlist in private mode', async function () {
this.timeout(30000)
- const channel = await servers[0].channelsCommand.create({ attributes: { name: 'super_channel', displayName: 'super channel' } })
+ const channel = await servers[0].channels.create({ attributes: { name: 'super_channel', displayName: 'super channel' } })
const playlistCreated = await commands[0].create({
attributes: {
await waitJobs(servers)
- await servers[0].channelsCommand.delete({ channelName: 'super_channel' })
+ await servers[0].channels.delete({ channelName: 'super_channel' })
await waitJobs(servers)
expect(body.displayName).to.equal('channel playlist')
expect(body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
- await servers[1].playlistsCommand.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[1].playlists.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Should delete an account and delete its playlists', async function () {
this.timeout(30000)
- const { userId, token } = await servers[0].usersCommand.generate('user_1')
+ const { userId, token } = await servers[0].users.generate('user_1')
- const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token })
+ const { videoChannels } = await servers[0].users.getMyInfo({ token })
const userChannel = videoChannels[0]
await commands[0].create({
{
for (const server of [ servers[0], servers[1] ]) {
- const body = await server.playlistsCommand.list({ start: 0, count: 15 })
+ const body = await server.playlists.list({ start: 0, count: 15 })
expect(finder(body.data)).to.not.be.undefined
}
}
- await servers[0].usersCommand.remove({ userId })
+ await servers[0].users.remove({ userId })
await waitJobs(servers)
{
for (const server of [ servers[0], servers[1] ]) {
- const body = await server.playlistsCommand.list({ start: 0, count: 15 })
+ const body = await server.playlists.list({ start: 0, count: 15 })
expect(finder(body.data)).to.be.undefined
}
for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) {
const attributes = { privacy }
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
}
await waitJobs(servers)
})
it('Should not have these private and internal videos on server 2', async function () {
- const { total, data } = await servers[1].videosCommand.list()
+ const { total, data } = await servers[1].videos.list()
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
})
it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () {
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
})
it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () {
- const { total, data } = await servers[0].videosCommand.listWithToken()
+ const { total, data } = await servers[0].videos.listWithToken()
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list my (private and internal) videos', async function () {
- const { total, data } = await servers[0].videosCommand.listMyVideos()
+ const { total, data } = await servers[0].videos.listMyVideos()
expect(total).to.equal(2)
expect(data).to.have.lengthOf(2)
})
it('Should not be able to watch the private/internal video with non authenticated user', async function () {
- await servers[0].videosCommand.get({ id: privateVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- await servers[0].videosCommand.get({ id: internalVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[0].videos.get({ id: privateVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[0].videos.get({ id: internalVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to watch the private video with another user', async function () {
username: 'hello',
password: 'super password'
}
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- anotherUserToken = await servers[0].loginCommand.getAccessToken(user)
+ anotherUserToken = await servers[0].login.getAccessToken(user)
- await servers[0].videosCommand.getWithToken({
+ await servers[0].videos.getWithToken({
token: anotherUserToken,
id: privateVideoUUID,
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
it('Should be able to watch the internal video with another user', async function () {
- await servers[0].videosCommand.getWithToken({ token: anotherUserToken, id: internalVideoUUID })
+ await servers[0].videos.getWithToken({ token: anotherUserToken, id: internalVideoUUID })
})
it('Should be able to watch the private video with the correct user', async function () {
- await servers[0].videosCommand.getWithToken({ id: privateVideoUUID })
+ await servers[0].videos.getWithToken({ id: privateVideoUUID })
})
})
name: 'unlisted video',
privacy: VideoPrivacy.UNLISTED
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
// Server 2 has transcoding enabled
await waitJobs(servers)
it('Should not have this unlisted video listed on server 1 and 2', async function () {
for (const server of servers) {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
})
it('Should list my (unlisted) videos', async function () {
- const { total, data } = await servers[1].videosCommand.listMyVideos()
+ const { total, data } = await servers[1].videos.listMyVideos()
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should not be able to get this unlisted video using its id', async function () {
- await servers[1].videosCommand.get({ id: unlistedVideo.id, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await servers[1].videos.get({ id: unlistedVideo.id, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should be able to get this unlisted video using its uuid/shortUUID', async function () {
for (const server of servers) {
for (const id of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) {
- const video = await server.videosCommand.get({ id })
+ const video = await server.videos.get({ id })
expect(video.name).to.equal('unlisted video')
}
name: 'unlisted video',
privacy: VideoPrivacy.UNLISTED
}
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
await waitJobs(servers)
})
it('Should list my new unlisted video', async function () {
- const { total, data } = await servers[0].videosCommand.listMyVideos()
+ const { total, data } = await servers[0].videos.listMyVideos()
expect(total).to.equal(3)
expect(data).to.have.lengthOf(3)
})
it('Should be able to get non-federated unlisted video from origin', async function () {
- const video = await servers[0].videosCommand.get({ id: nonFederatedUnlistedVideoUUID })
+ const video = await servers[0].videos.get({ id: nonFederatedUnlistedVideoUUID })
expect(video.name).to.equal('unlisted video')
})
it('Should not be able to get non-federated unlisted video from federated server', async function () {
- await servers[1].videosCommand.get({ id: nonFederatedUnlistedVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[1].videos.get({ id: nonFederatedUnlistedVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
})
privacy: VideoPrivacy.PUBLIC
}
- await servers[0].videosCommand.update({ id: privateVideoId, attributes })
+ await servers[0].videos.update({ id: privateVideoId, attributes })
}
{
name: 'internal video becomes public',
privacy: VideoPrivacy.PUBLIC
}
- await servers[0].videosCommand.update({ id: internalVideoId, attributes })
+ await servers[0].videos.update({ id: internalVideoId, attributes })
}
await waitJobs(servers)
it('Should have this new public video listed on server 1 and 2', async function () {
for (const server of servers) {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(2)
expect(data).to.have.lengthOf(2)
it('Should set these videos as private and internal', async function () {
this.timeout(10000)
- await servers[0].videosCommand.update({ id: internalVideoId, attributes: { privacy: VideoPrivacy.PRIVATE } })
- await servers[0].videosCommand.update({ id: privateVideoId, attributes: { privacy: VideoPrivacy.INTERNAL } })
+ await servers[0].videos.update({ id: internalVideoId, attributes: { privacy: VideoPrivacy.PRIVATE } })
+ await servers[0].videos.update({ id: privateVideoId, attributes: { privacy: VideoPrivacy.INTERNAL } })
await waitJobs(servers)
for (const server of servers) {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
}
{
- const { total, data } = await servers[0].videosCommand.listMyVideos()
+ const { total, data } = await servers[0].videos.listMyVideos()
expect(total).to.equal(3)
expect(data).to.have.lengthOf(3)
}
}
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
await waitJobs(servers)
})
it('Should not list the video (in privacy mode)', async function () {
for (const server of servers) {
- const { total } = await server.videosCommand.list()
+ const { total } = await server.videos.list()
expect(total).to.equal(0)
}
})
it('Should have my scheduled video in my account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listMyVideos()
+ const { total, data } = await servers[0].videos.listMyVideos()
expect(total).to.equal(1)
const videoFromList = data[0]
- const videoFromGet = await servers[0].videosCommand.getWithToken({ id: videoFromList.uuid })
+ const videoFromGet = await servers[0].videos.getWithToken({ id: videoFromList.uuid })
for (const video of [ videoFromList, videoFromGet ]) {
expect(video.name).to.equal('video 1')
await waitJobs(servers)
for (const server of servers) {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(1)
expect(data[0].name).to.equal('video 1')
privacy: VideoPrivacy.PRIVATE
}
- const { uuid } = await servers[0].videosCommand.upload({ attributes })
+ const { uuid } = await servers[0].videos.upload({ attributes })
video2UUID = uuid
await waitJobs(servers)
}
}
- await servers[0].videosCommand.update({ id: video2UUID, attributes })
+ await servers[0].videos.update({ id: video2UUID, attributes })
await waitJobs(servers)
})
it('Should not display the updated video', async function () {
for (const server of servers) {
- const { total } = await server.videosCommand.list()
+ const { total } = await server.videos.list()
expect(total).to.equal(1)
}
})
it('Should have my scheduled updated video in my account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listMyVideos()
+ const { total, data } = await servers[0].videos.listMyVideos()
expect(total).to.equal(2)
const video = data.find(v => v.uuid === video2UUID)
await waitJobs(servers)
for (const server of servers) {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(2)
const video = data.find(v => v.uuid === video2UUID)
const expect = chai.expect
function updateConfigForTranscoding (server: ServerInfo) {
- return server.configCommand.updateCustomSubConfig({
+ return server.config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: true,
description: 'my super description for server 1',
fixture: 'video_short.webm'
}
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data[0]
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(1)
const magnetUri = videoDetails.files[0].magnetUri
description: 'my super description for server 2',
fixture: 'video_short.webm'
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === attributes.name)
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(4)
fixture: 'video_short1.webm',
waitTranscoding: true
}
- const { uuid } = await servers[1].videosCommand.upload({ attributes })
+ const { uuid } = await servers[1].videos.upload({ attributes })
const videoId = uuid
// Should be in transcode state
- const body = await servers[1].videosCommand.get({ id: videoId })
+ const body = await servers[1].videos.get({ id: videoId })
expect(body.name).to.equal('waiting video')
expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
expect(body.state.label).to.equal('To transcode')
{
// Should have my video
- const { data } = await servers[1].videosCommand.listMyVideos()
+ const { data } = await servers[1].videos.listMyVideos()
const videoToFindInMine = data.find(v => v.name === attributes.name)
expect(videoToFindInMine).not.to.be.undefined
expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
{
// Should not list this video
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
const videoToFindInList = data.find(v => v.name === attributes.name)
expect(videoToFindInList).to.be.undefined
}
// Server 1 should not have the video yet
- await servers[0].videosCommand.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[0].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
}
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const videoToFind = data.find(v => v.name === 'waiting video')
expect(videoToFind).not.to.be.undefined
- const videoDetails = await server.videosCommand.get({ id: videoToFind.id })
+ const videoDetails = await server.videos.get({ id: videoToFind.id })
expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED)
expect(videoDetails.state.label).to.equal('Published')
fixture
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === attributes.name)
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(4)
const magnetUri = videoDetails.files[0].magnetUri
fixture: 'video_short_4k.mp4'
}
- const { uuid } = await servers[1].videosCommand.upload({ attributes })
+ const { uuid } = await servers[1].videos.upload({ attributes })
video4k = uuid
await waitJobs(servers)
const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: video4k })
+ const videoDetails = await server.videos.get({ id: video4k })
expect(videoDetails.files).to.have.lengthOf(resolutions.length)
for (const r of resolutions) {
name: 'mp3_256k',
fixture: 'video_short_mp3_256k.mp4'
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === attributes.name)
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(4)
- const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
+ const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
const probe = await getAudioStream(path)
if (probe.audioStream) {
name: 'no_audio',
fixture: 'video_short_no_audio.mp4'
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === attributes.name)
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(4)
- const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
+ const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
const probe = await getAudioStream(path)
expect(probe).to.not.have.property('audioStream')
}
name: 'untouched_audio',
fixture: 'video_short.mp4'
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === attributes.name)
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(4)
const fixturePath = buildAbsoluteFixturePath(attributes.fixture)
const fixtureVideoProbe = await getAudioStream(fixturePath)
- const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
+ const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
const videoProbe = await getAudioStream(path)
function runSuite (mode: 'legacy' | 'resumable') {
before(async function () {
- await servers[1].configCommand.updateCustomSubConfig({
+ await servers[1].config.updateCustomSubConfig({
newConfig: {
transcoding: {
hls: { enabled: true },
this.timeout(60_000)
const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
- await servers[1].videosCommand.upload({ attributes, mode })
+ await servers[1].videos.upload({ attributes, mode })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === 'audio_with_preview')
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(1)
this.timeout(60_000)
const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' }
- await servers[1].videosCommand.upload({ attributes, mode })
+ await servers[1].videos.upload({ attributes, mode })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === 'audio_without_preview')
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(1)
it('Should upload an audio file and create an audio version only', async function () {
this.timeout(60_000)
- await servers[1].configCommand.updateCustomSubConfig({
+ await servers[1].config.updateCustomSubConfig({
newConfig: {
transcoding: {
hls: { enabled: true },
})
const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
- const { id } = await servers[1].videosCommand.upload({ attributes, mode })
+ const { id } = await servers[1].videos.upload({ attributes, mode })
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id })
+ const videoDetails = await server.videos.get({ id })
for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) {
expect(files).to.have.lengthOf(2)
description: 'my super 30fps description for server 2',
fixture: '60fps_720p_small.mp4'
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === attributes.name)
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(4)
expect(videoDetails.files[0].fps).to.be.above(58).and.below(62)
expect(videoDetails.files[3].fps).to.be.below(31)
for (const resolution of [ '240', '360', '480' ]) {
- const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
+ const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
const fps = await getVideoFileFPS(path)
expect(fps).to.be.below(31)
}
- const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4'))
+ const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4'))
const fps = await getVideoFileFPS(path)
expect(fps).to.be.above(58).and.below(62)
fixture: tempFixturePath
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === attributes.name)
{
- const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
+ const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
const fps = await getVideoFileFPS(path)
expect(fps).to.be.equal(25)
}
{
- const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4'))
+ const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4'))
const fps = await getVideoFileFPS(path)
expect(fps).to.be.equal(59)
}
fixture: tempFixturePath
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.name === attributes.name)
for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
- const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
+ const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
const bitrate = await getVideoFileBitrate(path)
const fps = await getVideoFileFPS(path)
hls: { enabled: true }
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig })
+ await servers[1].config.updateCustomSubConfig({ newConfig })
const attributes = {
name: 'low bitrate',
fixture: 'low-bitrate.mp4'
}
- const { uuid } = await servers[1].videosCommand.upload({ attributes })
+ const { uuid } = await servers[1].videos.upload({ attributes })
await waitJobs(servers)
const resolutions = [ 240, 360, 480, 720, 1080 ]
for (const r of resolutions) {
const path = `videos/${uuid}-${r}.mp4`
- const size = await servers[1].serversCommand.getServerFileSize(path)
+ const size = await servers[1].servers.getServerFileSize(path)
expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
}
})
it('Should provide valid ffprobe data', async function () {
this.timeout(160_000)
- const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'ffprobe data' })).uuid
+ const videoUUID = (await servers[1].videos.quickUpload({ name: 'ffprobe data' })).uuid
await waitJobs(servers)
{
- const path = servers[1].serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4'))
+ const path = servers[1].servers.buildDirectory(join('videos', videoUUID + '-240.mp4'))
const metadata = await getMetadataFromFile(path)
// expected format properties
}
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videoUUID })
+ const videoDetails = await server.videos.get({ id: videoUUID })
const videoFiles = videoDetails.files
.concat(videoDetails.streamingPlaylists[0].files)
expect(file.metadataUrl).to.contain(servers[1].url)
expect(file.metadataUrl).to.contain(videoUUID)
- const metadata = await server.videosCommand.getFileMetadata({ url: file.metadataUrl })
+ const metadata = await server.videos.getFileMetadata({ url: file.metadataUrl })
expect(metadata).to.have.nested.property('format.size')
}
}
describe('Transcoding job queue', function () {
it('Should have the appropriate priorities for transcoding jobs', async function () {
- const body = await servers[1].jobsCommand.getJobsList({
+ const body = await servers[1].jobs.getJobsList({
start: 0,
count: 100,
sort: '-createdAt',
for (const server of servers) {
const moderator = { username: 'moderator', password: 'my super password' }
- await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
- server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator)
+ await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
+ server['moderatorAccessToken'] = await server.login.getAccessToken(moderator)
- await server.videosCommand.upload({ attributes: { name: 'public ' + server.serverNumber } })
+ await server.videos.upload({ attributes: { name: 'public ' + server.serverNumber } })
{
const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED }
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
}
{
const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE }
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
}
}
await setAccessTokensToServers([ server ])
- command = server.historyCommand
+ command = server.history
{
- const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 1' } })
+ const { uuid } = await server.videos.upload({ attributes: { name: 'video 1' } })
video1UUID = uuid
}
{
- const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 2' } })
+ const { uuid } = await server.videos.upload({ attributes: { name: 'video 2' } })
video2UUID = uuid
}
{
- const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 3' } })
+ const { uuid } = await server.videos.upload({ attributes: { name: 'video 3' } })
video3UUID = uuid
}
username: 'user_1',
password: 'super password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken = await server.login.getAccessToken(user)
})
it('Should get videos, without watching history', async function () {
- const { data } = await server.videosCommand.listWithToken()
+ const { data } = await server.videos.listWithToken()
for (const video of data) {
- const videoDetails = await server.videosCommand.getWithToken({ id: video.id })
+ const videoDetails = await server.videos.getWithToken({ id: video.id })
expect(video.userHistory).to.be.undefined
expect(videoDetails.userHistory).to.be.undefined
const videosOfVideos: Video[][] = []
{
- const { data } = await server.videosCommand.listWithToken()
+ const { data } = await server.videos.listWithToken()
videosOfVideos.push(data)
}
{
- const body = await server.searchCommand.searchVideos({ token: server.accessToken, search: 'video' })
+ const body = await server.search.searchVideos({ token: server.accessToken, search: 'video' })
videosOfVideos.push(body.data)
}
}
{
- const videoDetails = await server.videosCommand.getWithToken({ id: video1UUID })
+ const videoDetails = await server.videos.getWithToken({ id: video1UUID })
expect(videoDetails.userHistory).to.not.be.undefined
expect(videoDetails.userHistory.currentTime).to.equal(3)
}
{
- const videoDetails = await server.videosCommand.getWithToken({ id: video2UUID })
+ const videoDetails = await server.videos.getWithToken({ id: video2UUID })
expect(videoDetails.userHistory).to.not.be.undefined
expect(videoDetails.userHistory.currentTime).to.equal(8)
}
{
- const videoDetails = await server.videosCommand.getWithToken({ id: video3UUID })
+ const videoDetails = await server.videos.getWithToken({ id: video3UUID })
expect(videoDetails.userHistory).to.be.undefined
}
})
it('Should disable videos history', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
videosHistoryEnabled: false
})
})
it('Should re-enable videos history', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
videosHistoryEnabled: true
})
})
it('Should send empty overview', async function () {
- const body = await server.overviewsCommand.getVideos({ page: 1 })
+ const body = await server.overviews.getVideos({ page: 1 })
testOverviewCount(body, 0)
})
await wait(3000)
- await server.videosCommand.upload({
+ await server.videos.upload({
attributes: {
name: 'video 0',
category: 3,
}
})
- const body = await server.overviewsCommand.getVideos({ page: 1 })
+ const body = await server.overviews.getVideos({ page: 1 })
testOverviewCount(body, 0)
})
{
for (let i = 1; i < 6; i++) {
- await server.videosCommand.upload({
+ await server.videos.upload({
attributes: {
name: 'video ' + i,
category: 3,
}
{
- const body = await server.overviewsCommand.getVideos({ page: 1 })
+ const body = await server.overviews.getVideos({ page: 1 })
testOverviewCount(body, 1)
}
{
- const overview = await server.overviewsCommand.getVideos({ page: 2 })
+ const overview = await server.overviews.getVideos({ page: 2 })
expect(overview.tags).to.have.lengthOf(1)
expect(overview.categories).to.have.lengthOf(0)
})
it('Should have the correct overview', async function () {
- const overview1 = await server.overviewsCommand.getVideos({ page: 1 })
- const overview2 = await server.overviewsCommand.getVideos({ page: 2 })
+ const overview1 = await server.overviews.getVideos({ page: 1 })
+ const overview2 = await server.overviews.getVideos({ page: 2 })
for (const arr of [ overview1.tags, overview1.categories, overview1.channels, overview2.tags ]) {
expect(arr).to.have.lengthOf(1)
})
it('Should hide muted accounts', async function () {
- const token = await server.usersCommand.generateUserAndToken('choco')
+ const token = await server.users.generateUserAndToken('choco')
- await server.blocklistCommand.addToMyBlocklist({ token, account: 'root@' + server.host })
+ await server.blocklist.addToMyBlocklist({ token, account: 'root@' + server.host })
{
- const body = await server.overviewsCommand.getVideos({ page: 1 })
+ const body = await server.overviews.getVideos({ page: 1 })
testOverviewCount(body, 1)
}
{
- const body = await server.overviewsCommand.getVideos({ page: 1, token })
+ const body = await server.overviews.getVideos({ page: 1, token })
testOverviewCount(body, 0)
}
await doubleFollow(servers[0], servers[1])
- videoIdServer1 = (await servers[0].videosCommand.quickUpload({ name: 'video server 1' })).uuid
- videoIdServer2 = (await servers[1].videosCommand.quickUpload({ name: 'video server 2' })).uuid
+ videoIdServer1 = (await servers[0].videos.quickUpload({ name: 'video server 1' })).uuid
+ videoIdServer2 = (await servers[1].videos.quickUpload({ name: 'video server 2' })).uuid
await waitJobs(servers)
- await servers[0].videosCommand.view({ id: videoIdServer1 })
- await servers[1].videosCommand.view({ id: videoIdServer1 })
- await servers[0].videosCommand.view({ id: videoIdServer2 })
- await servers[1].videosCommand.view({ id: videoIdServer2 })
+ await servers[0].videos.view({ id: videoIdServer1 })
+ await servers[1].videos.view({ id: videoIdServer1 })
+ await servers[0].videos.view({ id: videoIdServer2 })
+ await servers[1].videos.view({ id: videoIdServer2 })
await waitJobs(servers)
})
{
for (const server of servers) {
- const total = await server.sqlCommand.countVideoViewsOf(videoIdServer1)
+ const total = await server.sql.countVideoViewsOf(videoIdServer1)
expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
}
}
{
for (const server of servers) {
- const total = await server.sqlCommand.countVideoViewsOf(videoIdServer2)
+ const total = await server.sql.countVideoViewsOf(videoIdServer2)
expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
}
}
{
for (const server of servers) {
- const total = await server.sqlCommand.countVideoViewsOf(videoIdServer1)
+ const total = await server.sql.countVideoViewsOf(videoIdServer1)
expect(total).to.equal(2)
}
}
{
- const totalServer1 = await servers[0].sqlCommand.countVideoViewsOf(videoIdServer2)
+ const totalServer1 = await servers[0].sql.countVideoViewsOf(videoIdServer2)
expect(totalServer1).to.equal(0)
- const totalServer2 = await servers[1].sqlCommand.countVideoViewsOf(videoIdServer2)
+ const totalServer2 = await servers[1].sql.countVideoViewsOf(videoIdServer2)
expect(totalServer2).to.equal(2)
}
})
// Upload two videos for our needs
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video1' } })
video1UUID = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video2' } })
video2UUID = uuid
}
it('Should run a import job on video 1 with a lower resolution', async function () {
const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`
- await servers[0].cliCommand.execWithEnv(command)
+ await servers[0].cli.execWithEnv(command)
await waitJobs(servers)
for (const server of servers) {
- const { data: videos } = await server.videosCommand.list()
+ const { data: videos } = await server.videos.list()
expect(videos).to.have.lengthOf(2)
const video = videos.find(({ uuid }) => uuid === video1UUID)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(2)
const [ originalVideo, transcodedVideo ] = videoDetails.files
it('Should run a import job on video 2 with the same resolution and a different extension', async function () {
const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`
- await servers[1].cliCommand.execWithEnv(command)
+ await servers[1].cli.execWithEnv(command)
await waitJobs(servers)
for (const server of servers) {
- const { data: videos } = await server.videosCommand.list()
+ const { data: videos } = await server.videos.list()
expect(videos).to.have.lengthOf(2)
const video = videos.find(({ uuid }) => uuid === video2UUID)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(4)
const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetails.files
it('Should run a import job on video 2 with the same resolution and the same extension', async function () {
const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`
- await servers[0].cliCommand.execWithEnv(command)
+ await servers[0].cli.execWithEnv(command)
await waitJobs(servers)
for (const server of servers) {
- const { data: videos } = await server.videosCommand.list()
+ const { data: videos } = await server.videos.list()
expect(videos).to.have.lengthOf(2)
const video = videos.find(({ uuid }) => uuid === video1UUID)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(2)
const [ video720, video480 ] = videoDetails.files
servers = await flushAndRunMultipleServers(2)
await setAccessTokensToServers(servers)
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
await doubleFollow(servers[0], servers[1])
for (let i = 1; i <= 5; i++) {
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' + i } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' + i } })
videosUUID.push(uuid)
}
this.timeout(30000)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(videosUUID.length)
for (const video of data) {
- const videoDetail = await server.videosCommand.get({ id: video.uuid })
+ const videoDetail = await server.videos.get({ id: video.uuid })
expect(videoDetail.files).to.have.lengthOf(1)
expect(videoDetail.streamingPlaylists).to.have.lengthOf(0)
}
it('Should run a transcoding job on video 2', async function () {
this.timeout(60000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`)
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
let infoHashes: { [id: number]: string }
for (const video of data) {
- const videoDetail = await server.videosCommand.get({ id: video.uuid })
+ const videoDetail = await server.videos.get({ id: video.uuid })
if (video.uuid === videosUUID[1]) {
expect(videoDetail.files).to.have.lengthOf(4)
it('Should run a transcoding job on video 1 with resolution', async function () {
this.timeout(60000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
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(videosUUID.length)
- const videoDetails = await server.videosCommand.get({ id: videosUUID[0] })
+ const videoDetails = await server.videos.get({ id: videosUUID[0] })
expect(videoDetails.files).to.have.lengthOf(2)
expect(videoDetails.files[0].resolution.id).to.equal(720)
it('Should generate an HLS resolution', async function () {
this.timeout(120000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videosUUID[2] })
+ const videoDetails = await server.videos.get({ id: videosUUID[2] })
expect(videoDetails.files).to.have.lengthOf(1)
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
it('Should not duplicate an HLS resolution', async function () {
this.timeout(120000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videosUUID[2] })
+ const videoDetails = await server.videos.get({ id: videosUUID[2] })
const files = videoDetails.streamingPlaylists[0].files
expect(files).to.have.lengthOf(1)
it('Should generate all HLS resolutions', async function () {
this.timeout(120000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videosUUID[3] })
+ const videoDetails = await server.videos.get({ id: videosUUID[3] })
expect(videoDetails.files).to.have.lengthOf(1)
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
this.timeout(120000)
config.transcoding.hls.enabled = true
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`)
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videosUUID[4] })
+ const videoDetails = await server.videos.get({ id: videosUUID[4] })
expect(videoDetails.files).to.have.lengthOf(4)
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
}
// Upload two videos for our needs
- await servers[0].videosCommand.upload({ attributes: { name: 'video1', fixture: tempFixturePath } })
- await servers[0].videosCommand.upload({ attributes: { name: 'video2', fixture: tempFixturePath } })
+ await servers[0].videos.upload({ attributes: { name: 'video1', fixture: tempFixturePath } })
+ await servers[0].videos.upload({ attributes: { name: 'video2', fixture: tempFixturePath } })
await waitJobs(servers)
})
this.timeout(30000)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(2)
for (const video of data) {
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(1)
}
}
it('Should run optimize script', async function () {
this.timeout(200000)
- await servers[0].cliCommand.execWithEnv('npm run optimize-old-videos')
+ await servers[0].cli.execWithEnv('npm run optimize-old-videos')
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)
for (const video of data) {
- await server.videosCommand.view({ id: video.uuid })
+ await server.videos.view({ id: video.uuid })
// Refresh video
await waitJobs(servers)
await wait(5000)
await waitJobs(servers)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(1)
const file = videoDetails.files[0]
expect(file.size).to.be.below(8000000)
- const path = servers[0].serversCommand.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4'))
+ const path = servers[0].servers.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4'))
const bitrate = await getVideoFileBitrate(path)
const fps = await getVideoFileFPS(path)
const resolution = await getVideoFileResolution(path)
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.usersCommand.create({ username: 'user_1', password: 'super_password' })
+ await server.users.create({ username: 'user_1', password: 'super_password' })
- userAccessToken = await server.loginCommand.getAccessToken({ username: 'user_1', password: 'super_password' })
+ userAccessToken = await server.login.getAccessToken({ username: 'user_1', password: 'super_password' })
{
const attributes = { name: 'user_channel', displayName: 'User channel', support: 'super support text' }
- await server.channelsCommand.create({ token: userAccessToken, attributes })
+ await server.channels.create({ token: userAccessToken, attributes })
}
- cliCommand = server.cliCommand
+ cliCommand = server.cli
})
describe('Authentication and instance selection', function () {
const stdout = await cliCommand.execWithEnv(`${cmd} token --url ${server.url} --username user_1 --password super_password`)
const token = stdout.trim()
- const body = await server.usersCommand.getMyInfo({ token })
+ const body = await server.users.getMyInfo({ token })
expect(body.username).to.equal('user_1')
})
})
it('Should have the video uploaded', async function () {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(1)
- const video = await server.videosCommand.get({ id: data[0].uuid })
+ const video = await server.videos.get({ id: data[0].uuid })
expect(video.name).to.equal('test upload')
expect(video.support).to.equal('support_text')
expect(video.channel.name).to.equal('user_channel')
await waitJobs([ server ])
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(2)
const video = data.find(v => v.name === 'small video - youtube')
expect(video).to.not.be.undefined
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.channel.name).to.equal('user_channel')
expect(videoDetails.support).to.equal('super support text')
expect(videoDetails.nsfw).to.be.false
// So we can reimport it
- await server.videosCommand.remove({ token: userAccessToken, id: video.id })
+ await server.videos.remove({ token: userAccessToken, id: video.id })
})
it('Should import and override some imported attributes', async function () {
await waitJobs([ server ])
{
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(2)
const video = data.find(v => v.name === 'toto')
expect(video).to.not.be.undefined
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.channel.name).to.equal('user_channel')
expect(videoDetails.support).to.equal('support')
expect(videoDetails.nsfw).to.be.true
servers = [ server, anotherServer ]
await waitJobs(servers)
- const { uuid } = await anotherServer.videosCommand.quickUpload({ name: 'super video' })
+ const { uuid } = await anotherServer.videos.quickUpload({ name: 'super video' })
await waitJobs(servers)
- video1Server2 = await server.videosCommand.getId({ uuid })
+ video1Server2 = await server.videos.getId({ uuid })
})
it('Should add a redundancy', async function () {
const packagePath = PluginsCommand.getPluginTestPath()
- await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
+ await server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
})
it('Should install a theme from stateless CLI', async function () {
this.timeout(60000)
- await server.cliCommand.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
+ await server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
})
it('Should have the theme and the plugin registered when we restart peertube', async function () {
await killallServers([ server ])
await reRunServer(server)
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const plugin = config.plugin.registered
.find(p => p.name === 'test')
it('Should uninstall a plugin from stateless CLI', async function () {
this.timeout(60000)
- await server.cliCommand.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
+ await server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
})
it('Should have removed the plugin on another peertube restart', async function () {
await killallServers([ server ])
await reRunServer(server)
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const plugin = config.plugin.registered
.find(p => p.name === 'test')
const expect = chai.expect
async function countFiles (server: ServerInfo, directory: string) {
- const files = await readdir(server.serversCommand.buildDirectory(directory))
+ const files = await readdir(server.servers.buildDirectory(directory))
return files.length
}
async function assertNotExists (server: ServerInfo, directory: string, substring: string) {
- const files = await readdir(server.serversCommand.buildDirectory(directory))
+ const files = await readdir(server.servers.buildDirectory(directory))
for (const f of files) {
expect(f).to.not.contain(substring)
await setDefaultVideoChannel(servers)
for (const server of servers) {
- await server.videosCommand.upload({ attributes: { name: 'video 1' } })
- await server.videosCommand.upload({ attributes: { name: 'video 2' } })
+ await server.videos.upload({ attributes: { name: 'video 1' } })
+ await server.videos.upload({ attributes: { name: 'video 2' } })
- await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' })
+ await server.users.updateMyAvatar({ fixture: 'avatar.png' })
- await server.playlistsCommand.create({
+ await server.playlists.create({
attributes: {
displayName: 'playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id,
+ videoChannelId: server.store.channel.id,
thumbnailfile: 'thumbnail.jpg'
}
})
// Lazy load the remote avatar
{
- const account = await servers[0].accountsCommand.get({ accountName: 'root@localhost:' + servers[1].port })
+ const account = await servers[0].accounts.get({ accountName: 'root@localhost:' + servers[1].port })
await makeGetRequest({
url: servers[0].url,
path: account.avatar.path,
}
{
- const account = await servers[1].accountsCommand.get({ accountName: 'root@localhost:' + servers[0].port })
+ const account = await servers[1].accounts.get({ accountName: 'root@localhost:' + servers[0].port })
await makeGetRequest({
url: servers[1].url,
path: account.avatar.path,
it('Should create some dirty files', async function () {
for (let i = 0; i < 2; i++) {
{
- const base = servers[0].serversCommand.buildDirectory('videos')
+ const base = servers[0].servers.buildDirectory('videos')
const n1 = buildUUID() + '.mp4'
const n2 = buildUUID() + '.webm'
}
{
- const base = servers[0].serversCommand.buildDirectory('torrents')
+ const base = servers[0].servers.buildDirectory('torrents')
const n1 = buildUUID() + '-240.torrent'
const n2 = buildUUID() + '-480.torrent'
}
{
- const base = servers[0].serversCommand.buildDirectory('thumbnails')
+ const base = servers[0].servers.buildDirectory('thumbnails')
const n1 = buildUUID() + '.jpg'
const n2 = buildUUID() + '.jpg'
}
{
- const base = servers[0].serversCommand.buildDirectory('previews')
+ const base = servers[0].servers.buildDirectory('previews')
const n1 = buildUUID() + '.jpg'
const n2 = buildUUID() + '.jpg'
}
{
- const base = servers[0].serversCommand.buildDirectory('avatars')
+ const base = servers[0].servers.buildDirectory('avatars')
const n1 = buildUUID() + '.png'
const n2 = buildUUID() + '.jpg'
it('Should run prune storage', async function () {
this.timeout(30000)
- const env = servers[0].cliCommand.getEnv()
+ const env = servers[0].cli.getEnv()
await CLICommand.exec(`echo y | ${env} npm run prune-storage`)
})
} from '../../../shared/extra-utils'
async function testThumbnail (server: ServerInfo, videoId: number | string) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
const requests = [
makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200),
await doubleFollow(servers[0], servers[1])
{
- const videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid
- video1 = await servers[0].videosCommand.get({ id: videoUUID1 })
+ const videoUUID1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).uuid
+ video1 = await servers[0].videos.get({ id: videoUUID1 })
- thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath))
+ thumbnail1Path = join(servers[0].servers.buildDirectory('thumbnails'), basename(video1.thumbnailPath))
- const videoUUID2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid
- video2 = await servers[0].videosCommand.get({ id: videoUUID2 })
+ const videoUUID2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).uuid
+ video2 = await servers[0].videos.get({ id: videoUUID2 })
}
{
- const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'video 3' })).uuid
+ const videoUUID = (await servers[1].videos.quickUpload({ name: 'video 3' })).uuid
await waitJobs(servers)
- remoteVideo = await servers[0].videosCommand.get({ id: videoUUID })
+ remoteVideo = await servers[0].videos.get({ id: videoUUID })
- thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath))
+ thumbnailRemotePath = join(servers[0].servers.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath))
}
await writeFile(thumbnail1Path, '')
it('Should regenerate local thumbnails from the CLI', async function () {
this.timeout(15000)
- await servers[0].cliCommand.execWithEnv(`npm run regenerate-thumbnails`)
+ await servers[0].cli.execWithEnv(`npm run regenerate-thumbnails`)
})
it('Should have generated new thumbnail files', async function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.usersCommand.create({ username: 'user_1', password: 'super password' })
+ await server.users.create({ username: 'user_1', password: 'super password' })
})
it('Should change the user password from CLI', async function () {
this.timeout(60000)
- const env = server.cliCommand.getEnv()
+ const env = server.cli.getEnv()
await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`)
- await server.loginCommand.login({ user: { username: 'user_1', password: 'coucou' } })
+ await server.login.login({ user: { username: 'user_1', password: 'coucou' } })
})
after(async function () {
await setAccessTokensToServers([ server ])
// Upload two videos for our needs
- const { uuid: video1UUID } = await server.videosCommand.upload()
- await server.videosCommand.upload()
+ const { uuid: video1UUID } = await server.videos.upload()
+ await server.videos.upload()
// Create a user
- await server.usersCommand.create({ username: 'toto', password: 'coucou' })
+ await server.users.create({ username: 'toto', password: 'coucou' })
// Create channel
const videoChannel = {
displayName: 'second video channel',
description: 'super video channel description'
}
- await server.channelsCommand.create({ attributes: videoChannel })
+ await server.channels.create({ attributes: videoChannel })
// Create comments
const text = 'my super first comment'
- await server.commentsCommand.createThread({ videoId: video1UUID, text })
+ await server.comments.createThread({ videoId: video1UUID, text })
await waitJobs(server)
})
// Run server with standard configuration
await reRunServer(server)
- await server.cliCommand.execWithEnv(`npm run update-host`)
+ await server.cli.execWithEnv(`npm run update-host`)
})
it('Should have updated videos url', async function () {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(2)
for (const video of data) {
expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.trackerUrls[0]).to.include(server.host)
expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host)
})
it('Should have updated video channels url', async function () {
- const { data, total } = await server.channelsCommand.list({ sort: '-name' })
+ const { data, total } = await server.channels.list({ sort: '-name' })
expect(total).to.equal(3)
for (const channel of data) {
})
it('Should have updated accounts url', async function () {
- const body = await server.accountsCommand.list()
+ const body = await server.accounts.list()
expect(body.total).to.equal(3)
for (const account of body.data) {
it('Should have updated torrent hosts', async function () {
this.timeout(30000)
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(2)
for (const video of data) {
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.files).to.have.lengthOf(4)
await setDefaultVideoChannel(servers)
- await servers[0].channelsCommand.update({
- channelName: servers[0].videoChannel.name,
+ await servers[0].channels.update({
+ channelName: servers[0].store.channel.name,
attributes: { description: channelDescription }
})
{
const attributes = { name: videoName, description: videoDescription }
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data.length).to.equal(1)
const video = data[0]
- servers[0].video = video
+ servers[0].store.video = video
videoIds = [ video.id, video.uuid, video.shortUUID ]
}
displayName: playlistName,
description: playlistDescription,
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[0].videoChannel.id
+ videoChannelId: servers[0].store.channel.id
}
- playlist = await servers[0].playlistsCommand.create({ attributes })
+ playlist = await servers[0].playlists.create({ attributes })
playlistIds = [ playlist.id, playlist.shortUUID, playlist.uuid ]
- await servers[0].playlistsCommand.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: servers[0].video.id } })
+ await servers[0].playlists.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: servers[0].store.video.id } })
}
// Account
{
- await servers[0].usersCommand.updateMe({ description: 'my account description' })
+ await servers[0].users.updateMe({ description: 'my account description' })
- account = await servers[0].accountsCommand.get({ accountName: `${servers[0].user.username}@${servers[0].host}` })
+ account = await servers[0].accounts.get({ accountName: `${servers[0].store.user.username}@${servers[0].host}` })
}
await waitJobs(servers)
const port = servers[0].port
const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
- `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2F${servers[0].video.uuid}" ` +
- `title="${servers[0].video.name}" />`
+ `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2F${servers[0].store.video.uuid}" ` +
+ `title="${servers[0].store.video.name}" />`
expect(res.text).to.contain(expectedLink)
}
expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
expect(text).to.contain(`<meta property="og:description" content="${account.description}" />`)
expect(text).to.contain('<meta property="og:type" content="website" />')
- expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].user.username}" />`)
+ expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].store.user.username}" />`)
}
async function channelPageTest (path: string) {
const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
const text = res.text
- expect(text).to.contain(`<meta property="og:title" content="${servers[0].videoChannel.displayName}" />`)
+ expect(text).to.contain(`<meta property="og:title" content="${servers[0].store.channel.displayName}" />`)
expect(text).to.contain(`<meta property="og:description" content="${channelDescription}" />`)
expect(text).to.contain('<meta property="og:type" content="website" />')
- expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].videoChannel.name}" />`)
+ expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].store.channel.name}" />`)
}
async function watchVideoPageTest (path: string) {
expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`)
expect(text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`)
expect(text).to.contain('<meta property="og:type" content="video" />')
- expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/${servers[0].video.uuid}" />`)
+ expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/${servers[0].store.video.uuid}" />`)
}
async function watchPlaylistPageTest (path: string) {
}
it('Should have valid Open Graph tags on the account page', async function () {
- await accountPageTest('/accounts/' + servers[0].user.username)
- await accountPageTest('/a/' + servers[0].user.username)
- await accountPageTest('/@' + servers[0].user.username)
+ await accountPageTest('/accounts/' + servers[0].store.user.username)
+ await accountPageTest('/a/' + servers[0].store.user.username)
+ await accountPageTest('/@' + servers[0].store.user.username)
})
it('Should have valid Open Graph tags on the channel page', async function () {
- await channelPageTest('/video-channels/' + servers[0].videoChannel.name)
- await channelPageTest('/c/' + servers[0].videoChannel.name)
- await channelPageTest('/@' + servers[0].videoChannel.name)
+ await channelPageTest('/video-channels/' + servers[0].store.channel.name)
+ await channelPageTest('/c/' + servers[0].store.channel.name)
+ await channelPageTest('/@' + servers[0].store.channel.name)
})
it('Should have valid Open Graph tags on the watch page', async function () {
expect(text).to.contain('<meta property="twitter:card" content="summary" />')
expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
- expect(text).to.contain(`<meta property="twitter:title" content="${servers[0].videoChannel.displayName}" />`)
+ expect(text).to.contain(`<meta property="twitter:title" content="${servers[0].store.channel.displayName}" />`)
expect(text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`)
}
})
it('Should have valid twitter card on the channel page', async function () {
- await channelPageTest('/video-channels/' + servers[0].videoChannel.name)
- await channelPageTest('/c/' + servers[0].videoChannel.name)
- await channelPageTest('/@' + servers[0].videoChannel.name)
+ await channelPageTest('/video-channels/' + servers[0].store.channel.name)
+ await channelPageTest('/c/' + servers[0].store.channel.name)
+ await channelPageTest('/@' + servers[0].store.channel.name)
})
})
describe('Whitelisted', function () {
before(async function () {
- const config = await servers[0].configCommand.getCustomConfig()
+ const config = await servers[0].config.getCustomConfig()
config.services.twitter = {
username: '@Kuja',
whitelisted: true
}
- await servers[0].configCommand.updateCustomConfig({ newCustomConfig: config })
+ await servers[0].config.updateCustomConfig({ newCustomConfig: config })
})
async function accountPageTest (path: string) {
})
it('Should have valid twitter card on the channel page', async function () {
- await channelPageTest('/video-channels/' + servers[0].videoChannel.name)
- await channelPageTest('/c/' + servers[0].videoChannel.name)
- await channelPageTest('/@' + servers[0].videoChannel.name)
+ await channelPageTest('/video-channels/' + servers[0].store.channel.name)
+ await channelPageTest('/c/' + servers[0].store.channel.name)
+ await channelPageTest('/@' + servers[0].store.channel.name)
})
})
})
describe('Index HTML', function () {
it('Should have valid index html tags (title, description...)', async function () {
- const config = await servers[0].configCommand.getConfig()
+ const config = await servers[0].config.getConfig()
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
})
it('Should update the customized configuration and have the correct index html tags', async function () {
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
instance: {
name: 'PeerTube updated',
}
})
- const config = await servers[0].configCommand.getConfig()
+ const config = await servers[0].config.getConfig()
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
})
it('Should have valid index html updated tags (title, description...)', async function () {
- const config = await servers[0].configCommand.getConfig()
+ const config = await servers[0].config.getConfig()
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
for (const basePath of watchVideoBasePaths) {
for (const id of videoIds) {
const res = await makeHTMLRequest(servers[1].url, basePath + id)
- expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].video.uuid}" />`)
+ expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].store.video.uuid}" />`)
}
}
})
describe('Embed HTML', function () {
it('Should have the correct embed html tags', async function () {
- const config = await servers[0].configCommand.getConfig()
- const res = await makeHTMLRequest(servers[0].url, servers[0].video.embedPath)
+ const config = await servers[0].config.getConfig()
+ const res = await makeHTMLRequest(servers[0].url, servers[0].store.video.embedPath)
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
})
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.pluginsCommand.install({ npmName: 'peertube-plugin-auth-ldap' })
+ await server.plugins.install({ npmName: 'peertube-plugin-auth-ldap' })
})
it('Should not login with without LDAP settings', async function () {
- await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not login with bad LDAP settings', async function () {
- await server.pluginsCommand.updateSettings({
+ await server.plugins.updateSettings({
npmName: 'peertube-plugin-auth-ldap',
settings: {
'bind-credentials': 'GoodNewsEveryone',
}
})
- await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not login with good LDAP settings but wrong username/password', async function () {
- await server.pluginsCommand.updateSettings({
+ await server.plugins.updateSettings({
npmName: 'peertube-plugin-auth-ldap',
settings: {
'bind-credentials': 'GoodNewsEveryone',
}
})
- await server.loginCommand.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.loginCommand.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should login with the appropriate username/password', async function () {
- accessToken = await server.loginCommand.getAccessToken({ username: 'fry', password: 'fry' })
+ accessToken = await server.login.getAccessToken({ username: 'fry', password: 'fry' })
})
it('Should login with the appropriate email/password', async function () {
- accessToken = await server.loginCommand.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' })
+ accessToken = await server.login.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' })
})
it('Should login get my profile', async function () {
- const body = await server.usersCommand.getMyInfo({ token: accessToken })
+ const body = await server.users.getMyInfo({ token: accessToken })
expect(body.username).to.equal('fry')
expect(body.email).to.equal('fry@planetexpress.com')
})
it('Should upload a video', async function () {
- await server.videosCommand.upload({ token: accessToken, attributes: { name: 'my super video' } })
+ await server.videos.upload({ token: accessToken, attributes: { name: 'my super video' } })
})
it('Should not be able to login if the user is banned', async function () {
- await server.usersCommand.banUser({ userId })
+ await server.users.banUser({ userId })
- await server.loginCommand.login({
+ await server.login.login({
user: { username: 'fry@planetexpress.com', password: 'fry' },
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
it('Should be able to login if the user is unbanned', async function () {
- await server.usersCommand.unbanUser({ userId })
+ await server.users.unbanUser({ userId })
- await server.loginCommand.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } })
+ await server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } })
})
it('Should not login if the plugin is uninstalled', async function () {
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-auth-ldap' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-auth-ldap' })
- await server.loginCommand.login({
+ await server.login.login({
user: { username: 'fry@planetexpress.com', password: 'fry' },
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
import { Video } from '@shared/models'
async function check (server: ServerInfo, videoUUID: string, exists = true) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.uuid === videoUUID)
await setAccessTokensToServers(servers)
for (const server of servers) {
- await server.pluginsCommand.install({ npmName: 'peertube-plugin-auto-block-videos' })
+ await server.plugins.install({ npmName: 'peertube-plugin-auto-block-videos' })
}
blocklistServer = new MockBlocklist()
port = await blocklistServer.initialize()
- await await servers[0].videosCommand.quickUpload({ name: 'video server 1' })
- await await servers[1].videosCommand.quickUpload({ name: 'video server 2' })
- await await servers[1].videosCommand.quickUpload({ name: 'video 2 server 2' })
- await await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2' })
+ await await servers[0].videos.quickUpload({ name: 'video server 1' })
+ await await servers[1].videos.quickUpload({ name: 'video server 2' })
+ await await servers[1].videos.quickUpload({ name: 'video 2 server 2' })
+ await await servers[1].videos.quickUpload({ name: 'video 3 server 2' })
{
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
server1Videos = data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid }))
}
{
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
server2Videos = data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid }))
}
})
it('Should update plugin settings', async function () {
- await servers[0].pluginsCommand.updateSettings({
+ await servers[0].plugins.updateSettings({
npmName: 'peertube-plugin-auto-block-videos',
settings: {
'blocklist-urls': `http://localhost:${port}/blocklist`,
})
it('Should have video in blacklists', async function () {
- const body = await servers[0].blacklistCommand.list()
+ const body = await servers[0].blacklist.list()
const videoBlacklists = body.data
expect(videoBlacklists).to.have.lengthOf(1)
await check(servers[0], video.uuid, false)
- await servers[0].blacklistCommand.remove({ videoId: video.uuid })
+ await servers[0].blacklist.remove({ videoId: video.uuid })
await check(servers[0], video.uuid, true)
await setAccessTokensToServers(servers)
for (const server of servers) {
- await server.pluginsCommand.install({ npmName: 'peertube-plugin-auto-mute' })
+ await server.plugins.install({ npmName: 'peertube-plugin-auto-mute' })
}
blocklistServer = new MockBlocklist()
port = await blocklistServer.initialize()
- await await servers[0].videosCommand.quickUpload({ name: 'video server 1' })
- await await servers[1].videosCommand.quickUpload({ name: 'video server 2' })
+ await await servers[0].videos.quickUpload({ name: 'video server 1' })
+ await await servers[1].videos.quickUpload({ name: 'video server 2' })
await doubleFollow(servers[0], servers[1])
})
it('Should update plugin settings', async function () {
- await servers[0].pluginsCommand.updateSettings({
+ await servers[0].plugins.updateSettings({
npmName: 'peertube-plugin-auto-mute',
settings: {
'blocklist-urls': `http://localhost:${port}/blocklist`,
await wait(2000)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(1)
})
await wait(2000)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(2)
})
await wait(2000)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(1)
})
await wait(2000)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(2)
})
await wait(2000)
{
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(1)
}
- await servers[0].blocklistCommand.removeFromServerBlocklist({ account })
+ await servers[0].blocklist.removeFromServerBlocklist({ account })
{
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(2)
}
await wait(2000)
{
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(2)
}
})
})
it('Should enable auto mute list', async function () {
- await servers[0].pluginsCommand.updateSettings({
+ await servers[0].plugins.updateSettings({
npmName: 'peertube-plugin-auto-mute',
settings: {
'blocklist-urls': '',
it('Should mute an account on server 1, and server 2 auto mutes it', async function () {
this.timeout(20000)
- await servers[1].pluginsCommand.updateSettings({
+ await servers[1].plugins.updateSettings({
npmName: 'peertube-plugin-auto-mute',
settings: {
'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath,
}
})
- await servers[0].blocklistCommand.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port })
- await servers[0].blocklistCommand.addToMyBlocklist({ server: 'localhost:' + servers[1].port })
+ await servers[0].blocklist.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port })
+ await servers[0].blocklist.addToMyBlocklist({ server: 'localhost:' + servers[1].port })
const res = await makeGetRequest({
url: servers[0].url,
await wait(2000)
for (const server of servers) {
- const { total } = await server.videosCommand.list()
+ const { total } = await server.videos.list()
expect(total).to.equal(1)
}
})
await doubleFollow(servers[0], servers[1])
{
- const user = await servers[0].usersCommand.getMyInfo()
+ const user = await servers[0].users.getMyInfo()
rootAccountId = user.account.id
rootChannelId = user.videoChannels[0].id
}
{
const attr = { username: 'john', password: 'password' }
- await servers[0].usersCommand.create({ username: attr.username, password: attr.password })
- userAccessToken = await servers[0].loginCommand.getAccessToken(attr)
+ await servers[0].users.create({ username: attr.username, password: attr.password })
+ userAccessToken = await servers[0].login.getAccessToken(attr)
- const user = await servers[0].usersCommand.getMyInfo({ token: userAccessToken })
+ const user = await servers[0].users.getMyInfo({ token: userAccessToken })
userAccountId = user.account.id
userChannelId = user.videoChannels[0].id
- const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken })
+ const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken })
userFeedToken = token.feedToken
}
{
- await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'user video' } })
+ await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'user video' } })
}
{
description: 'my super description for server 1',
fixture: 'video_short.webm'
}
- const { id } = await servers[0].videosCommand.upload({ attributes })
+ const { id } = await servers[0].videos.upload({ attributes })
- await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 1' })
- await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 2' })
+ await servers[0].comments.createThread({ videoId: id, text: 'super comment 1' })
+ await servers[0].comments.createThread({ videoId: id, text: 'super comment 2' })
}
{
const attributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED }
- const { id } = await servers[0].videosCommand.upload({ attributes })
+ const { id } = await servers[0].videos.upload({ attributes })
- await servers[0].commentsCommand.createThread({ videoId: id, text: 'comment on unlisted video' })
+ await servers[0].comments.createThread({ videoId: id, text: 'comment on unlisted video' })
}
await waitJobs(servers)
it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () {
for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) {
- const rss = await servers[0].feedCommand.getXML({ feed })
+ const rss = await servers[0].feed.getXML({ feed })
expect(rss).xml.to.be.valid()
- const atom = await servers[0].feedCommand.getXML({ feed, format: 'atom' })
+ const atom = await servers[0].feed.getXML({ feed, format: 'atom' })
expect(atom).xml.to.be.valid()
}
})
it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () {
for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) {
- const jsonText = await servers[0].feedCommand.getJSON({ feed })
+ const jsonText = await servers[0].feed.getJSON({ feed })
expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' })
}
})
it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () {
for (const server of servers) {
- const rss = await server.feedCommand.getXML({ feed: 'videos' })
+ const rss = await server.feed.getXML({ feed: 'videos' })
expect(xmlParser.validate(rss)).to.be.true
const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false })
it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', async function () {
for (const server of servers) {
- const json = await server.feedCommand.getJSON({ feed: 'videos' })
+ const json = await server.feed.getJSON({ feed: 'videos' })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(2)
expect(jsonObj.items[0].attachments).to.exist
it('Should filter by account', async function () {
{
- const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: rootAccountId } })
+ const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: rootAccountId } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('my super name for server 1')
}
{
- const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: userAccountId } })
+ const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: userAccountId } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('user video')
for (const server of servers) {
{
- const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } })
+ const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('my super name for server 1')
}
{
- const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } })
+ const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('user video')
it('Should filter by video channel', async function () {
{
- const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } })
+ const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('my super name for server 1')
}
{
- const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } })
+ const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('user video')
for (const server of servers) {
{
const query = { videoChannelName: 'root_channel@localhost:' + servers[0].port }
- const json = await server.feedCommand.getJSON({ feed: 'videos', query })
+ const json = await server.feed.getJSON({ feed: 'videos', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('my super name for server 1')
{
const query = { videoChannelName: 'john_channel@localhost:' + servers[0].port }
- const json = await server.feedCommand.getJSON({ feed: 'videos', query })
+ const json = await server.feed.getJSON({ feed: 'videos', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('user video')
it('Should correctly have videos feed with HLS only', async function () {
this.timeout(120000)
- await serverHLSOnly.videosCommand.upload({ attributes: { name: 'hls only video' } })
+ await serverHLSOnly.videos.upload({ attributes: { name: 'hls only video' } })
await waitJobs([ serverHLSOnly ])
- const json = await serverHLSOnly.feedCommand.getJSON({ feed: 'videos' })
+ const json = await serverHLSOnly.feed.getJSON({ feed: 'videos' })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].attachments).to.exist
it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () {
for (const server of servers) {
- const json = await server.feedCommand.getJSON({ feed: 'video-comments' })
+ const json = await server.feed.getJSON({ feed: 'video-comments' })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(2)
const remoteHandle = 'root@localhost:' + servers[0].port
- await servers[1].blocklistCommand.addToServerBlocklist({ account: remoteHandle })
+ await servers[1].blocklist.addToServerBlocklist({ account: remoteHandle })
{
- const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 2 } })
+ const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 2 } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(0)
}
- await servers[1].blocklistCommand.removeFromServerBlocklist({ account: remoteHandle })
+ await servers[1].blocklist.removeFromServerBlocklist({ account: remoteHandle })
{
- const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid
+ const videoUUID = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid
await waitJobs(servers)
- await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'super comment' })
+ await servers[0].comments.createThread({ videoId: videoUUID, text: 'super comment' })
await waitJobs(servers)
- const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 3 } })
+ const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 3 } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(3)
}
- await servers[1].blocklistCommand.addToMyBlocklist({ account: remoteHandle })
+ await servers[1].blocklist.addToMyBlocklist({ account: remoteHandle })
{
- const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 4 } })
+ const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 4 } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(2)
}
it('Should list no videos for a user with no videos and no subscriptions', async function () {
const attr = { username: 'feeduser', password: 'password' }
- await servers[0].usersCommand.create({ username: attr.username, password: attr.password })
- const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr)
+ await servers[0].users.create({ username: attr.username, password: attr.password })
+ const feeduserAccessToken = await servers[0].login.getAccessToken(attr)
{
- const user = await servers[0].usersCommand.getMyInfo({ token: feeduserAccessToken })
+ const user = await servers[0].users.getMyInfo({ token: feeduserAccessToken })
feeduserAccountId = user.account.id
}
{
- const token = await servers[0].usersCommand.getMyScopedTokens({ token: feeduserAccessToken })
+ const token = await servers[0].users.getMyScopedTokens({ token: feeduserAccessToken })
feeduserFeedToken = token.feedToken
}
{
- const body = await servers[0].subscriptionsCommand.listVideos({ token: feeduserAccessToken })
+ const body = await servers[0].subscriptions.listVideos({ token: feeduserAccessToken })
expect(body.total).to.equal(0)
const query = { accountId: feeduserAccountId, token: feeduserFeedToken }
- const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos
}
it('Should fail with an invalid token', async function () {
const query = { accountId: feeduserAccountId, token: 'toto' }
- await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with a token of another user', async function () {
const query = { accountId: feeduserAccountId, token: userFeedToken }
- await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should list no videos for a user with videos but no subscriptions', async function () {
- const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken })
+ const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
expect(body.total).to.equal(0)
const query = { accountId: userAccountId, token: userFeedToken }
- const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos
})
it('Should list self videos for a user with a subscription to themselves', async function () {
this.timeout(30000)
- await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port })
await waitJobs(servers)
{
- const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken })
+ const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
expect(body.total).to.equal(1)
expect(body.data[0].name).to.equal('user video')
const query = { accountId: userAccountId, token: userFeedToken, version: 1 }
- const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1) // subscribed to self, it should not list the instance's videos but list john's
}
it('Should list videos of a user\'s subscription', async function () {
this.timeout(30000)
- await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
await waitJobs(servers)
{
- const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken })
+ const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
expect(body.total).to.equal(2, "there should be 2 videos part of the subscription")
const query = { accountId: userAccountId, token: userFeedToken, version: 2 }
- const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(2) // subscribed to root, it should not list the instance's videos but list root/john's
}
})
it('Should renew the token, and so have an invalid old token', async function () {
- await servers[0].usersCommand.renewMyScopedTokens({ token: userAccessToken })
+ await servers[0].users.renewMyScopedTokens({ token: userAccessToken })
const query = { accountId: userAccountId, token: userFeedToken, version: 3 }
- await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should succeed with the new token', async function () {
- const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken })
+ const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken })
userFeedToken = token.feedToken
const query = { accountId: userAccountId, token: userFeedToken, version: 4 }
- await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ await servers[0].feed.getJSON({ feed: 'subscriptions', query })
})
})
it('Should add videos, channel and accounts and get sitemap', async function () {
this.timeout(35000)
- await server.videosCommand.upload({ attributes: { name: 'video 1', nsfw: false } })
- await server.videosCommand.upload({ attributes: { name: 'video 2', nsfw: false } })
- await server.videosCommand.upload({ attributes: { name: 'video 3', privacy: VideoPrivacy.PRIVATE } })
+ await server.videos.upload({ attributes: { name: 'video 1', nsfw: false } })
+ await server.videos.upload({ attributes: { name: 'video 2', nsfw: false } })
+ await server.videos.upload({ attributes: { name: 'video 3', privacy: VideoPrivacy.PRIVATE } })
- await server.channelsCommand.create({ attributes: { name: 'channel1', displayName: 'channel 1' } })
- await server.channelsCommand.create({ attributes: { name: 'channel2', displayName: 'channel 2' } })
+ await server.channels.create({ attributes: { name: 'channel1', displayName: 'channel 1' } })
+ await server.channels.create({ attributes: { name: 'channel2', displayName: 'channel 2' } })
- await server.usersCommand.create({ username: 'user1', password: 'password' })
- await server.usersCommand.create({ username: 'user2', password: 'password' })
+ await server.users.create({ username: 'user1', password: 'password' })
+ await server.users.create({ username: 'user2', password: 'password' })
const res = await makeGetRequest({
url: server.url,
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 () {
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] ])
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')
})
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')
})
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')
})
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')
})
before(async function () {
{
- const { id } = await servers[0].playlistsCommand.create({
+ const { id } = await servers[0].playlists.create({
attributes: {
displayName: 'My playlist',
privacy: VideoPlaylistPrivacy.PRIVATE
}
{
- 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')
})
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,
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
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)
})
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',
})
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 })
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 () {
}
{
- 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')
}
{
- 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')
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 () {
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')
})
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',
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,
})
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)
})
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,
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 () {
})
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,
})
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)
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')
})
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)
})
})
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 },
})
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 () {
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)
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)
})
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
})
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',
})
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)
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
})
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)
})
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)
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)
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
before(async function () {
this.timeout(120000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
webtorrent: {
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 }))
}
})
before(async function () {
this.timeout(60000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: false
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)
}
}
describe('Search filters', function () {
before(async function () {
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
})
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)
})
})
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- command = server.pluginsCommand
+ command = server.plugins
})
it('Should not inject global css file in HTML', async 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)
})
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')
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')
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')
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')
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)
})
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)
})
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')
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 () {
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')
})
})
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)
})
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')
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)
})
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')
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)
})
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')
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)
}
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
})
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
})
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}`)
})
})
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 () {
})
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({
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')
})
})
}
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
})
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')
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,
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) {
}
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' ])
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)
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)
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)
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)
})
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)
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)
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)
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)
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')
})
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')
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`
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 () {
})
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,
})
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,
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') })
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
})
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
})
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
})
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
})
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
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')
}
{
- const categories = await server.videosCommand.getCategories()
+ const categories = await server.videos.getCategories()
expect(categories[1]).to.equal('Music')
expect(categories[2]).to.equal('Films')
}
{
- 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')
}
{
- const privacies = await server.videosCommand.getPrivacies()
+ const privacies = await server.videos.getPrivacies()
expect(privacies[1]).to.exist
expect(privacies[2]).to.exist
}
{
- const playlistPrivacies = await server.playlistsCommand.getPrivacies()
+ const playlistPrivacies = await server.playlists.getPrivacies()
expect(playlistPrivacies[1]).to.exist
expect(playlistPrivacies[2]).to.exist
const version = require('../../../package.json').version
async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) {
- const token = await server.loginCommand.getAccessToken(username, password)
- const me = await server.usersCommand.getMyInfo({ token })
+ const token = await server.login.getAccessToken(username, password)
+ const me = await server.users.getMyInfo({ token })
if (me.role !== UserRole.ADMINISTRATOR) {
console.error('You must be an administrator.')
Object.assign(videoAttributes, booleanAttributes)
if (options.channelName) {
- const videoChannel = await server.channelsCommand.get({ channelName: options.channelName })
+ const videoChannel = await server.channels.get({ channelName: options.channelName })
Object.assign(videoAttributes, { channelId: videoChannel.id })
}
async function assignToken (server: ServerInfo, username: string, password: string) {
- const bodyClient = await server.loginCommand.getClient()
+ const bodyClient = await server.login.getClient()
const client = { id: bodyClient.client_id, secret: bodyClient.client_secret }
- const body = await server.loginCommand.login({ client, user: { username, password } })
+ const body = await server.login.login({ client, user: { username, password } })
server.accessToken = body.access_token
}
}
const server = buildServer(url)
- const { data } = await server.searchCommand.advancedVideoSearch({
+ const { data } = await server.search.advancedVideoSearch({
search: {
search: videoInfo.title,
sort: '-match',
log.info('\nUploading on PeerTube video "%s".', attributes.name)
try {
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
} catch (err) {
if (err.message.indexOf('401') !== -1) {
log.info('Got 401 Unauthorized, token may have expired, renewing token and retry.')
- server.accessToken = await server.loginCommand.getAccessToken(username, password)
+ server.accessToken = await server.login.getAccessToken(username, password)
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
} else {
exitError(err.message)
}
if (categoryString === 'News & Politics') return 11
- const categoriesServer = await server.videosCommand.getCategories()
+ const categoriesServer = await server.videos.getCategories()
for (const key of Object.keys(categoriesServer)) {
const categoryServer = categoriesServer[key]
if (options.onlyThemes) pluginType = PluginType.THEME
if (options.onlyPlugins) pluginType = PluginType.PLUGIN
- const { data } = await server.pluginsCommand.list({ start: 0, count: 100, sort: 'name', pluginType })
+ const { data } = await server.plugins.list({ start: 0, count: 100, sort: 'name', pluginType })
const table = new CliTable3({
head: [ 'name', 'version', 'homepage' ],
await assignToken(server, username, password)
try {
- await server.pluginsCommand.install({ npmName: options.npmName, path: options.path })
+ await server.plugins.install({ npmName: options.npmName, path: options.path })
} catch (err) {
console.error('Cannot install plugin.', err)
process.exit(-1)
await assignToken(server, username, password)
try {
- await server.pluginsCommand.update({ npmName: options.npmName, path: options.path })
+ await server.plugins.update({ npmName: options.npmName, path: options.path })
} catch (err) {
console.error('Cannot update plugin.', err)
process.exit(-1)
await assignToken(server, username, password)
try {
- await server.pluginsCommand.uninstall({ npmName: options.npmName })
+ await server.plugins.uninstall({ npmName: options.npmName })
} catch (err) {
console.error('Cannot uninstall plugin.', err)
process.exit(-1)
const server = buildServer(url)
await assignToken(server, username, password)
- const { data } = await server.redundancyCommand.listVideos({ start: 0, count: 100, sort: 'name', target })
+ const { data } = await server.redundancy.listVideos({ start: 0, count: 100, sort: 'name', target })
const table = new CliTable3({
head: [ 'video id', 'video name', 'video url', 'files', 'playlists', 'by instances', 'total size' ]
}
try {
- await server.redundancyCommand.addVideo({ videoId: options.video })
+ await server.redundancy.addVideo({ videoId: options.video })
console.log('Video will be duplicated by your instance!')
const videoId = parseInt(options.video + '', 10)
- const myVideoRedundancies = await server.redundancyCommand.listVideos({ target: 'my-videos' })
+ const myVideoRedundancies = await server.redundancy.listVideos({ target: 'my-videos' })
let videoRedundancy = myVideoRedundancies.data.find(r => videoId === r.id)
if (!videoRedundancy) {
- const remoteVideoRedundancies = await server.redundancyCommand.listVideos({ target: 'remote-videos' })
+ const remoteVideoRedundancies = await server.redundancy.listVideos({ target: 'remote-videos' })
videoRedundancy = remoteVideoRedundancies.data.find(r => videoId === r.id)
}
.map(r => r.id)
for (const id of ids) {
- await server.redundancyCommand.removeVideo({ redundancyId: id })
+ await server.redundancy.removeVideo({ redundancyId: id })
}
console.log('Video redundancy removed!')
}
try {
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
console.log(`Video ${options.videoName} uploaded.`)
process.exit(0)
} catch (err) {
const attributes: LiveVideoCreate = {
name: 'live',
saveReplay: true,
- channelId: server.videoChannel.id,
+ channelId: server.store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
console.log('Creating live.')
- const { uuid: liveVideoUUID } = await server.liveCommand.create({ fields: attributes })
+ const { uuid: liveVideoUUID } = await server.live.create({ fields: attributes })
- const live = await server.liveCommand.get({ videoId: liveVideoUUID })
+ const live = await server.live.get({ videoId: liveVideoUUID })
console.log('Sending RTMP stream.')
// ----------------------------------------------------------------------------
async function buildConfig (server: ServerInfo, commandType: CommandType) {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
instance: {
customizations: {
}
async function testFileExistsOrNot (server: ServerInfo, directory: string, filePath: string, exist: boolean) {
- const base = server.serversCommand.buildDirectory(directory)
+ const base = server.servers.buildDirectory(directory)
expect(await pathExists(join(base, filePath))).to.equal(exist)
}
async function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) {
const torrentName = videoUUID + '-' + resolution + '.torrent'
- const torrentPath = server.serversCommand.buildDirectory(join('torrents', torrentName))
+ const torrentPath = server.servers.buildDirectory(join('torrents', torrentName))
const data = await readFile(torrentPath)
async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
await Promise.all([
- server1.followsCommand.follow({ targets: [ server2.url ] }),
- server2.followsCommand.follow({ targets: [ server1.url ] })
+ server1.follows.follow({ targets: [ server2.url ] }),
+ server2.follows.follow({ targets: [ server1.url ] })
])
// Wait request propagation
// Check if each server has pending request
for (const server of servers) {
for (const state of states) {
- const p = server.jobsCommand.getJobsList({
+ const p = server.jobs.getJobsList({
state,
start: 0,
count: 10,
tasks.push(p)
}
- const p = server.debugCommand.getDebug()
+ const p = server.debug.getDebug()
.then(obj => {
if (obj.activityPubMessagesWaiting !== 0) {
pendingRequests = true
}
private getPackageJSONPath (npmName: string) {
- return this.server.serversCommand.buildDirectory(join('plugins', 'node_modules', npmName, 'package.json'))
+ return this.server.servers.buildDirectory(join('plugins', 'node_modules', npmName, 'package.json'))
}
}
import { ServerInfo } from '../server/servers'
async function testHelloWorldRegisteredSettings (server: ServerInfo) {
- const body = await server.pluginsCommand.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' })
+ const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' })
const registeredSettings = body.registeredSettings
expect(registeredSettings).to.have.length.at.least(1)
if (isGithubCI()) {
await ensureDir('artifacts')
- const origin = this.server.serversCommand.buildDirectory('logs/peertube.log')
+ const origin = this.server.servers.buildDirectory('logs/peertube.log')
const destname = `peertube-${this.server.internalServerNumber}.log`
console.log('Saving logs %s.', destname)
}
async waitUntilLog (str: string, count = 1, strictCount = true) {
- const logfile = this.server.serversCommand.buildDirectory('logs/peertube.log')
+ const logfile = this.server.servers.buildDirectory('logs/peertube.log')
while (true) {
const buf = await readFile(logfile)
}
async getServerFileSize (subPath: string) {
- const path = this.server.serversCommand.buildDirectory(subPath)
+ const path = this.server.servers.buildDirectory(subPath)
return getFileSize(path)
}
parallel?: boolean
internalServerNumber: number
+
serverNumber?: number
+ customConfigFile?: string
- client?: {
- id?: string
- secret?: string
- }
+ store?: {
+ client?: {
+ id?: string
+ secret?: string
+ }
- user?: {
- username: string
- password: string
- email?: string
- }
+ user?: {
+ username: string
+ password: string
+ email?: string
+ }
- customConfigFile?: string
+ channel?: VideoChannel
- accessToken?: string
- refreshToken?: string
- videoChannel?: VideoChannel
+ video?: {
+ id: number
+ uuid: string
+ shortUUID: string
+ name?: string
+ url?: string
- video?: {
- id: number
- uuid: string
- shortUUID: string
- name?: string
- url?: string
+ account?: {
+ name: string
+ }
- account?: {
- name: string
+ embedPath?: string
}
- embedPath?: string
+ videos?: { id: number, uuid: string }[]
}
- remoteVideo?: {
- id: number
- uuid: string
- }
+ accessToken?: string
+ refreshToken?: string
- videos?: { id: number, uuid: string }[]
-
- bulkCommand?: BulkCommand
- cliCommand?: CLICommand
- customPageCommand?: CustomPagesCommand
- feedCommand?: FeedCommand
- logsCommand?: LogsCommand
- abusesCommand?: AbusesCommand
- overviewsCommand?: OverviewsCommand
- searchCommand?: SearchCommand
- contactFormCommand?: ContactFormCommand
- debugCommand?: DebugCommand
- followsCommand?: FollowsCommand
- jobsCommand?: JobsCommand
- pluginsCommand?: PluginsCommand
- redundancyCommand?: RedundancyCommand
- statsCommand?: StatsCommand
- configCommand?: ConfigCommand
- socketIOCommand?: SocketIOCommand
- accountsCommand?: AccountsCommand
- blocklistCommand?: BlocklistCommand
- subscriptionsCommand?: SubscriptionsCommand
- liveCommand?: LiveCommand
- servicesCommand?: ServicesCommand
- blacklistCommand?: BlacklistCommand
- captionsCommand?: CaptionsCommand
- changeOwnershipCommand?: ChangeOwnershipCommand
- playlistsCommand?: PlaylistsCommand
- historyCommand?: HistoryCommand
- importsCommand?: ImportsCommand
- streamingPlaylistsCommand?: StreamingPlaylistsCommand
- channelsCommand?: ChannelsCommand
- commentsCommand?: CommentsCommand
- sqlCommand?: SQLCommand
- notificationsCommand?: NotificationsCommand
- serversCommand?: ServersCommand
- loginCommand?: LoginCommand
- usersCommand?: UsersCommand
- videosCommand?: VideosCommand
+ bulk?: BulkCommand
+ cli?: CLICommand
+ customPage?: CustomPagesCommand
+ feed?: FeedCommand
+ logs?: LogsCommand
+ abuses?: AbusesCommand
+ overviews?: OverviewsCommand
+ search?: SearchCommand
+ contactForm?: ContactFormCommand
+ debug?: DebugCommand
+ follows?: FollowsCommand
+ jobs?: JobsCommand
+ plugins?: PluginsCommand
+ redundancy?: RedundancyCommand
+ stats?: StatsCommand
+ config?: ConfigCommand
+ socketIO?: SocketIOCommand
+ accounts?: AccountsCommand
+ blocklist?: BlocklistCommand
+ subscriptions?: SubscriptionsCommand
+ live?: LiveCommand
+ services?: ServicesCommand
+ blacklist?: BlacklistCommand
+ captions?: CaptionsCommand
+ changeOwnership?: ChangeOwnershipCommand
+ playlists?: PlaylistsCommand
+ history?: HistoryCommand
+ imports?: ImportsCommand
+ streamingPlaylists?: StreamingPlaylistsCommand
+ channels?: ChannelsCommand
+ comments?: CommentsCommand
+ sql?: SQLCommand
+ notifications?: NotificationsCommand
+ servers?: ServersCommand
+ login?: LoginCommand
+ users?: UsersCommand
+ videos?: VideosCommand
}
function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) {
url: `http://localhost:${port}`,
host: `localhost:${port}`,
hostname: 'localhost',
- client: {
- id: null,
- secret: null
- },
- user: {
- username: null,
- password: null
+ store: {
+ client: {
+ id: null,
+ secret: null
+ },
+ user: {
+ username: null,
+ password: null
+ }
}
}
const regexp = regexps[key]
const matches = data.toString().match(regexp)
if (matches !== null) {
- if (key === 'client_id') server.client.id = matches[1]
- else if (key === 'client_secret') server.client.secret = matches[1]
- else if (key === 'user_username') server.user.username = matches[1]
- else if (key === 'user_password') server.user.password = matches[1]
+ if (key === 'client_id') server.store.client.id = matches[1]
+ else if (key === 'client_secret') server.store.client.secret = matches[1]
+ else if (key === 'user_username') server.store.user.username = matches[1]
+ else if (key === 'user_password') server.store.user.password = matches[1]
}
}
}
function assignCommands (server: ServerInfo) {
- server.bulkCommand = new BulkCommand(server)
- server.cliCommand = new CLICommand(server)
- server.customPageCommand = new CustomPagesCommand(server)
- server.feedCommand = new FeedCommand(server)
- server.logsCommand = new LogsCommand(server)
- server.abusesCommand = new AbusesCommand(server)
- server.overviewsCommand = new OverviewsCommand(server)
- server.searchCommand = new SearchCommand(server)
- server.contactFormCommand = new ContactFormCommand(server)
- server.debugCommand = new DebugCommand(server)
- server.followsCommand = new FollowsCommand(server)
- server.jobsCommand = new JobsCommand(server)
- server.pluginsCommand = new PluginsCommand(server)
- server.redundancyCommand = new RedundancyCommand(server)
- server.statsCommand = new StatsCommand(server)
- server.configCommand = new ConfigCommand(server)
- server.socketIOCommand = new SocketIOCommand(server)
- server.accountsCommand = new AccountsCommand(server)
- server.blocklistCommand = new BlocklistCommand(server)
- server.subscriptionsCommand = new SubscriptionsCommand(server)
- server.liveCommand = new LiveCommand(server)
- server.servicesCommand = new ServicesCommand(server)
- server.blacklistCommand = new BlacklistCommand(server)
- server.captionsCommand = new CaptionsCommand(server)
- server.changeOwnershipCommand = new ChangeOwnershipCommand(server)
- server.playlistsCommand = new PlaylistsCommand(server)
- server.historyCommand = new HistoryCommand(server)
- server.importsCommand = new ImportsCommand(server)
- server.streamingPlaylistsCommand = new StreamingPlaylistsCommand(server)
- server.channelsCommand = new ChannelsCommand(server)
- server.commentsCommand = new CommentsCommand(server)
- server.sqlCommand = new SQLCommand(server)
- server.notificationsCommand = new NotificationsCommand(server)
- server.serversCommand = new ServersCommand(server)
- server.loginCommand = new LoginCommand(server)
- server.usersCommand = new UsersCommand(server)
- server.videosCommand = new VideosCommand(server)
+ server.bulk = new BulkCommand(server)
+ server.cli = new CLICommand(server)
+ server.customPage = new CustomPagesCommand(server)
+ server.feed = new FeedCommand(server)
+ server.logs = new LogsCommand(server)
+ server.abuses = new AbusesCommand(server)
+ server.overviews = new OverviewsCommand(server)
+ server.search = new SearchCommand(server)
+ server.contactForm = new ContactFormCommand(server)
+ server.debug = new DebugCommand(server)
+ server.follows = new FollowsCommand(server)
+ server.jobs = new JobsCommand(server)
+ server.plugins = new PluginsCommand(server)
+ server.redundancy = new RedundancyCommand(server)
+ server.stats = new StatsCommand(server)
+ server.config = new ConfigCommand(server)
+ server.socketIO = new SocketIOCommand(server)
+ server.accounts = new AccountsCommand(server)
+ server.blocklist = new BlocklistCommand(server)
+ server.subscriptions = new SubscriptionsCommand(server)
+ server.live = new LiveCommand(server)
+ server.services = new ServicesCommand(server)
+ server.blacklist = new BlacklistCommand(server)
+ server.captions = new CaptionsCommand(server)
+ server.changeOwnership = new ChangeOwnershipCommand(server)
+ server.playlists = new PlaylistsCommand(server)
+ server.history = new HistoryCommand(server)
+ server.imports = new ImportsCommand(server)
+ server.streamingPlaylists = new StreamingPlaylistsCommand(server)
+ server.channels = new ChannelsCommand(server)
+ server.comments = new CommentsCommand(server)
+ server.sql = new SQLCommand(server)
+ server.notifications = new NotificationsCommand(server)
+ server.servers = new ServersCommand(server)
+ server.login = new LoginCommand(server)
+ server.users = new UsersCommand(server)
+ server.videos = new VideosCommand(server)
}
async function reRunServer (server: ServerInfo, configOverride?: any) {
for (const server of servers) {
if (!server.app) continue
- await server.sqlCommand.cleanup()
+ await server.sql.cleanup()
process.kill(-server.app.pid)
let p: Promise<any>[] = []
for (const server of servers) {
- p = p.concat(server.serversCommand.cleanupTests())
+ p = p.concat(server.servers.cleanupTests())
}
return Promise.all(p)
}) {
const { server, handle, followers, following } = options
- const body = await server.accountsCommand.list()
+ const body = await server.accounts.list()
const account = body.data.find(a => a.name + '@' + a.host === handle)
const message = `${handle} on ${server.url}`
client?: { id?: string, secret?: string }
user?: { username: string, password?: string }
} = {}) {
- const { client = this.server.client, user = this.server.user } = options
+ const { client = this.server.store.client, user = this.server.store.user } = options
const path = '/api/v1/users/token'
const body = {
async getAccessToken (arg1?: { username: string, password?: string } | string, password?: string) {
let user: { username: string, password?: string }
- if (!arg1) user = this.server.user
+ if (!arg1) user = this.server.store.user
else if (typeof arg1 === 'object') user = arg1
else user = { username: arg1, password }
const path = '/api/v1/users/token'
const body = {
- client_id: this.server.client.id,
- client_secret: this.server.client.secret,
+ client_id: this.server.store.client.id,
+ client_secret: this.server.store.client.secret,
username: username,
response_type: 'code',
grant_type: 'password',
const path = '/api/v1/users/token'
const body = {
- client_id: this.server.client.id,
- client_secret: this.server.client.secret,
+ client_id: this.server.store.client.id,
+ client_secret: this.server.store.client.secret,
refresh_token: options.refreshToken,
response_type: 'code',
grant_type: 'refresh_token'
const tasks: Promise<any>[] = []
for (const server of servers) {
- const p = server.loginCommand.getAccessToken()
+ const p = server.login.getAccessToken()
.then(t => { server.accessToken = t })
tasks.push(p)
}
const check = base.check || { web: true, mail: true }
if (check.web) {
- const notification = await base.server.notificationsCommand.getLastest({ token: base.token })
+ const notification = await base.server.notifications.getLastest({ token: base.token })
if (notification || checkType !== 'absence') {
notificationChecker(notification, checkType)
}
const user = { username: 'user_1', password: 'super password' }
- await servers[0].usersCommand.create({ ...user, videoQuota: 10 * 1000 * 1000 })
- const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ await servers[0].users.create({ ...user, videoQuota: 10 * 1000 * 1000 })
+ const userAccessToken = await servers[0].login.getAccessToken(user)
- await servers[0].notificationsCommand.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() })
- await servers[0].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() })
+ await servers[0].notifications.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() })
+ await servers[0].notifications.updateMySettings({ settings: getAllNotificationsSettings() })
if (serversCount > 1) {
- await servers[1].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() })
+ await servers[1].notifications.updateMySettings({ settings: getAllNotificationsSettings() })
}
{
- const socket = servers[0].socketIOCommand.getUserNotificationSocket({ token: userAccessToken })
+ const socket = servers[0].socketIO.getUserNotificationSocket({ token: userAccessToken })
socket.on('new-notification', n => userNotifications.push(n))
}
{
- const socket = servers[0].socketIOCommand.getUserNotificationSocket()
+ const socket = servers[0].socketIO.getUserNotificationSocket()
socket.on('new-notification', n => adminNotifications.push(n))
}
if (serversCount > 1) {
- const socket = servers[1].socketIOCommand.getUserNotificationSocket()
+ const socket = servers[1].socketIO.getUserNotificationSocket()
socket.on('new-notification', n => adminNotificationsServer2.push(n))
}
- const { videoChannels } = await servers[0].usersCommand.getMyInfo()
+ const { videoChannels } = await servers[0].users.getMyInfo()
const channelId = videoChannels[0].id
return {
const password = 'password'
const user = await this.create({ username, password })
- const token = await this.server.loginCommand.getAccessToken({ username, password })
+ const token = await this.server.login.getAccessToken({ username, password })
const me = await this.getMyInfo({ token })
const password = 'password'
await this.create({ username, password })
- return this.server.loginCommand.getAccessToken({ username, password })
+ return this.server.login.getAccessToken({ username, password })
}
register (options: OverrideCommandOptions & {
const tasks: Promise<any>[] = []
for (const server of servers) {
- const p = server.usersCommand.getMyInfo()
- .then(user => { server.videoChannel = user.videoChannels[0] })
+ const p = server.users.getMyInfo()
+ .then(user => { server.store.channel = user.videoChannels[0] })
tasks.push(p)
}
const { resolution, segment, videoUUID } = options
const segmentName = `${resolution}-00000${segment}.ts`
- return this.server.serversCommand.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false)
+ return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false)
}
async waitUntilSaved (options: OverrideCommandOptions & {
let video: VideoDetails
do {
- video = await this.server.videosCommand.getWithToken({ token: options.token, id: options.videoId })
+ video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId })
await wait(500)
} while (video.isLive === true && video.state.id !== VideoState.PUBLISHED)
async countPlaylists (options: OverrideCommandOptions & {
videoUUID: string
}) {
- const basePath = this.server.serversCommand.buildDirectory('streaming-playlists')
+ const basePath = this.server.servers.buildDirectory('streaming-playlists')
const hlsPath = join(basePath, 'hls', options.videoUUID)
const files = await readdir(hlsPath)
let video: VideoDetails
do {
- video = await this.server.videosCommand.getWithToken({ token: options.token, id: options.videoId })
+ video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId })
await wait(500)
} while (video.state.id !== options.state)
async function waitUntilLivePublishedOnAllServers (servers: ServerInfo[], videoId: string) {
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId })
+ await server.live.waitUntilPublished({ videoId })
}
}
async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
- const basePath = server.serversCommand.buildDirectory('streaming-playlists')
+ const basePath = server.servers.buildDirectory('streaming-playlists')
const hlsPath = join(basePath, 'hls', videoUUID)
if (resolutions.length === 0) {
const attributes = {
...options.attributes,
- videoId: await this.server.videosCommand.getId({ ...options, uuid: options.attributes.videoId })
+ videoId: await this.server.videos.getId({ ...options, uuid: options.attributes.videoId })
}
const path = '/api/v1/video-playlists/' + options.playlistId + '/videos'
hlsPlaylist: VideoStreamingPlaylist
}) {
const { server, baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist } = options
- const command = server.streamingPlaylistsCommand
+ const command = server.streamingPlaylists
const playlist = await command.get({ url: `${baseUrlPlaylist}/${videoUUID}/${resolution}.m3u8` })
hlsPlaylist: VideoStreamingPlaylist
}) {
const { server, baseUrlSegment, videoUUID, segmentName, hlsPlaylist } = options
- const command = server.streamingPlaylistsCommand
+ const command = server.streamingPlaylists
const segmentBody = await command.getSegment({ url: `${baseUrlSegment}/${videoUUID}/${segmentName}` })
const shaBody = await command.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url })
}) {
const { server, playlistUrl, resolutions } = options
- const masterPlaylist = await server.streamingPlaylistsCommand.get({ url: playlistUrl })
+ const masterPlaylist = await server.streamingPlaylists.get({ url: playlistUrl })
for (const resolution of resolutions) {
const reg = new RegExp(
let defaultChannelId = 1
try {
- const { videoChannels } = await this.server.usersCommand.getMyInfo({ token: options.token })
+ const { videoChannels } = await this.server.users.getMyInfo({ token: options.token })
defaultChannelId = videoChannels[0].id
} catch (e) { /* empty */ }
]
) {
for (const directory of directories) {
- const directoryPath = server.serversCommand.buildDirectory(directory)
+ const directoryPath = server.servers.buildDirectory(directory)
const directoryExists = await pathExists(directoryPath)
if (directoryExists === false) continue
mode: 'legacy' | 'resumable' = 'legacy'
) {
return mode === 'legacy'
- ? server.videosCommand.buildLegacyUpload({ token, attributes, expectedStatus })
- : server.videosCommand.buildResumeUpload({ token, attributes, expectedStatus })
+ ? server.videos.buildLegacyUpload({ token, attributes, expectedStatus })
+ : server.videos.buildResumeUpload({ token, attributes, expectedStatus })
}
async function completeVideoCheck (
expect(video.originallyPublishedAt).to.be.null
}
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(attributes.files.length)
expect(videoDetails.tags).to.deep.equal(attributes.tags)
additionalParams?: VideoEdit & { prefixName?: string }
) {
const server = servers.find(s => s.serverNumber === serverNumber)
- const res = await server.videosCommand.randomUpload({ wait: false, ...additionalParams })
+ const res = await server.videos.randomUpload({ wait: false, ...additionalParams })
await waitJobs(servers)