Shorter server command names
This commit is contained in:
parent
d23dd9fbfc
commit
89d241a79c
|
@ -210,29 +210,29 @@ async function prepare () {
|
|||
}
|
||||
|
||||
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'
|
||||
|
|
|
@ -46,9 +46,9 @@ describe('Test AP cleaner', function () {
|
|||
// 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 ]
|
||||
|
||||
|
@ -56,8 +56,8 @@ describe('Test AP cleaner', function () {
|
|||
|
||||
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' })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ describe('Test AP cleaner', function () {
|
|||
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)
|
||||
|
@ -78,9 +78,9 @@ describe('Test AP cleaner', function () {
|
|||
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)
|
||||
|
@ -88,14 +88,14 @@ describe('Test AP cleaner', function () {
|
|||
|
||||
// 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)
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ describe('Test AP cleaner', function () {
|
|||
|
||||
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' })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ describe('Test AP cleaner', 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(0)
|
||||
expect(video.dislikes).to.equal(3)
|
||||
}
|
||||
|
@ -124,10 +124,10 @@ describe('Test AP cleaner', function () {
|
|||
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)
|
||||
|
@ -135,14 +135,14 @@ describe('Test AP cleaner', function () {
|
|||
|
||||
// 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)
|
||||
}
|
||||
|
@ -151,15 +151,15 @@ describe('Test AP cleaner', function () {
|
|||
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)
|
||||
})
|
||||
|
||||
|
@ -167,17 +167,17 @@ describe('Test AP cleaner', function () {
|
|||
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)
|
||||
}
|
||||
})
|
||||
|
@ -188,7 +188,7 @@ describe('Test AP cleaner', function () {
|
|||
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}$`)
|
||||
|
@ -217,7 +217,7 @@ describe('Test AP cleaner', function () {
|
|||
|
||||
{
|
||||
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)
|
||||
|
@ -234,7 +234,7 @@ describe('Test AP cleaner', function () {
|
|||
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}`)
|
||||
|
@ -260,7 +260,7 @@ describe('Test AP cleaner', function () {
|
|||
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -68,12 +68,12 @@ describe('Test activitypub', function () {
|
|||
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])
|
||||
|
|
|
@ -21,24 +21,24 @@ describe('Test ActivityPub fetcher', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -49,7 +49,7 @@ describe('Test ActivityPub fetcher', function () {
|
|||
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')
|
||||
|
@ -58,7 +58,7 @@ describe('Test ActivityPub fetcher', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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')
|
||||
|
|
|
@ -34,28 +34,28 @@ describe('Test AP refresher', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -70,15 +70,15 @@ describe('Test AP refresher', function () {
|
|||
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 () {
|
||||
|
@ -86,18 +86,18 @@ describe('Test AP refresher', 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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -106,13 +106,13 @@ describe('Test AP refresher', function () {
|
|||
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 })
|
||||
|
@ -132,15 +132,15 @@ describe('Test AP refresher', function () {
|
|||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey:
|
|||
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)
|
||||
])
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ function setUpdatedAtOfServer (onServer: ServerInfo, ofServer: ServerInfo, updat
|
|||
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)
|
||||
])
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,12 @@ describe('Test abuses API validators', function () {
|
|||
|
||||
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 () {
|
||||
|
@ -224,25 +224,25 @@ describe('Test abuses API validators', 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,
|
||||
|
@ -255,19 +255,19 @@ describe('Test abuses API validators', function () {
|
|||
})
|
||||
|
||||
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 })
|
||||
})
|
||||
|
@ -275,7 +275,7 @@ describe('Test abuses API validators', function () {
|
|||
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
|
||||
},
|
||||
|
@ -414,8 +414,8 @@ describe('Test abuses API validators', function () {
|
|||
|
||||
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 ])
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ describe('Test accounts API validators', function () {
|
|||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ describe('Test blocklist API validators', function () {
|
|||
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])
|
||||
})
|
||||
|
|
|
@ -23,9 +23,9 @@ describe('Test bulk API validators', 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 removing comments of', function () {
|
||||
|
|
|
@ -205,8 +205,8 @@ describe('Test config API validators', 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 () {
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('Test contact form API validators', 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 () {
|
||||
|
|
|
@ -25,9 +25,9 @@ describe('Test custom pages validators', 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 () {
|
||||
|
|
|
@ -29,8 +29,8 @@ describe('Test debug API validators', 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 () {
|
||||
|
|
|
@ -39,8 +39,8 @@ describe('Test server follows API validators', 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 () {
|
||||
|
|
|
@ -34,8 +34,8 @@ describe('Test jobs API validators', 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 () {
|
||||
|
|
|
@ -35,7 +35,7 @@ describe('Test video lives API validator', function () {
|
|||
|
||||
await setAccessTokensToServers([ server ])
|
||||
|
||||
await server.configCommand.updateCustomSubConfig({
|
||||
await server.config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
live: {
|
||||
enabled: true,
|
||||
|
@ -48,19 +48,19 @@ describe('Test video lives API validator', function () {
|
|||
|
||||
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 () {
|
||||
|
@ -144,10 +144,10 @@ describe('Test video lives API validator', 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 }
|
||||
|
@ -230,7 +230,7 @@ describe('Test video lives API validator', function () {
|
|||
})
|
||||
|
||||
it('Should forbid if live is disabled', async function () {
|
||||
await server.configCommand.updateCustomSubConfig({
|
||||
await server.config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
live: {
|
||||
enabled: false
|
||||
|
@ -250,7 +250,7 @@ describe('Test video lives API validator', function () {
|
|||
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,
|
||||
|
@ -271,7 +271,7 @@ describe('Test video lives API validator', function () {
|
|||
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,
|
||||
|
@ -290,7 +290,7 @@ describe('Test video lives API validator', function () {
|
|||
})
|
||||
|
||||
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,
|
||||
|
@ -309,7 +309,7 @@ describe('Test video lives API validator', function () {
|
|||
})
|
||||
|
||||
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,
|
||||
|
@ -401,7 +401,7 @@ describe('Test video lives API validator', function () {
|
|||
})
|
||||
|
||||
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,
|
||||
|
|
|
@ -29,8 +29,8 @@ describe('Test logs API validators', 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 logs', function () {
|
||||
|
|
|
@ -42,17 +42,17 @@ describe('Test server plugins API validators', 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
|
||||
}
|
||||
|
|
|
@ -40,16 +40,16 @@ describe('Test server redundancy API validators', function () {
|
|||
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 () {
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
} from '@shared/extra-utils'
|
||||
|
||||
function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) {
|
||||
return server.configCommand.updateCustomSubConfig({
|
||||
return server.config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
search: {
|
||||
searchIndex: {
|
||||
|
|
|
@ -25,14 +25,14 @@ describe('Test services API validators', function () {
|
|||
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
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -48,7 +48,7 @@ describe('Test services API validators', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
})
|
||||
|
||||
|
@ -63,37 +63,37 @@ describe('Test services API validators', function () {
|
|||
})
|
||||
|
||||
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,
|
||||
|
|
|
@ -29,12 +29,12 @@ describe('Test upload quota', function () {
|
|||
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 () {
|
||||
|
@ -43,8 +43,8 @@ describe('Test upload 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++) {
|
||||
|
@ -58,8 +58,8 @@ describe('Test upload 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++) {
|
||||
|
@ -73,16 +73,16 @@ describe('Test upload quota', function () {
|
|||
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)
|
||||
|
@ -98,7 +98,7 @@ describe('Test upload quota', function () {
|
|||
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' })
|
||||
|
@ -107,7 +107,7 @@ describe('Test upload quota', function () {
|
|||
|
||||
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
|
||||
|
@ -118,7 +118,7 @@ describe('Test upload quota', function () {
|
|||
})
|
||||
|
||||
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
|
||||
|
|
|
@ -38,8 +38,8 @@ describe('Test user subscriptions API validators', 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 my subscriptions', function () {
|
||||
|
|
|
@ -60,27 +60,27 @@ describe('Test users API validators', 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
|
||||
|
@ -341,7 +341,7 @@ describe('Test users API validators', function () {
|
|||
|
||||
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',
|
||||
|
@ -596,28 +596,28 @@ describe('Test users API validators', function () {
|
|||
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()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -769,11 +769,11 @@ describe('Test users API validators', function () {
|
|||
|
||||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -781,7 +781,7 @@ describe('Test users API validators', function () {
|
|||
let command: UsersCommand
|
||||
|
||||
before(function () {
|
||||
command = server.usersCommand
|
||||
command = server.users
|
||||
})
|
||||
|
||||
it('Should fail with a non authenticated user', async function () {
|
||||
|
@ -846,54 +846,54 @@ describe('Test users API validators', 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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1011,7 +1011,7 @@ describe('Test users API validators', function () {
|
|||
|
||||
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' } }
|
||||
|
||||
|
@ -1055,7 +1055,7 @@ describe('Test users API validators', function () {
|
|||
|
||||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -40,41 +40,41 @@ describe('Test video blacklist API validators', function () {
|
|||
{
|
||||
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 })
|
||||
})
|
||||
|
@ -86,13 +86,13 @@ describe('Test video blacklist API validators', function () {
|
|||
})
|
||||
|
||||
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,
|
||||
|
@ -104,7 +104,7 @@ describe('Test video blacklist API validators', function () {
|
|||
})
|
||||
|
||||
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 })
|
||||
|
@ -124,7 +124,7 @@ describe('Test video blacklist API validators', function () {
|
|||
})
|
||||
|
||||
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({
|
||||
|
@ -159,13 +159,13 @@ describe('Test video blacklist API validators', function () {
|
|||
})
|
||||
|
||||
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,
|
||||
|
@ -177,14 +177,14 @@ describe('Test video blacklist API validators', function () {
|
|||
})
|
||||
|
||||
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({
|
||||
|
@ -200,27 +200,27 @@ describe('Test video blacklist API validators', function () {
|
|||
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
|
||||
}
|
||||
})
|
||||
|
@ -229,11 +229,11 @@ describe('Test video blacklist API validators', function () {
|
|||
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 () {
|
||||
|
@ -246,7 +246,7 @@ describe('Test video blacklist API validators', 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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -254,11 +254,11 @@ describe('Test video blacklist API validators', function () {
|
|||
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 () {
|
||||
|
@ -274,11 +274,11 @@ describe('Test video blacklist API validators', 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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -30,15 +30,15 @@ describe('Test video captions API validator', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -152,7 +152,7 @@ describe('Test video captions API validator', function () {
|
|||
// })
|
||||
|
||||
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',
|
||||
|
|
|
@ -44,11 +44,11 @@ describe('Test video channels API validator', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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 () {
|
||||
|
@ -81,7 +81,7 @@ describe('Test video channels API validator', 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 () {
|
||||
|
|
|
@ -38,26 +38,26 @@ describe('Test video comments API validator', 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)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -274,7 +274,7 @@ describe('Test video comments API validator', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -289,12 +289,12 @@ describe('Test video comments API validator', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ describe('Test video comments API validator', function () {
|
|||
|
||||
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'
|
||||
})
|
||||
|
||||
|
|
|
@ -36,11 +36,11 @@ describe('Test video imports API validator', function () {
|
|||
|
||||
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
|
||||
}
|
||||
})
|
||||
|
@ -162,10 +162,10 @@ describe('Test video imports API validator', 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 }
|
||||
|
@ -256,7 +256,7 @@ describe('Test video imports API validator', function () {
|
|||
})
|
||||
|
||||
it('Should forbid to import http videos', async function () {
|
||||
await server.configCommand.updateCustomSubConfig({
|
||||
await server.config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
import: {
|
||||
videos: {
|
||||
|
@ -281,7 +281,7 @@ describe('Test video imports API validator', function () {
|
|||
})
|
||||
|
||||
it('Should forbid to import torrent videos', async function () {
|
||||
await server.configCommand.updateCustomSubConfig({
|
||||
await server.config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
import: {
|
||||
videos: {
|
||||
|
|
|
@ -47,10 +47,10 @@ describe('Test video playlists API validator', function () {
|
|||
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({
|
||||
|
@ -68,7 +68,7 @@ describe('Test video playlists API validator', function () {
|
|||
attributes: {
|
||||
displayName: 'super playlist',
|
||||
privacy: VideoPlaylistPrivacy.PUBLIC,
|
||||
videoChannelId: server.videoChannel.id
|
||||
videoChannelId: server.store.channel.id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ describe('Test video playlists API validator', function () {
|
|||
const playlist = await command.create({
|
||||
attributes: {
|
||||
displayName: 'super playlist',
|
||||
videoChannelId: server.videoChannel.id,
|
||||
videoChannelId: server.store.channel.id,
|
||||
privacy: VideoPlaylistPrivacy.UNLISTED
|
||||
}
|
||||
})
|
||||
|
@ -200,7 +200,7 @@ describe('Test video playlists API validator', function () {
|
|||
displayName: 'display name',
|
||||
privacy: VideoPlaylistPrivacy.UNLISTED,
|
||||
thumbnailfile: 'thumbnail.jpg',
|
||||
videoChannelId: server.videoChannel.id,
|
||||
videoChannelId: server.store.channel.id,
|
||||
|
||||
...attributes
|
||||
},
|
||||
|
@ -485,8 +485,8 @@ describe('Test video playlists API validator', function () {
|
|||
}
|
||||
|
||||
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 } })
|
||||
|
|
|
@ -49,13 +49,13 @@ describe('Test video filters validators', function () {
|
|||
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 () {
|
||||
|
|
|
@ -29,7 +29,7 @@ describe('Test videos history API validator', function () {
|
|||
|
||||
await setAccessTokensToServers([ server ])
|
||||
|
||||
const { uuid } = await server.videosCommand.upload()
|
||||
const { uuid } = await server.videos.upload()
|
||||
watchingPath = '/api/v1/videos/' + uuid + '/watching'
|
||||
})
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@ describe('Test videos overview', function () {
|
|||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -44,11 +44,11 @@ describe('Test videos API validator', function () {
|
|||
|
||||
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
|
||||
|
@ -274,10 +274,10 @@ describe('Test videos API validator', function () {
|
|||
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 }
|
||||
|
@ -484,7 +484,7 @@ describe('Test videos API validator', function () {
|
|||
}
|
||||
|
||||
before(async function () {
|
||||
const { data } = await server.videosCommand.list()
|
||||
const { data } = await server.videos.list()
|
||||
video = data[0]
|
||||
})
|
||||
|
||||
|
@ -710,15 +710,15 @@ describe('Test videos API validator', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -734,7 +734,7 @@ describe('Test videos API validator', function () {
|
|||
})
|
||||
|
||||
it('Should succeed with the correct parameters', async function () {
|
||||
await server.videosCommand.get({ id: video.shortUUID })
|
||||
await server.videos.get({ id: video.shortUUID })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -742,7 +742,7 @@ describe('Test videos API validator', function () {
|
|||
let videoId: number
|
||||
|
||||
before(async function () {
|
||||
const { data } = await server.videosCommand.list()
|
||||
const { data } = await server.videos.list()
|
||||
videoId = data[0].id
|
||||
})
|
||||
|
||||
|
@ -797,21 +797,21 @@ describe('Test videos API validator', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -827,7 +827,7 @@ describe('Test videos API validator', function () {
|
|||
})
|
||||
|
||||
it('Should succeed with the correct parameters', async function () {
|
||||
await server.videosCommand.remove({ id: video.uuid })
|
||||
await server.videos.remove({ id: video.uuid })
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ describe('Test live constraints', function () {
|
|||
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)
|
||||
}
|
||||
|
@ -48,12 +48,12 @@ describe('Test live constraints', function () {
|
|||
|
||||
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
|
||||
|
@ -69,7 +69,7 @@ describe('Test live constraints', function () {
|
|||
await setAccessTokensToServers(servers)
|
||||
await setDefaultVideoChannel(servers)
|
||||
|
||||
await servers[0].configCommand.updateCustomSubConfig({
|
||||
await servers[0].config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
live: {
|
||||
enabled: true,
|
||||
|
@ -82,7 +82,7 @@ describe('Test live constraints', function () {
|
|||
})
|
||||
|
||||
{
|
||||
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
|
||||
|
@ -98,7 +98,7 @@ describe('Test live constraints', function () {
|
|||
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 () {
|
||||
|
@ -108,7 +108,7 @@ describe('Test live constraints', 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)
|
||||
|
@ -125,7 +125,7 @@ describe('Test live constraints', function () {
|
|||
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)
|
||||
|
@ -142,13 +142,13 @@ describe('Test live constraints', function () {
|
|||
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,
|
||||
|
@ -163,7 +163,7 @@ describe('Test live constraints', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
|
|
@ -24,20 +24,20 @@ describe('Permanent live', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ describe('Permanent live', function () {
|
|||
// 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,
|
||||
|
@ -75,14 +75,14 @@ describe('Permanent live', function () {
|
|||
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
|
||||
}
|
||||
})
|
||||
|
@ -92,7 +92,7 @@ describe('Permanent live', function () {
|
|||
|
||||
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)
|
||||
|
@ -101,16 +101,16 @@ describe('Permanent live', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -122,7 +122,7 @@ describe('Permanent live', function () {
|
|||
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)
|
||||
}
|
||||
})
|
||||
|
@ -136,7 +136,7 @@ describe('Permanent live', function () {
|
|||
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,
|
||||
|
@ -150,15 +150,15 @@ describe('Permanent live', function () {
|
|||
}
|
||||
})
|
||||
|
||||
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)
|
||||
|
||||
|
|
|
@ -30,19 +30,19 @@ describe('Save replay setting', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -50,32 +50,32 @@ describe('Save replay setting', function () {
|
|||
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 })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ describe('Save replay setting', function () {
|
|||
// 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,
|
||||
|
@ -126,7 +126,7 @@ describe('Save replay setting', function () {
|
|||
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)
|
||||
|
||||
|
@ -142,7 +142,7 @@ describe('Save replay setting', function () {
|
|||
await stopFfmpeg(ffmpegCommand)
|
||||
|
||||
for (const server of servers) {
|
||||
await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID })
|
||||
await server.live.waitUntilEnded({ videoId: liveVideoUUID })
|
||||
}
|
||||
await waitJobs(servers)
|
||||
|
||||
|
@ -159,7 +159,7 @@ describe('Save replay setting', function () {
|
|||
|
||||
liveVideoUUID = await createLiveWrapper(false)
|
||||
|
||||
ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
||||
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
||||
|
||||
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
|
||||
|
||||
|
@ -167,7 +167,7 @@ describe('Save replay setting', function () {
|
|||
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)
|
||||
])
|
||||
|
||||
|
@ -175,8 +175,8 @@ describe('Save replay setting', function () {
|
|||
|
||||
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)
|
||||
|
@ -188,7 +188,7 @@ describe('Save replay setting', function () {
|
|||
|
||||
liveVideoUUID = await createLiveWrapper(false)
|
||||
|
||||
ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
||||
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
||||
|
||||
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
|
||||
|
||||
|
@ -197,7 +197,7 @@ describe('Save replay setting', function () {
|
|||
|
||||
await Promise.all([
|
||||
testFfmpegStreamError(ffmpegCommand, true),
|
||||
servers[0].videosCommand.remove({ id: liveVideoUUID })
|
||||
servers[0].videos.remove({ id: liveVideoUUID })
|
||||
])
|
||||
|
||||
await wait(5000)
|
||||
|
@ -224,7 +224,7 @@ describe('Save replay setting', function () {
|
|||
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)
|
||||
|
@ -249,11 +249,11 @@ describe('Save replay setting', function () {
|
|||
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
|
||||
}
|
||||
|
@ -268,14 +268,14 @@ describe('Save replay setting', function () {
|
|||
|
||||
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)
|
||||
])
|
||||
|
||||
|
@ -283,8 +283,8 @@ describe('Save replay setting', function () {
|
|||
|
||||
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)
|
||||
|
@ -296,14 +296,14 @@ describe('Save replay setting', function () {
|
|||
|
||||
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)
|
||||
])
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ describe('Test live', function () {
|
|||
await setAccessTokensToServers(servers)
|
||||
await setDefaultVideoChannel(servers)
|
||||
|
||||
await servers[0].configCommand.updateCustomSubConfig({
|
||||
await servers[0].config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
live: {
|
||||
enabled: true,
|
||||
|
@ -51,11 +51,11 @@ describe('Test live', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -69,22 +69,22 @@ describe('Test live', function () {
|
|||
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)
|
||||
|
@ -97,7 +97,7 @@ describe('Test live', function () {
|
|||
await stopFfmpeg(ffmpegCommand)
|
||||
|
||||
for (const server of servers) {
|
||||
await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID })
|
||||
await server.live.waitUntilEnded({ videoId: liveVideoUUID })
|
||||
}
|
||||
await waitJobs(servers)
|
||||
|
||||
|
@ -117,22 +117,22 @@ describe('Test live', function () {
|
|||
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)
|
||||
|
@ -140,8 +140,8 @@ describe('Test live', function () {
|
|||
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)
|
||||
|
@ -161,13 +161,13 @@ describe('Test live', function () {
|
|||
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)
|
||||
|
|
|
@ -31,7 +31,7 @@ describe('Test live', function () {
|
|||
await setAccessTokensToServers(servers)
|
||||
await setDefaultVideoChannel(servers)
|
||||
|
||||
await servers[0].configCommand.updateCustomSubConfig({
|
||||
await servers[0].config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
live: {
|
||||
enabled: true,
|
||||
|
@ -53,7 +53,7 @@ describe('Test live', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -63,14 +63,14 @@ describe('Test live', function () {
|
|||
|
||||
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)
|
||||
})
|
||||
|
@ -82,8 +82,8 @@ describe('Test live', function () {
|
|||
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)
|
||||
|
||||
|
@ -104,9 +104,9 @@ describe('Test live', function () {
|
|||
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)
|
||||
|
|
|
@ -44,7 +44,7 @@ describe('Test live', function () {
|
|||
await setAccessTokensToServers(servers)
|
||||
await setDefaultVideoChannel(servers)
|
||||
|
||||
await servers[0].configCommand.updateCustomSubConfig({
|
||||
await servers[0].config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
live: {
|
||||
enabled: true,
|
||||
|
@ -59,7 +59,7 @@ describe('Test live', function () {
|
|||
// 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 () {
|
||||
|
@ -74,7 +74,7 @@ describe('Test live', 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',
|
||||
|
@ -93,7 +93,7 @@ describe('Test live', function () {
|
|||
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)
|
||||
|
@ -101,8 +101,8 @@ describe('Test live', function () {
|
|||
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
|
||||
|
||||
|
@ -117,7 +117,7 @@ describe('Test live', function () {
|
|||
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')
|
||||
|
@ -136,7 +136,7 @@ describe('Test live', function () {
|
|||
|
||||
const attributes: LiveVideoCreate = {
|
||||
name: 'default live thumbnail',
|
||||
channelId: servers[0].videoChannel.id,
|
||||
channelId: servers[0].store.channel.id,
|
||||
privacy: VideoPrivacy.UNLISTED,
|
||||
nsfw: true
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ describe('Test live', function () {
|
|||
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
|
||||
|
||||
|
@ -158,7 +158,7 @@ describe('Test live', function () {
|
|||
|
||||
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)
|
||||
|
@ -178,7 +178,7 @@ describe('Test live', function () {
|
|||
|
||||
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')
|
||||
|
@ -195,14 +195,14 @@ describe('Test live', function () {
|
|||
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 })
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -215,19 +215,19 @@ describe('Test live', function () {
|
|||
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)
|
||||
|
@ -235,7 +235,7 @@ describe('Test live', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -248,22 +248,22 @@ describe('Test live', function () {
|
|||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -278,7 +278,7 @@ describe('Test live', function () {
|
|||
async function createLiveWrapper () {
|
||||
const liveAttributes = {
|
||||
name: 'user live',
|
||||
channelId: servers[0].videoChannel.id,
|
||||
channelId: servers[0].store.channel.id,
|
||||
privacy: VideoPrivacy.PUBLIC,
|
||||
saveReplay: false
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ describe('Test live', function () {
|
|||
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)
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ describe('Test live', function () {
|
|||
|
||||
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)
|
||||
|
@ -332,7 +332,7 @@ describe('Test live', function () {
|
|||
|
||||
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)
|
||||
|
@ -343,7 +343,7 @@ describe('Test live', function () {
|
|||
|
||||
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)
|
||||
|
@ -356,7 +356,7 @@ describe('Test live', function () {
|
|||
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
|
||||
}
|
||||
|
@ -367,10 +367,10 @@ describe('Test live', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -387,7 +387,7 @@ describe('Test live', function () {
|
|||
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`
|
||||
})
|
||||
|
||||
|
@ -406,7 +406,7 @@ describe('Test live', function () {
|
|||
}
|
||||
|
||||
function updateConf (resolutions: number[]) {
|
||||
return servers[0].configCommand.updateCustomSubConfig({
|
||||
return servers[0].config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
live: {
|
||||
enabled: true,
|
||||
|
@ -490,7 +490,7 @@ describe('Test live', function () {
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -515,7 +515,7 @@ describe('Test live', function () {
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -542,7 +542,7 @@ describe('Test live', function () {
|
|||
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
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ describe('Test abuses', function () {
|
|||
// 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 () {
|
||||
|
@ -47,7 +47,7 @@ describe('Test 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 })
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -55,17 +55,17 @@ describe('Test abuses', function () {
|
|||
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 () {
|
||||
|
@ -80,7 +80,7 @@ describe('Test abuses', 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)
|
||||
|
@ -100,7 +100,7 @@ describe('Test abuses', function () {
|
|||
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
|
||||
|
@ -127,7 +127,7 @@ describe('Test abuses', function () {
|
|||
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
|
||||
|
@ -146,7 +146,7 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
|
||||
|
@ -165,7 +165,7 @@ describe('Test abuses', function () {
|
|||
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
|
||||
|
||||
|
@ -200,7 +200,7 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
|
||||
|
@ -211,7 +211,7 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
|
@ -221,7 +221,7 @@ describe('Test abuses', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
|
@ -232,7 +232,7 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
|
@ -242,7 +242,7 @@ describe('Test abuses', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
|
@ -252,7 +252,7 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
|
||||
|
@ -272,15 +272,15 @@ describe('Test abuses', function () {
|
|||
|
||||
// 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
|
||||
|
@ -288,7 +288,7 @@ describe('Test abuses', function () {
|
|||
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()
|
||||
|
@ -301,7 +301,7 @@ describe('Test abuses', function () {
|
|||
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")
|
||||
}
|
||||
})
|
||||
|
@ -312,7 +312,7 @@ describe('Test abuses', function () {
|
|||
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,
|
||||
|
@ -391,10 +391,10 @@ describe('Test abuses', function () {
|
|||
|
||||
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]
|
||||
}
|
||||
|
@ -402,11 +402,11 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -414,7 +414,7 @@ describe('Test abuses', function () {
|
|||
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 })
|
||||
|
@ -424,7 +424,7 @@ describe('Test abuses', function () {
|
|||
|
||||
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)
|
||||
|
@ -442,8 +442,8 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
|
@ -459,7 +459,7 @@ describe('Test abuses', function () {
|
|||
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 })
|
||||
|
@ -468,7 +468,7 @@ describe('Test abuses', function () {
|
|||
})
|
||||
|
||||
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' })
|
||||
|
@ -493,7 +493,7 @@ describe('Test abuses', function () {
|
|||
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')
|
||||
|
@ -527,9 +527,9 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
|
||||
|
@ -592,16 +592,16 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -702,7 +702,7 @@ describe('Test abuses', function () {
|
|||
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)
|
||||
|
||||
|
@ -759,11 +759,11 @@ describe('Test abuses', function () {
|
|||
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' })
|
||||
})
|
||||
|
||||
|
@ -830,9 +830,9 @@ describe('Test abuses', function () {
|
|||
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
|
||||
})
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import { UserNotificationType } from '@shared/models'
|
|||
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) {
|
||||
|
@ -26,24 +26,24 @@ describe('Test blocklist', function () {
|
|||
|
||||
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'
|
||||
|
@ -52,8 +52,8 @@ describe('Test blocklist', function () {
|
|||
|
||||
{
|
||||
|
||||
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)
|
||||
|
@ -67,29 +67,29 @@ describe('Test blocklist', function () {
|
|||
|
||||
{
|
||||
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])
|
||||
|
@ -111,7 +111,7 @@ describe('Test blocklist', function () {
|
|||
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)
|
||||
})
|
||||
|
||||
|
@ -124,7 +124,7 @@ describe('Test blocklist', function () {
|
|||
|
||||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -144,7 +144,7 @@ describe('Test blocklist', function () {
|
|||
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)
|
||||
})
|
||||
|
||||
|
@ -157,7 +157,7 @@ describe('Test blocklist', function () {
|
|||
|
||||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -184,7 +184,7 @@ describe('Test blocklist', function () {
|
|||
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)
|
||||
})
|
||||
|
||||
|
@ -192,7 +192,7 @@ describe('Test blocklist', function () {
|
|||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -219,7 +219,7 @@ describe('Test blocklist', function () {
|
|||
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)
|
||||
})
|
||||
|
||||
|
|
|
@ -18,24 +18,24 @@ const expect = chai.expect
|
|||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -45,13 +45,13 @@ async function checkCommentNotification (
|
|||
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)
|
||||
|
@ -80,44 +80,44 @@ describe('Test blocklist', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ describe('Test blocklist', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
||||
|
@ -172,7 +172,7 @@ describe('Test blocklist', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
||||
|
@ -289,12 +289,12 @@ describe('Test blocklist', function () {
|
|||
|
||||
// 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)
|
||||
|
@ -306,7 +306,7 @@ describe('Test blocklist', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -315,7 +315,7 @@ describe('Test blocklist', function () {
|
|||
|
||||
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) {
|
||||
|
@ -327,7 +327,7 @@ describe('Test blocklist', function () {
|
|||
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)
|
||||
|
@ -378,7 +378,7 @@ describe('Test blocklist', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
||||
|
@ -488,7 +488,7 @@ describe('Test blocklist', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -503,7 +503,7 @@ describe('Test blocklist', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -581,7 +581,7 @@ describe('Test blocklist', function () {
|
|||
|
||||
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')
|
||||
|
@ -639,8 +639,8 @@ describe('Test blocklist', function () {
|
|||
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) {
|
||||
|
@ -688,13 +688,13 @@ describe('Test blocklist', function () {
|
|||
|
||||
{
|
||||
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()
|
||||
})
|
||||
|
@ -749,13 +749,13 @@ describe('Test blocklist', function () {
|
|||
|
||||
{
|
||||
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()
|
||||
})
|
||||
|
|
|
@ -25,10 +25,10 @@ describe('Test video blacklist', function () {
|
|||
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' })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,13 +45,13 @@ describe('Test video blacklist', function () {
|
|||
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])
|
||||
|
@ -61,7 +61,7 @@ describe('Test video blacklist', function () {
|
|||
|
||||
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')
|
||||
|
@ -69,7 +69,7 @@ describe('Test video blacklist', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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')
|
||||
|
@ -79,7 +79,7 @@ describe('Test video blacklist', function () {
|
|||
|
||||
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')
|
||||
|
@ -87,7 +87,7 @@ describe('Test video blacklist', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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')
|
||||
|
@ -181,7 +181,7 @@ describe('Test video blacklist', function () {
|
|||
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)
|
||||
|
@ -198,7 +198,7 @@ describe('Test video blacklist', function () {
|
|||
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)
|
||||
|
@ -215,7 +215,7 @@ describe('Test video blacklist', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -244,11 +244,11 @@ describe('Test video blacklist', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -263,12 +263,12 @@ describe('Test video blacklist', function () {
|
|||
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
|
||||
}
|
||||
})
|
||||
|
@ -281,7 +281,7 @@ describe('Test video blacklist', function () {
|
|||
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
|
||||
}
|
||||
})
|
||||
|
@ -289,12 +289,12 @@ describe('Test video blacklist', function () {
|
|||
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
|
||||
}
|
||||
})
|
||||
|
@ -318,7 +318,7 @@ describe('Test video blacklist', function () {
|
|||
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
|
||||
}
|
||||
})
|
||||
|
@ -348,36 +348,36 @@ describe('Test video blacklist', function () {
|
|||
|
||||
{
|
||||
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)
|
||||
|
@ -392,7 +392,7 @@ describe('Test video blacklist', function () {
|
|||
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)
|
||||
|
@ -405,7 +405,7 @@ describe('Test video blacklist', function () {
|
|||
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)
|
||||
|
@ -413,7 +413,7 @@ describe('Test video blacklist', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
|
|
@ -58,8 +58,8 @@ describe('Test admin notifications', function () {
|
|||
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 () {
|
||||
|
@ -118,8 +118,8 @@ describe('Test admin notifications', 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')
|
||||
|
@ -140,8 +140,8 @@ describe('Test admin notifications', function () {
|
|||
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)
|
||||
|
|
|
@ -52,9 +52,9 @@ describe('Test comments notifications', function () {
|
|||
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)
|
||||
|
@ -64,9 +64,9 @@ describe('Test comments notifications', function () {
|
|||
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)
|
||||
|
@ -76,25 +76,25 @@ describe('Test comments notifications', function () {
|
|||
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)
|
||||
|
@ -104,15 +104,15 @@ describe('Test comments notifications', function () {
|
|||
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
|
||||
|
@ -122,11 +122,11 @@ describe('Test comments notifications', function () {
|
|||
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')
|
||||
|
@ -135,22 +135,22 @@ describe('Test comments notifications', function () {
|
|||
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
|
||||
|
@ -161,9 +161,9 @@ describe('Test comments notifications', function () {
|
|||
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)
|
||||
|
||||
|
@ -183,16 +183,16 @@ describe('Test comments notifications', function () {
|
|||
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')
|
||||
|
@ -201,9 +201,9 @@ describe('Test comments notifications', function () {
|
|||
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')
|
||||
|
@ -212,25 +212,25 @@ describe('Test comments notifications', function () {
|
|||
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')
|
||||
|
@ -239,14 +239,14 @@ describe('Test comments notifications', function () {
|
|||
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')
|
||||
|
@ -255,27 +255,27 @@ describe('Test comments notifications', function () {
|
|||
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
|
||||
|
@ -286,11 +286,11 @@ describe('Test comments notifications', function () {
|
|||
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)
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -74,12 +74,12 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -89,8 +89,8 @@ describe('Test moderation notifications', function () {
|
|||
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()
|
||||
|
@ -98,7 +98,7 @@ describe('Test moderation notifications', function () {
|
|||
|
||||
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')
|
||||
|
@ -108,9 +108,9 @@ describe('Test moderation notifications', function () {
|
|||
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()
|
||||
|
@ -118,9 +118,9 @@ describe('Test moderation notifications', function () {
|
|||
|
||||
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')
|
||||
|
@ -130,10 +130,10 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -143,13 +143,13 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -169,16 +169,16 @@ describe('Test moderation notifications', function () {
|
|||
}
|
||||
|
||||
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')
|
||||
|
@ -187,7 +187,7 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -216,15 +216,15 @@ describe('Test moderation notifications', function () {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
})
|
||||
|
@ -233,7 +233,7 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -243,7 +243,7 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -253,7 +253,7 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -263,7 +263,7 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -286,9 +286,9 @@ describe('Test moderation notifications', function () {
|
|||
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')
|
||||
|
@ -298,12 +298,12 @@ describe('Test moderation notifications', function () {
|
|||
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)
|
||||
|
@ -326,7 +326,7 @@ describe('Test moderation notifications', function () {
|
|||
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)
|
||||
|
||||
|
@ -368,7 +368,7 @@ describe('Test moderation notifications', function () {
|
|||
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)
|
||||
|
||||
|
@ -381,7 +381,7 @@ describe('Test moderation notifications', function () {
|
|||
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 = {
|
||||
|
@ -391,9 +391,9 @@ describe('Test moderation notifications', function () {
|
|||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
||||
|
@ -405,16 +405,16 @@ describe('Test moderation notifications', function () {
|
|||
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)
|
||||
|
@ -424,8 +424,8 @@ describe('Test moderation notifications', function () {
|
|||
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] })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -460,7 +460,7 @@ describe('Test moderation notifications', function () {
|
|||
token: userAccessToken
|
||||
}
|
||||
|
||||
currentCustomConfig = await servers[0].configCommand.getCustomConfig()
|
||||
currentCustomConfig = await servers[0].config.getCustomConfig()
|
||||
|
||||
const autoBlacklistTestsCustomConfig = {
|
||||
...currentCustomConfig,
|
||||
|
@ -476,10 +476,10 @@ describe('Test moderation notifications', function () {
|
|||
|
||||
// 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 })
|
||||
|
||||
})
|
||||
|
||||
|
@ -487,7 +487,7 @@ describe('Test moderation notifications', function () {
|
|||
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)
|
||||
|
@ -509,7 +509,7 @@ describe('Test moderation notifications', function () {
|
|||
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)
|
||||
|
||||
|
@ -543,9 +543,9 @@ describe('Test moderation notifications', function () {
|
|||
}
|
||||
}
|
||||
|
||||
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')
|
||||
|
@ -575,7 +575,7 @@ describe('Test moderation notifications', function () {
|
|||
}
|
||||
}
|
||||
|
||||
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')
|
||||
|
@ -589,17 +589,17 @@ describe('Test moderation notifications', function () {
|
|||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ describe('Test notifications API', function () {
|
|||
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 ])
|
||||
|
@ -43,14 +43,14 @@ describe('Test notifications API', function () {
|
|||
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
|
||||
|
@ -61,7 +61,7 @@ describe('Test notifications API', function () {
|
|||
})
|
||||
|
||||
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
|
||||
|
@ -69,7 +69,7 @@ describe('Test notifications API', function () {
|
|||
})
|
||||
|
||||
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
|
||||
|
@ -77,9 +77,9 @@ describe('Test notifications API', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -101,17 +101,17 @@ describe('Test notifications API', function () {
|
|||
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')
|
||||
|
@ -120,17 +120,17 @@ describe('Test notifications API', function () {
|
|||
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 }
|
||||
|
@ -146,17 +146,17 @@ describe('Test notifications API', function () {
|
|||
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 }
|
||||
|
@ -172,7 +172,7 @@ describe('Test notifications API', function () {
|
|||
it('Should have email and web notifications', async function () {
|
||||
this.timeout(20000)
|
||||
|
||||
await server.notificationsCommand.updateMySettings({
|
||||
await server.notifications.updateMySettings({
|
||||
token: userToken,
|
||||
settings: {
|
||||
...getAllNotificationsSettings(),
|
||||
|
@ -181,13 +181,13 @@ describe('Test notifications API', function () {
|
|||
})
|
||||
|
||||
{
|
||||
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')
|
||||
})
|
||||
|
|
|
@ -61,7 +61,7 @@ describe('Test user notifications', function () {
|
|||
|
||||
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)
|
||||
|
@ -71,7 +71,7 @@ describe('Test user notifications', function () {
|
|||
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)
|
||||
|
@ -81,7 +81,7 @@ describe('Test user notifications', function () {
|
|||
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)
|
||||
|
@ -153,7 +153,7 @@ describe('Test user notifications', function () {
|
|||
|
||||
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')
|
||||
|
@ -167,7 +167,7 @@ describe('Test user notifications', function () {
|
|||
|
||||
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')
|
||||
|
@ -179,7 +179,7 @@ describe('Test user notifications', function () {
|
|||
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')
|
||||
})
|
||||
|
@ -190,7 +190,7 @@ describe('Test user notifications', function () {
|
|||
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')
|
||||
|
@ -207,7 +207,7 @@ describe('Test user notifications', function () {
|
|||
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)
|
||||
|
||||
|
@ -242,7 +242,7 @@ describe('Test user notifications', function () {
|
|||
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)
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ describe('Test user notifications', function () {
|
|||
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')
|
||||
|
@ -345,7 +345,7 @@ describe('Test user notifications', function () {
|
|||
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')
|
||||
|
@ -362,7 +362,7 @@ describe('Test user notifications', function () {
|
|||
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')
|
||||
|
@ -382,16 +382,16 @@ describe('Test user notifications', function () {
|
|||
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 }
|
||||
|
@ -401,23 +401,23 @@ describe('Test user notifications', function () {
|
|||
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
|
||||
|
|
|
@ -53,15 +53,15 @@ describe('Test manage videos redundancy', function () {
|
|||
// 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
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ describe('Test manage videos redundancy', function () {
|
|||
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' })
|
||||
|
@ -203,14 +203,14 @@ describe('Test manage videos redundancy', function () {
|
|||
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)
|
||||
|
||||
{
|
||||
|
|
|
@ -36,21 +36,21 @@ describe('Test redundancy constraints', function () {
|
|||
|
||||
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
|
||||
}
|
||||
|
@ -78,14 +78,14 @@ describe('Test redundancy constraints', function () {
|
|||
// 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)
|
||||
})
|
||||
|
@ -94,7 +94,7 @@ describe('Test redundancy constraints', function () {
|
|||
this.timeout(120000)
|
||||
|
||||
await waitJobs(servers)
|
||||
await remoteServer.serversCommand.waitUntilLog('Duplicated ', 5)
|
||||
await remoteServer.servers.waitUntilLog('Duplicated ', 5)
|
||||
await waitJobs(servers)
|
||||
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ describe('Test redundancy constraints', function () {
|
|||
|
||||
await uploadWrapper('video 2 server 2')
|
||||
|
||||
await remoteServer.serversCommand.waitUntilLog('Duplicated ', 10)
|
||||
await remoteServer.servers.waitUntilLog('Duplicated ', 10)
|
||||
await waitJobs(servers)
|
||||
|
||||
{
|
||||
|
@ -152,7 +152,7 @@ describe('Test redundancy constraints', function () {
|
|||
|
||||
await uploadWrapper('video 3 server 2')
|
||||
|
||||
await remoteServer.serversCommand.waitUntilLog('Duplicated ', 15)
|
||||
await remoteServer.servers.waitUntilLog('Duplicated ', 15)
|
||||
await waitJobs(servers)
|
||||
|
||||
{
|
||||
|
@ -169,11 +169,11 @@ describe('Test redundancy constraints', function () {
|
|||
it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () {
|
||||
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)
|
||||
|
||||
{
|
||||
|
|
|
@ -78,11 +78,11 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add
|
|||
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)
|
||||
|
@ -106,7 +106,7 @@ async function check1WebSeed (videoUUID?: string) {
|
|||
|
||||
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)
|
||||
|
@ -123,7 +123,7 @@ async function check2Webseeds (videoUUID?: string) {
|
|||
]
|
||||
|
||||
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)
|
||||
|
@ -163,7 +163,7 @@ async function check0PlaylistRedundancies (videoUUID?: string) {
|
|||
|
||||
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)
|
||||
|
@ -175,7 +175,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
|
|||
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)
|
||||
|
@ -188,7 +188,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
|
|||
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 ]) {
|
||||
|
@ -221,7 +221,7 @@ async function checkStatsGlobal (strategy: VideoRedundancyStrategyWithManual) {
|
|||
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]
|
||||
|
@ -248,7 +248,7 @@ async function checkStatsWithoutRedundancy (strategy: VideoRedundancyStrategyWit
|
|||
}
|
||||
|
||||
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}`)
|
||||
|
@ -257,7 +257,7 @@ async function findServerFollows () {
|
|||
}
|
||||
|
||||
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()
|
||||
|
||||
|
@ -269,7 +269,7 @@ async function enableRedundancyOnServer1 () {
|
|||
}
|
||||
|
||||
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()
|
||||
|
||||
|
@ -305,7 +305,7 @@ describe('Test videos redundancy', 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()
|
||||
|
@ -355,7 +355,7 @@ describe('Test videos redundancy', 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()
|
||||
|
@ -366,7 +366,7 @@ describe('Test videos redundancy', function () {
|
|||
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)
|
||||
|
@ -416,8 +416,8 @@ describe('Test videos redundancy', function () {
|
|||
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)
|
||||
|
@ -427,7 +427,7 @@ describe('Test videos redundancy', 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()
|
||||
|
@ -438,7 +438,7 @@ describe('Test videos redundancy', function () {
|
|||
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)
|
||||
|
||||
|
@ -484,14 +484,14 @@ describe('Test videos redundancy', function () {
|
|||
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()
|
||||
|
@ -501,7 +501,7 @@ describe('Test videos redundancy', function () {
|
|||
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)
|
||||
|
||||
|
@ -529,14 +529,14 @@ describe('Test videos redundancy', function () {
|
|||
})
|
||||
|
||||
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()
|
||||
|
@ -547,7 +547,7 @@ describe('Test videos redundancy', function () {
|
|||
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)
|
||||
|
@ -555,7 +555,7 @@ describe('Test videos redundancy', function () {
|
|||
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)
|
||||
|
@ -577,7 +577,7 @@ describe('Test videos redundancy', function () {
|
|||
|
||||
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)
|
||||
|
@ -587,7 +587,7 @@ describe('Test videos redundancy', function () {
|
|||
|
||||
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)
|
||||
|
@ -645,20 +645,20 @@ describe('Test videos redundancy', function () {
|
|||
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 () {
|
||||
|
|
|
@ -30,34 +30,34 @@ describe('Test ActivityPub video channels search', 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 () {
|
||||
|
@ -134,7 +134,7 @@ describe('Test ActivityPub video channels search', 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')
|
||||
|
@ -147,7 +147,7 @@ describe('Test ActivityPub video channels search', function () {
|
|||
|
||||
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
|
||||
})
|
||||
|
@ -156,7 +156,7 @@ describe('Test ActivityPub video channels search', function () {
|
|||
})
|
||||
|
||||
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
|
||||
})
|
||||
|
||||
|
@ -167,12 +167,12 @@ describe('Test ActivityPub video channels search', function () {
|
|||
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
|
||||
|
@ -193,8 +193,8 @@ describe('Test ActivityPub video channels search', function () {
|
|||
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)
|
||||
|
||||
|
@ -207,7 +207,7 @@ describe('Test ActivityPub video channels search', function () {
|
|||
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')
|
||||
|
@ -217,7 +217,7 @@ describe('Test ActivityPub video channels search', function () {
|
|||
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
|
||||
|
|
|
@ -33,40 +33,40 @@ describe('Test ActivityPub playlists search', function () {
|
|||
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 () {
|
||||
|
@ -139,7 +139,7 @@ describe('Test ActivityPub playlists search', 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')
|
||||
|
@ -148,7 +148,7 @@ describe('Test ActivityPub playlists search', function () {
|
|||
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
|
||||
|
@ -172,7 +172,7 @@ describe('Test ActivityPub playlists search', function () {
|
|||
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
|
||||
|
|
|
@ -30,18 +30,18 @@ describe('Test ActivityPub videos search', function () {
|
|||
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 () {
|
||||
|
@ -105,7 +105,7 @@ describe('Test ActivityPub videos search', 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')
|
||||
|
@ -118,7 +118,7 @@ describe('Test ActivityPub videos search', function () {
|
|||
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 = {
|
||||
|
@ -127,7 +127,7 @@ describe('Test ActivityPub videos search', function () {
|
|||
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
|
||||
|
@ -153,7 +153,7 @@ describe('Test ActivityPub videos search', function () {
|
|||
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
|
||||
|
|
|
@ -19,15 +19,15 @@ describe('Test channels search', function () {
|
|||
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 () {
|
||||
|
|
|
@ -20,9 +20,9 @@ describe('Test videos search', 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 () {
|
||||
|
@ -30,7 +30,7 @@ describe('Test videos search', 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: {
|
||||
|
@ -57,7 +57,7 @@ describe('Test videos search', function () {
|
|||
})
|
||||
|
||||
it('Should make an index videos search by default', async function () {
|
||||
await server.configCommand.updateCustomSubConfig({
|
||||
await server.config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
search: {
|
||||
searchIndex: {
|
||||
|
@ -79,7 +79,7 @@ describe('Test videos search', function () {
|
|||
})
|
||||
|
||||
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: {
|
||||
|
@ -213,7 +213,7 @@ describe('Test videos search', function () {
|
|||
let nsfwUUID: string
|
||||
|
||||
{
|
||||
await server.configCommand.updateCustomSubConfig({
|
||||
await server.config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
instance: { defaultNSFWPolicy: 'display' }
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ describe('Test videos search', function () {
|
|||
}
|
||||
|
||||
{
|
||||
await server.configCommand.updateCustomSubConfig({
|
||||
await server.config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
instance: { defaultNSFWPolicy: 'do_not_list' }
|
||||
}
|
||||
|
|
|
@ -26,40 +26,40 @@ describe('Test playlists search', function () {
|
|||
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 () {
|
||||
|
|
|
@ -40,24 +40,24 @@ describe('Test videos search', 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',
|
||||
|
@ -66,23 +66,23 @@ describe('Test videos search', function () {
|
|||
}
|
||||
|
||||
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 })
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -93,9 +93,9 @@ describe('Test videos search', function () {
|
|||
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' } })
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ describe('Test videos search', function () {
|
|||
licence: 3,
|
||||
language: 'pl'
|
||||
}
|
||||
await server.videosCommand.upload({ attributes: attributes })
|
||||
await server.videos.upload({ attributes: attributes })
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -115,11 +115,11 @@ describe('Test videos search', function () {
|
|||
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' ] } })
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -127,11 +127,11 @@ describe('Test videos search', function () {
|
|||
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 () {
|
||||
|
@ -479,7 +479,7 @@ describe('Test videos search', function () {
|
|||
},
|
||||
live: { enabled: true }
|
||||
}
|
||||
await server.configCommand.updateCustomSubConfig({ newConfig })
|
||||
await server.config.updateCustomSubConfig({ newConfig })
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -490,9 +490,9 @@ describe('Test videos search', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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 })
|
||||
|
|
|
@ -16,7 +16,7 @@ const expect = chai.expect
|
|||
|
||||
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
|
||||
|
@ -24,7 +24,7 @@ async function checkFollow (follower: ServerInfo, following: ServerInfo, exists:
|
|||
}
|
||||
|
||||
{
|
||||
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
|
||||
|
@ -33,15 +33,15 @@ async function checkFollow (follower: ServerInfo, following: ServerInfo, exists:
|
|||
}
|
||||
|
||||
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 */
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ describe('Test auto follows', function () {
|
|||
}
|
||||
}
|
||||
}
|
||||
await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
|
||||
await servers[1].config.updateCustomSubConfig({ newConfig: config })
|
||||
|
||||
await server1Follows2(servers)
|
||||
|
||||
|
@ -111,14 +111,14 @@ describe('Test auto follows', function () {
|
|||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
@ -128,7 +128,7 @@ describe('Test auto follows', function () {
|
|||
|
||||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -165,7 +165,7 @@ describe('Test auto follows', function () {
|
|||
}
|
||||
}
|
||||
}
|
||||
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
|
||||
await servers[0].config.updateCustomSubConfig({ newConfig: config })
|
||||
|
||||
await wait(5000)
|
||||
await waitJobs(servers)
|
||||
|
|
|
@ -34,23 +34,23 @@ describe('Test bulk actions', function () {
|
|||
|
||||
{
|
||||
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])
|
||||
|
@ -61,11 +61,11 @@ describe('Test bulk actions', function () {
|
|||
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
|
||||
|
@ -73,11 +73,11 @@ describe('Test bulk actions', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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) {
|
||||
|
@ -92,30 +92,30 @@ describe('Test bulk actions', function () {
|
|||
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 })
|
||||
}
|
||||
}
|
||||
|
@ -137,10 +137,10 @@ describe('Test bulk actions', function () {
|
|||
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
|
||||
|
@ -168,7 +168,7 @@ describe('Test bulk actions', function () {
|
|||
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,
|
||||
|
|
|
@ -214,7 +214,7 @@ describe('Test config', function () {
|
|||
})
|
||||
|
||||
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
|
||||
})
|
||||
|
@ -223,32 +223,32 @@ describe('Test config', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -425,16 +425,16 @@ describe('Test config', function () {
|
|||
}
|
||||
}
|
||||
}
|
||||
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')
|
||||
|
@ -447,8 +447,8 @@ describe('Test config', function () {
|
|||
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 () {
|
||||
|
@ -458,13 +458,13 @@ describe('Test config', 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')
|
||||
|
@ -486,9 +486,9 @@ describe('Test config', function () {
|
|||
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)
|
||||
})
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('Test contact form', function () {
|
|||
server = await flushAndRunServer(1, overrideConfig)
|
||||
await setAccessTokensToServers([ server ])
|
||||
|
||||
command = server.contactFormCommand
|
||||
command = server.contactForm
|
||||
})
|
||||
|
||||
it('Should send a contact form', async function () {
|
||||
|
|
|
@ -43,15 +43,15 @@ describe('Test emails', 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
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ describe('Test emails', function () {
|
|||
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
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ describe('Test emails', function () {
|
|||
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)
|
||||
|
@ -96,7 +96,7 @@ describe('Test emails', function () {
|
|||
})
|
||||
|
||||
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',
|
||||
|
@ -105,11 +105,11 @@ describe('Test emails', function () {
|
|||
})
|
||||
|
||||
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',
|
||||
|
@ -120,7 +120,7 @@ describe('Test emails', function () {
|
|||
it('Should login with this new password', async function () {
|
||||
user.password = 'super_password2'
|
||||
|
||||
await server.loginCommand.getAccessToken(user)
|
||||
await server.login.getAccessToken(user)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -129,7 +129,7 @@ describe('Test emails', function () {
|
|||
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)
|
||||
|
@ -155,7 +155,7 @@ describe('Test emails', function () {
|
|||
})
|
||||
|
||||
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',
|
||||
|
@ -164,7 +164,7 @@ describe('Test emails', function () {
|
|||
})
|
||||
|
||||
it('Should reset the password', async function () {
|
||||
await server.usersCommand.resetPassword({
|
||||
await server.users.resetPassword({
|
||||
userId: userId2,
|
||||
verificationString: verificationString2,
|
||||
password: 'newly_created_password'
|
||||
|
@ -172,7 +172,7 @@ describe('Test emails', function () {
|
|||
})
|
||||
|
||||
it('Should login with this new password', async function () {
|
||||
await server.loginCommand.getAccessToken({
|
||||
await server.login.getAccessToken({
|
||||
username: 'create_password',
|
||||
password: 'newly_created_password'
|
||||
})
|
||||
|
@ -184,7 +184,7 @@ describe('Test emails', function () {
|
|||
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)
|
||||
|
@ -205,7 +205,7 @@ describe('Test emails', function () {
|
|||
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)
|
||||
|
@ -223,7 +223,7 @@ describe('Test emails', function () {
|
|||
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)
|
||||
|
@ -243,7 +243,7 @@ describe('Test emails', function () {
|
|||
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)
|
||||
|
@ -261,7 +261,7 @@ describe('Test emails', function () {
|
|||
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)
|
||||
|
@ -286,7 +286,7 @@ describe('Test emails', function () {
|
|||
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)
|
||||
|
@ -312,7 +312,7 @@ describe('Test emails', function () {
|
|||
})
|
||||
|
||||
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,
|
||||
|
@ -321,7 +321,7 @@ describe('Test emails', function () {
|
|||
})
|
||||
|
||||
it('Should verify the email', async function () {
|
||||
await server.usersCommand.verifyEmail({ userId, verificationString })
|
||||
await server.users.verifyEmail({ userId, verificationString })
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@ describe('Test follow constraints', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@ describe('Test follow constraints', function () {
|
|||
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])
|
||||
})
|
||||
|
@ -46,22 +46,22 @@ describe('Test follow constraints', function () {
|
|||
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)
|
||||
|
@ -69,7 +69,7 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
@ -77,7 +77,7 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
@ -86,22 +86,22 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
@ -109,7 +109,7 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
@ -117,7 +117,7 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
@ -130,17 +130,17 @@ describe('Test follow constraints', function () {
|
|||
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'
|
||||
|
@ -156,7 +156,7 @@ describe('Test follow constraints', function () {
|
|||
})
|
||||
|
||||
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
|
||||
})
|
||||
|
@ -166,7 +166,7 @@ describe('Test follow constraints', function () {
|
|||
})
|
||||
|
||||
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
|
||||
})
|
||||
|
@ -177,7 +177,7 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
@ -185,7 +185,7 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
@ -194,22 +194,22 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
@ -217,7 +217,7 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
@ -225,7 +225,7 @@ describe('Test follow constraints', function () {
|
|||
|
||||
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)
|
||||
|
|
|
@ -15,8 +15,8 @@ const expect = chai.expect
|
|||
|
||||
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) {
|
||||
|
@ -32,8 +32,8 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
|
|||
|
||||
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) {
|
||||
|
@ -54,7 +54,7 @@ describe('Test follows moderation', function () {
|
|||
// 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 () {
|
||||
|
@ -93,7 +93,7 @@ describe('Test follows moderation', 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)
|
||||
|
@ -113,7 +113,7 @@ describe('Test follows moderation', 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)
|
||||
|
@ -136,8 +136,8 @@ describe('Test follows moderation', function () {
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('Test follows', function () {
|
|||
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)
|
||||
|
@ -34,7 +34,7 @@ describe('Test follows', function () {
|
|||
|
||||
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
|
||||
|
@ -45,7 +45,7 @@ describe('Test follows', function () {
|
|||
|
||||
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
|
||||
|
@ -141,7 +141,7 @@ describe('Test follows', function () {
|
|||
|
||||
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
|
||||
|
@ -152,7 +152,7 @@ describe('Test follows', function () {
|
|||
|
||||
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
|
||||
|
@ -284,25 +284,25 @@ describe('Test follows', function () {
|
|||
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')
|
||||
}
|
||||
|
@ -322,60 +322,60 @@ describe('Test follows', function () {
|
|||
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'
|
||||
|
@ -404,7 +404,7 @@ describe('Test follows', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -454,7 +454,7 @@ describe('Test follows', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -474,7 +474,7 @@ describe('Test follows', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -502,7 +502,7 @@ describe('Test follows', function () {
|
|||
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
|
||||
|
@ -527,7 +527,7 @@ describe('Test follows', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
||||
|
@ -545,7 +545,7 @@ describe('Test follows', function () {
|
|||
|
||||
await waitJobs(servers)
|
||||
|
||||
const { total } = await servers[0].videosCommand.list()
|
||||
const { total } = await servers[0].videos.list()
|
||||
expect(total).to.equal(1)
|
||||
})
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ describe('Test handle downs', function () {
|
|||
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',
|
||||
|
@ -99,19 +99,19 @@ describe('Test handle downs', function () {
|
|||
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)
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ describe('Test handle downs', function () {
|
|||
|
||||
// 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] ])
|
||||
|
@ -129,12 +129,12 @@ describe('Test handle downs', function () {
|
|||
// 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
|
||||
{
|
||||
|
@ -153,7 +153,7 @@ describe('Test handle downs', function () {
|
|||
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)
|
||||
|
@ -163,7 +163,7 @@ describe('Test handle downs', function () {
|
|||
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,
|
||||
|
@ -179,14 +179,14 @@ describe('Test handle downs', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -195,25 +195,25 @@ describe('Test handle downs', function () {
|
|||
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)
|
||||
})
|
||||
|
||||
|
@ -224,16 +224,16 @@ describe('Test handle downs', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -256,7 +256,7 @@ describe('Test handle downs', function () {
|
|||
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)
|
||||
|
||||
|
@ -286,24 +286,24 @@ describe('Test handle downs', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -318,14 +318,14 @@ describe('Test handle downs', function () {
|
|||
|
||||
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 })
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
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
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ describe('Test instance homepage actions', function () {
|
|||
server = await flushAndRunServer(1)
|
||||
await setAccessTokensToServers([ server ])
|
||||
|
||||
command = server.customPageCommand
|
||||
command = server.customPage
|
||||
})
|
||||
|
||||
it('Should not have a homepage', async function () {
|
||||
|
|
|
@ -31,21 +31,21 @@ describe('Test jobs', 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,
|
||||
|
@ -66,7 +66,7 @@ describe('Test jobs', function () {
|
|||
}
|
||||
|
||||
{
|
||||
const body = await servers[1].jobsCommand.getJobsList({
|
||||
const body = await servers[1].jobs.getJobsList({
|
||||
state: 'completed',
|
||||
start: 0,
|
||||
count: 100,
|
||||
|
@ -82,7 +82,7 @@ describe('Test jobs', function () {
|
|||
})
|
||||
|
||||
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
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('Test logs', function () {
|
|||
server = await flushAndRunServer(1)
|
||||
await setAccessTokensToServers([ server ])
|
||||
|
||||
logsCommand = server.logsCommand
|
||||
logsCommand = server.logs
|
||||
})
|
||||
|
||||
describe('With the standard log file', function () {
|
||||
|
@ -33,12 +33,12 @@ describe('Test logs', 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 })
|
||||
|
@ -51,17 +51,17 @@ describe('Test logs', function () {
|
|||
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 })
|
||||
|
@ -77,7 +77,7 @@ describe('Test logs', function () {
|
|||
|
||||
const now = new Date()
|
||||
|
||||
await server.videosCommand.upload({ attributes: { name: 'video 6' } })
|
||||
await server.videos.upload({ attributes: { name: 'video 6' } })
|
||||
await waitJobs([ server ])
|
||||
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ describe('Test logs', function () {
|
|||
|
||||
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)
|
||||
|
@ -117,7 +117,7 @@ describe('Test logs', function () {
|
|||
|
||||
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)
|
||||
|
@ -130,12 +130,12 @@ describe('Test logs', function () {
|
|||
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 })
|
||||
|
@ -156,17 +156,17 @@ describe('Test logs', function () {
|
|||
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 })
|
||||
|
|
|
@ -33,7 +33,7 @@ describe('Test plugins', function () {
|
|||
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 () {
|
||||
|
@ -97,7 +97,7 @@ describe('Test plugins', 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
|
||||
|
@ -107,20 +107,20 @@ describe('Test plugins', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
})
|
||||
|
||||
|
@ -187,7 +187,7 @@ describe('Test plugins', function () {
|
|||
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 () {
|
||||
|
@ -234,7 +234,7 @@ describe('Test plugins', 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')
|
||||
|
@ -293,7 +293,7 @@ describe('Test plugins', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
||||
|
@ -305,7 +305,7 @@ describe('Test plugins', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
})
|
||||
|
||||
|
|
|
@ -33,59 +33,59 @@ describe('Test application behind a reverse proxy', function () {
|
|||
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)
|
||||
})
|
||||
|
||||
|
@ -93,22 +93,22 @@ describe('Test application behind a reverse proxy', function () {
|
|||
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 () {
|
||||
|
@ -117,10 +117,10 @@ describe('Test application behind a reverse proxy', 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 })
|
||||
|
||||
})
|
||||
|
||||
|
@ -131,13 +131,13 @@ describe('Test application behind a reverse proxy', function () {
|
|||
|
||||
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 () {
|
||||
|
|
|
@ -23,25 +23,25 @@ describe('Test services', 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
|
||||
|
@ -54,7 +54,7 @@ describe('Test services', function () {
|
|||
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>'
|
||||
|
@ -62,7 +62,7 @@ describe('Test services', function () {
|
|||
|
||||
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)
|
||||
|
@ -75,14 +75,14 @@ describe('Test services', function () {
|
|||
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
|
||||
|
@ -98,14 +98,14 @@ describe('Test services', function () {
|
|||
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')
|
||||
|
|
|
@ -32,23 +32,23 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
|
||||
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)
|
||||
|
@ -63,7 +63,7 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -78,7 +78,7 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -94,10 +94,10 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -106,7 +106,7 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
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)
|
||||
|
@ -114,9 +114,9 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
|
@ -128,7 +128,7 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
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)
|
||||
|
@ -140,10 +140,10 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
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)
|
||||
|
@ -151,9 +151,9 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
|
@ -165,12 +165,12 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
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,
|
||||
|
@ -178,7 +178,7 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
}
|
||||
})
|
||||
|
||||
const data = await server.statsCommand.get()
|
||||
const data = await server.stats.get()
|
||||
expect(data.totalLocalPlaylists).to.equal(1)
|
||||
}
|
||||
})
|
||||
|
@ -186,7 +186,7 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
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,
|
||||
|
@ -210,17 +210,17 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
}
|
||||
})
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
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
|
||||
|
@ -237,17 +237,17 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
}
|
||||
})
|
||||
|
||||
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[] = [
|
||||
|
@ -269,7 +269,7 @@ describe('Test stats (excluding redundancy)', function () {
|
|||
|
||||
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)
|
||||
})
|
||||
|
|
|
@ -16,8 +16,8 @@ describe('Test tracker', function () {
|
|||
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)
|
||||
|
|
|
@ -35,26 +35,26 @@ describe('Test users subscriptions', function () {
|
|||
{
|
||||
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)
|
||||
})
|
||||
|
@ -67,14 +67,14 @@ describe('Test users subscriptions', function () {
|
|||
|
||||
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) {
|
||||
|
@ -183,7 +183,7 @@ describe('Test users subscriptions', function () {
|
|||
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)
|
||||
|
||||
|
@ -209,7 +209,7 @@ describe('Test users subscriptions', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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) {
|
||||
|
@ -223,11 +223,11 @@ describe('Test users subscriptions', function () {
|
|||
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' ]
|
||||
|
@ -240,11 +240,11 @@ describe('Test users subscriptions', function () {
|
|||
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) {
|
||||
|
@ -280,7 +280,7 @@ describe('Test users subscriptions', function () {
|
|||
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)
|
||||
|
||||
|
@ -325,7 +325,7 @@ describe('Test users subscriptions', function () {
|
|||
})
|
||||
|
||||
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) {
|
||||
|
@ -356,7 +356,7 @@ describe('Test users subscriptions', 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) {
|
||||
|
|
|
@ -42,20 +42,20 @@ describe('Test users with multiple servers', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -65,9 +65,9 @@ describe('Test users with multiple servers', function () {
|
|||
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)
|
||||
|
@ -76,9 +76,9 @@ describe('Test users with multiple servers', function () {
|
|||
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')
|
||||
|
||||
|
@ -90,9 +90,9 @@ describe('Test users with multiple servers', function () {
|
|||
|
||||
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')
|
||||
|
@ -104,12 +104,12 @@ describe('Test users with multiple servers', function () {
|
|||
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
|
||||
|
||||
|
@ -131,7 +131,7 @@ describe('Test users with multiple servers', function () {
|
|||
|
||||
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')
|
||||
|
@ -143,12 +143,12 @@ describe('Test users with multiple servers', function () {
|
|||
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')
|
||||
|
@ -161,27 +161,27 @@ describe('Test users with multiple servers', function () {
|
|||
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
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ describe('Test users account verification', function () {
|
|||
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,
|
||||
|
@ -52,7 +52,7 @@ describe('Test users account verification', function () {
|
|||
}
|
||||
})
|
||||
|
||||
await server.usersCommand.register(user1)
|
||||
await server.users.register(user1)
|
||||
|
||||
await waitJobs(server)
|
||||
expectedEmailsLength++
|
||||
|
@ -71,22 +71,22 @@ describe('Test users account verification', function () {
|
|||
|
||||
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
|
||||
})
|
||||
|
||||
|
@ -96,7 +96,7 @@ describe('Test users account verification', function () {
|
|||
let updateVerificationString: string
|
||||
|
||||
{
|
||||
await server.usersCommand.updateMe({
|
||||
await server.users.updateMe({
|
||||
token: userAccessToken,
|
||||
email: 'updated@example.com',
|
||||
currentPassword: user1.password
|
||||
|
@ -113,15 +113,15 @@ describe('Test users account verification', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ describe('Test users account verification', function () {
|
|||
|
||||
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,
|
||||
|
@ -139,19 +139,19 @@ describe('Test users account verification', function () {
|
|||
}
|
||||
})
|
||||
|
||||
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,
|
||||
|
@ -161,7 +161,7 @@ describe('Test users account verification', function () {
|
|||
}
|
||||
})
|
||||
|
||||
await server.loginCommand.getAccessToken(user2)
|
||||
await server.login.getAccessToken(user2)
|
||||
})
|
||||
|
||||
after(async function () {
|
||||
|
|
|
@ -42,7 +42,7 @@ describe('Test users', 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 () {
|
||||
|
@ -53,8 +53,8 @@ describe('Test users', 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')
|
||||
|
@ -63,8 +63,8 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -76,8 +76,8 @@ describe('Test users', function () {
|
|||
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')
|
||||
|
@ -86,8 +86,8 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -98,13 +98,13 @@ describe('Test users', function () {
|
|||
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
|
||||
|
@ -114,28 +114,28 @@ describe('Test users', function () {
|
|||
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')
|
||||
|
@ -143,24 +143,24 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -169,12 +169,12 @@ describe('Test users', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
@ -182,27 +182,27 @@ describe('Test users', function () {
|
|||
|
||||
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 () {
|
||||
|
@ -222,64 +222,64 @@ describe('Test users', 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')
|
||||
|
@ -319,20 +319,20 @@ describe('Test users', function () {
|
|||
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)
|
||||
|
||||
|
@ -344,13 +344,13 @@ describe('Test users', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
|
@ -360,11 +360,11 @@ describe('Test users', function () {
|
|||
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 })
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -372,13 +372,13 @@ describe('Test users', function () {
|
|||
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)
|
||||
}
|
||||
})
|
||||
|
@ -387,7 +387,7 @@ describe('Test users', function () {
|
|||
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')
|
||||
|
@ -410,7 +410,7 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -423,7 +423,7 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -435,7 +435,7 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -447,7 +447,7 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -462,7 +462,7 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -470,7 +470,7 @@ describe('Test users', function () {
|
|||
|
||||
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')
|
||||
|
@ -478,7 +478,7 @@ describe('Test users', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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')
|
||||
|
@ -490,23 +490,23 @@ describe('Test users', function () {
|
|||
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')
|
||||
|
@ -517,33 +517,33 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -556,9 +556,9 @@ describe('Test users', function () {
|
|||
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')
|
||||
})
|
||||
|
||||
|
@ -566,17 +566,17 @@ describe('Test users', function () {
|
|||
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')
|
||||
|
@ -587,9 +587,9 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -603,21 +603,21 @@ describe('Test users', function () {
|
|||
|
||||
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
|
||||
})
|
||||
|
@ -625,7 +625,7 @@ describe('Test users', function () {
|
|||
|
||||
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',
|
||||
|
@ -636,7 +636,7 @@ describe('Test users', function () {
|
|||
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')
|
||||
|
@ -650,47 +650,47 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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]
|
||||
|
@ -705,7 +705,7 @@ describe('Test users', function () {
|
|||
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 () {
|
||||
|
@ -714,35 +714,35 @@ describe('Test users', 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
|
||||
}
|
||||
})
|
||||
|
@ -757,21 +757,21 @@ describe('Test users', function () {
|
|||
}
|
||||
|
||||
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)
|
||||
|
||||
|
@ -779,7 +779,7 @@ describe('Test users', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
|
||||
|
@ -788,9 +788,9 @@ describe('Test users', function () {
|
|||
})
|
||||
|
||||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -803,12 +803,12 @@ describe('Test users', function () {
|
|||
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)
|
||||
|
@ -818,37 +818,37 @@ describe('Test users', function () {
|
|||
|
||||
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
|
||||
})
|
||||
})
|
||||
|
|
|
@ -48,13 +48,13 @@ describe('Test audio only video transcoding', function () {
|
|||
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 ]) {
|
||||
|
@ -68,8 +68,8 @@ describe('Test audio only video transcoding', function () {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -44,8 +44,8 @@ describe('Test multiple servers', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ describe('Test multiple servers', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ describe('Test multiple servers', function () {
|
|||
channelId: videoChannelId,
|
||||
fixture: 'video_short1.webm'
|
||||
}
|
||||
await servers[0].videosCommand.upload({ attributes })
|
||||
await servers[0].videos.upload({ attributes })
|
||||
|
||||
await waitJobs(servers)
|
||||
|
||||
|
@ -125,7 +125,7 @@ describe('Test multiple servers', function () {
|
|||
]
|
||||
}
|
||||
|
||||
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]
|
||||
|
@ -142,8 +142,8 @@ describe('Test multiple servers', function () {
|
|||
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',
|
||||
|
@ -158,7 +158,7 @@ describe('Test multiple servers', function () {
|
|||
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)
|
||||
|
@ -213,7 +213,7 @@ describe('Test multiple servers', function () {
|
|||
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]
|
||||
|
@ -237,7 +237,7 @@ describe('Test multiple servers', function () {
|
|||
tags: [ 'tag1p3' ],
|
||||
fixture: 'video_short3.webm'
|
||||
}
|
||||
await servers[2].videosCommand.upload({ attributes })
|
||||
await servers[2].videos.upload({ attributes })
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -252,7 +252,7 @@ describe('Test multiple servers', function () {
|
|||
tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
|
||||
fixture: 'video_short.webm'
|
||||
}
|
||||
await servers[2].videosCommand.upload({ attributes })
|
||||
await servers[2].videos.upload({ attributes })
|
||||
}
|
||||
|
||||
await waitJobs(servers)
|
||||
|
@ -260,7 +260,7 @@ describe('Test multiple servers', function () {
|
|||
// 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)
|
||||
|
@ -349,7 +349,7 @@ describe('Test multiple servers', function () {
|
|||
|
||||
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')
|
||||
|
@ -358,7 +358,7 @@ describe('Test multiple servers', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -367,7 +367,7 @@ describe('Test multiple servers', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -381,13 +381,13 @@ describe('Test multiple servers', function () {
|
|||
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)
|
||||
|
@ -397,10 +397,10 @@ describe('Test multiple servers', function () {
|
|||
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')
|
||||
|
@ -411,10 +411,10 @@ describe('Test multiple servers', function () {
|
|||
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')
|
||||
|
@ -425,10 +425,10 @@ describe('Test multiple servers', function () {
|
|||
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')
|
||||
|
@ -439,10 +439,10 @@ describe('Test multiple servers', function () {
|
|||
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
|
||||
|
@ -462,17 +462,17 @@ describe('Test multiple servers', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
|
@ -481,16 +481,16 @@ describe('Test multiple servers', function () {
|
|||
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)
|
||||
|
||||
|
@ -500,7 +500,7 @@ describe('Test multiple servers', function () {
|
|||
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])
|
||||
|
@ -514,16 +514,16 @@ describe('Test multiple servers', function () {
|
|||
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)
|
||||
|
||||
|
@ -537,7 +537,7 @@ describe('Test multiple servers', function () {
|
|||
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) {
|
||||
|
@ -555,17 +555,17 @@ describe('Test multiple servers', function () {
|
|||
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)
|
||||
|
@ -573,7 +573,7 @@ describe('Test multiple servers', function () {
|
|||
|
||||
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) {
|
||||
|
@ -608,7 +608,7 @@ describe('Test multiple servers', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -617,7 +617,7 @@ describe('Test multiple servers', function () {
|
|||
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
|
||||
|
@ -665,8 +665,8 @@ describe('Test multiple servers', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -680,7 +680,7 @@ describe('Test multiple servers', function () {
|
|||
|
||||
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)
|
||||
|
@ -697,7 +697,7 @@ describe('Test multiple servers', function () {
|
|||
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
|
||||
|
@ -720,7 +720,7 @@ describe('Test multiple servers', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
|
@ -735,36 +735,36 @@ describe('Test multiple servers', function () {
|
|||
|
||||
{
|
||||
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)
|
||||
|
@ -772,7 +772,7 @@ describe('Test multiple servers', function () {
|
|||
|
||||
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')
|
||||
|
@ -804,10 +804,10 @@ describe('Test multiple servers', function () {
|
|||
|
||||
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')
|
||||
|
@ -837,17 +837,17 @@ describe('Test multiple servers', function () {
|
|||
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]
|
||||
|
@ -868,16 +868,16 @@ describe('Test multiple servers', function () {
|
|||
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')
|
||||
|
@ -913,16 +913,16 @@ describe('Test multiple servers', function () {
|
|||
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)
|
||||
|
@ -957,17 +957,17 @@ describe('Test multiple servers', function () {
|
|||
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 })
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -992,7 +992,7 @@ describe('Test multiple servers', function () {
|
|||
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
|
||||
|
|
|
@ -36,14 +36,14 @@ describe('Test resumable upload', function () {
|
|||
|
||||
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]
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ describe('Test resumable upload', function () {
|
|||
const size = await buildSize(defaultFixture, options.size)
|
||||
const absoluteFilePath = buildAbsoluteFixturePath(defaultFixture)
|
||||
|
||||
return server.videosCommand.sendResumableChunks({
|
||||
return server.videos.sendResumableChunks({
|
||||
pathUploadId,
|
||||
videoFilePath: absoluteFilePath,
|
||||
size,
|
||||
|
@ -75,7 +75,7 @@ describe('Test resumable upload', function () {
|
|||
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) {
|
||||
|
@ -90,7 +90,7 @@ describe('Test resumable upload', function () {
|
|||
|
||||
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
|
||||
|
@ -103,10 +103,10 @@ describe('Test resumable upload', function () {
|
|||
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 () {
|
||||
|
@ -125,13 +125,13 @@ describe('Test resumable upload', 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)
|
||||
})
|
||||
|
|
|
@ -100,35 +100,35 @@ describe('Test a single server', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -145,7 +145,7 @@ describe('Test a single server', function () {
|
|||
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)
|
||||
|
@ -157,7 +157,7 @@ describe('Test a single server', function () {
|
|||
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')
|
||||
|
@ -170,42 +170,42 @@ describe('Test a single server', function () {
|
|||
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')
|
||||
|
@ -232,12 +232,12 @@ describe('Test a single server', function () {
|
|||
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')
|
||||
|
@ -255,7 +255,7 @@ describe('Test a single server', function () {
|
|||
})
|
||||
|
||||
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
|
||||
|
@ -267,7 +267,7 @@ describe('Test a single server', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -276,7 +276,7 @@ describe('Test a single server', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -286,7 +286,7 @@ describe('Test a single server', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -294,7 +294,7 @@ describe('Test a single server', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -302,7 +302,7 @@ describe('Test a single server', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -318,21 +318,21 @@ describe('Test a single server', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -350,18 +350,18 @@ describe('Test a single server', function () {
|
|||
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)
|
||||
}
|
||||
})
|
||||
|
@ -369,7 +369,7 @@ describe('Test a single server', function () {
|
|||
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())
|
||||
})
|
||||
|
@ -378,9 +378,9 @@ describe('Test a single server', function () {
|
|||
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))
|
||||
})
|
||||
|
@ -389,27 +389,27 @@ describe('Test a single server', function () {
|
|||
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)
|
||||
|
@ -419,9 +419,9 @@ describe('Test a single server', function () {
|
|||
{
|
||||
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')
|
||||
|
@ -435,9 +435,9 @@ describe('Test a single server', function () {
|
|||
{
|
||||
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')
|
||||
|
|
|
@ -32,7 +32,7 @@ describe('Test video captions', function () {
|
|||
|
||||
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)
|
||||
|
@ -40,7 +40,7 @@ describe('Test video captions', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
|
@ -49,13 +49,13 @@ describe('Test video captions', function () {
|
|||
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',
|
||||
|
@ -67,7 +67,7 @@ describe('Test video captions', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -88,7 +88,7 @@ describe('Test video captions', function () {
|
|||
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'
|
||||
|
@ -99,7 +99,7 @@ describe('Test video captions', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -114,7 +114,7 @@ describe('Test video captions', function () {
|
|||
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'
|
||||
|
@ -128,7 +128,7 @@ describe('Test video captions', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -157,14 +157,14 @@ describe('Test video captions', function () {
|
|||
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)
|
||||
|
||||
|
@ -178,7 +178,7 @@ describe('Test video captions', function () {
|
|||
})
|
||||
|
||||
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])
|
||||
})
|
||||
|
|
|
@ -43,7 +43,7 @@ describe('Test video change ownership - nominal', function () {
|
|||
await setAccessTokensToServers(servers)
|
||||
await setDefaultVideoChannel(servers)
|
||||
|
||||
await servers[0].configCommand.updateCustomSubConfig({
|
||||
await servers[0].config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
transcoding: {
|
||||
enabled: false
|
||||
|
@ -54,16 +54,16 @@ describe('Test video change ownership - nominal', function () {
|
|||
}
|
||||
})
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -72,19 +72,19 @@ describe('Test video change ownership - nominal', function () {
|
|||
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])
|
||||
})
|
||||
|
@ -110,7 +110,7 @@ describe('Test video change ownership - nominal', function () {
|
|||
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 () {
|
||||
|
@ -136,7 +136,7 @@ describe('Test video change ownership - nominal', 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 () {
|
||||
|
@ -164,7 +164,7 @@ describe('Test video change ownership - nominal', 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 () {
|
||||
|
@ -208,7 +208,7 @@ describe('Test video change ownership - nominal', 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')
|
||||
|
@ -237,7 +237,7 @@ describe('Test video change ownership - nominal', function () {
|
|||
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')
|
||||
|
@ -266,35 +266,35 @@ describe('Test video change ownership - quota too small', function () {
|
|||
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')
|
||||
|
@ -302,7 +302,7 @@ describe('Test video change ownership - quota too small', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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')
|
||||
|
@ -315,10 +315,10 @@ describe('Test video change ownership - quota too small', function () {
|
|||
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,
|
||||
|
|
|
@ -21,7 +21,7 @@ import { User, VideoChannel } from '@shared/models'
|
|||
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)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ describe('Test video channels', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -66,14 +66,14 @@ describe('Test video channels', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ describe('Test video channels', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -99,7 +99,7 @@ describe('Test video channels', function () {
|
|||
})
|
||||
|
||||
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
|
||||
|
@ -118,7 +118,7 @@ describe('Test video channels', function () {
|
|||
|
||||
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,
|
||||
|
@ -133,7 +133,7 @@ describe('Test video channels', function () {
|
|||
}
|
||||
|
||||
{
|
||||
const body = await servers[0].channelsCommand.listByAccount({
|
||||
const body = await servers[0].channels.listByAccount({
|
||||
accountName,
|
||||
start: 0,
|
||||
count: 1,
|
||||
|
@ -146,7 +146,7 @@ describe('Test video channels', function () {
|
|||
}
|
||||
|
||||
{
|
||||
const body = await servers[0].channelsCommand.listByAccount({
|
||||
const body = await servers[0].channels.listByAccount({
|
||||
accountName,
|
||||
start: 1,
|
||||
count: 1,
|
||||
|
@ -160,7 +160,7 @@ describe('Test video channels', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -174,7 +174,7 @@ describe('Test video channels', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -192,14 +192,14 @@ describe('Test video channels', function () {
|
|||
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')
|
||||
|
@ -214,7 +214,7 @@ describe('Test video channels', function () {
|
|||
|
||||
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')
|
||||
}
|
||||
})
|
||||
|
@ -227,12 +227,12 @@ describe('Test video channels', function () {
|
|||
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)
|
||||
}
|
||||
})
|
||||
|
@ -242,7 +242,7 @@ describe('Test video channels', function () {
|
|||
|
||||
const fixture = 'avatar.png'
|
||||
|
||||
await servers[0].channelsCommand.updateImage({
|
||||
await servers[0].channels.updateImage({
|
||||
channelName: 'second_video_channel',
|
||||
fixture,
|
||||
type: 'avatar'
|
||||
|
@ -257,7 +257,7 @@ describe('Test video channels', function () {
|
|||
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)
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ describe('Test video channels', function () {
|
|||
|
||||
const fixture = 'banner.jpg'
|
||||
|
||||
await servers[0].channelsCommand.updateImage({
|
||||
await servers[0].channels.updateImage({
|
||||
channelName: 'second_video_channel',
|
||||
fixture,
|
||||
type: 'banner'
|
||||
|
@ -277,13 +277,13 @@ describe('Test video channels', function () {
|
|||
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)
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ describe('Test video channels', function () {
|
|||
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)
|
||||
|
||||
|
@ -307,7 +307,7 @@ describe('Test video channels', function () {
|
|||
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)
|
||||
|
||||
|
@ -324,7 +324,7 @@ describe('Test video channels', function () {
|
|||
|
||||
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')
|
||||
|
@ -336,7 +336,7 @@ describe('Test video channels', function () {
|
|||
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)
|
||||
})
|
||||
|
@ -347,13 +347,13 @@ describe('Test video channels', function () {
|
|||
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')
|
||||
|
@ -364,11 +364,11 @@ describe('Test video channels', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
|
@ -379,15 +379,15 @@ describe('Test video channels', function () {
|
|||
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}/)
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ describe('Test video channels', function () {
|
|||
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')
|
||||
|
@ -411,21 +411,21 @@ describe('Test video channels', function () {
|
|||
}
|
||||
|
||||
{
|
||||
// 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')
|
||||
|
@ -436,7 +436,7 @@ describe('Test video channels', function () {
|
|||
|
||||
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
|
||||
|
@ -444,7 +444,7 @@ describe('Test video channels', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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
|
||||
|
@ -455,21 +455,21 @@ describe('Test video channels', function () {
|
|||
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')
|
||||
|
|
|
@ -32,15 +32,15 @@ describe('Test video comments', function () {
|
|||
|
||||
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 () {
|
||||
|
|
|
@ -31,11 +31,11 @@ describe('Test video description', 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
|
||||
|
@ -43,7 +43,7 @@ describe('Test video description', function () {
|
|||
|
||||
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) +
|
||||
|
@ -55,9 +55,9 @@ describe('Test video description', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
@ -68,18 +68,18 @@ describe('Test video description', function () {
|
|||
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')
|
||||
}
|
||||
})
|
||||
|
|
|
@ -25,7 +25,7 @@ const expect = chai.expect
|
|||
|
||||
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)
|
||||
|
@ -62,7 +62,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn
|
|||
{
|
||||
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`)
|
||||
|
@ -72,7 +72,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn
|
|||
|
||||
{
|
||||
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`
|
||||
})
|
||||
|
||||
|
@ -107,7 +107,7 @@ describe('Test HLS videos', function () {
|
|||
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)
|
||||
|
@ -118,7 +118,7 @@ describe('Test HLS videos', function () {
|
|||
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)
|
||||
|
@ -129,7 +129,7 @@ describe('Test HLS videos', function () {
|
|||
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)
|
||||
|
||||
|
@ -139,14 +139,14 @@ describe('Test HLS videos', function () {
|
|||
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 })
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -192,7 +192,7 @@ describe('Test HLS videos', function () {
|
|||
describe('With only HLS enabled', function () {
|
||||
|
||||
before(async function () {
|
||||
await servers[0].configCommand.updateCustomSubConfig({
|
||||
await servers[0].config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
transcoding: {
|
||||
enabled: true,
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('Test video imports', function () {
|
|||
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
|
||||
|
@ -43,8 +43,8 @@ describe('Test video imports', function () {
|
|||
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')
|
||||
|
@ -59,12 +59,12 @@ describe('Test video imports', function () {
|
|||
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')
|
||||
|
@ -76,7 +76,7 @@ describe('Test video imports', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -89,12 +89,12 @@ describe('Test video imports', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ describe('Test video imports', function () {
|
|||
|
||||
{
|
||||
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$`))
|
||||
|
@ -120,7 +120,7 @@ describe('Test video imports', function () {
|
|||
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)
|
||||
|
||||
|
@ -166,7 +166,7 @@ Ajouter un sous-titre est vraiment facile`)
|
|||
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')
|
||||
}
|
||||
|
||||
|
@ -177,13 +177,13 @@ Ajouter un sous-titre est vraiment facile`)
|
|||
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)
|
||||
|
||||
|
@ -194,7 +194,7 @@ Ajouter un sous-titre est vraiment facile`)
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -221,7 +221,7 @@ Ajouter un sous-titre est vraiment facile`)
|
|||
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)
|
||||
|
||||
|
@ -244,7 +244,7 @@ Ajouter un sous-titre est vraiment facile`)
|
|||
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')
|
||||
})
|
||||
|
||||
|
@ -254,7 +254,7 @@ Ajouter un sous-titre est vraiment facile`)
|
|||
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)
|
||||
|
||||
|
@ -274,13 +274,13 @@ Ajouter un sous-titre est vraiment facile`)
|
|||
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)
|
||||
|
@ -316,7 +316,7 @@ Ajouter un sous-titre est vraiment facile`)
|
|||
}
|
||||
}
|
||||
}
|
||||
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
|
||||
await servers[0].config.updateCustomSubConfig({ newConfig: config })
|
||||
|
||||
const attributes = {
|
||||
name: 'hdr video',
|
||||
|
@ -324,13 +324,13 @@ Ajouter un sous-titre est vraiment facile`)
|
|||
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)
|
||||
|
|
|
@ -18,7 +18,7 @@ describe('Test video NSFW policy', function () {
|
|||
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
|
||||
|
@ -26,15 +26,15 @@ describe('Test video NSFW policy', function () {
|
|||
|
||||
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)
|
||||
}
|
||||
|
@ -43,15 +43,15 @@ describe('Test video NSFW policy', function () {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -68,20 +68,20 @@ describe('Test video NSFW policy', function () {
|
|||
|
||||
{
|
||||
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()) {
|
||||
|
@ -96,9 +96,9 @@ describe('Test video NSFW policy', function () {
|
|||
|
||||
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()) {
|
||||
|
@ -112,9 +112,9 @@ describe('Test video NSFW policy', function () {
|
|||
|
||||
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()) {
|
||||
|
@ -133,17 +133,17 @@ describe('Test video NSFW policy', function () {
|
|||
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)
|
||||
|
@ -156,7 +156,7 @@ describe('Test video NSFW policy', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -169,7 +169,7 @@ describe('Test video NSFW policy', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -181,7 +181,7 @@ describe('Test video NSFW policy', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
|
|
@ -31,13 +31,13 @@ describe('Playlist thumbnail', function () {
|
|||
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')
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ describe('Playlist thumbnail', function () {
|
|||
// 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)
|
||||
})
|
||||
|
@ -63,16 +63,16 @@ describe('Playlist thumbnail', function () {
|
|||
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 }
|
||||
})
|
||||
|
@ -89,17 +89,17 @@ describe('Playlist thumbnail', function () {
|
|||
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 }
|
||||
})
|
||||
|
@ -116,13 +116,13 @@ describe('Playlist thumbnail', function () {
|
|||
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,
|
||||
|
@ -141,13 +141,13 @@ describe('Playlist thumbnail', function () {
|
|||
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,
|
||||
|
@ -166,7 +166,7 @@ describe('Playlist thumbnail', function () {
|
|||
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
|
||||
})
|
||||
|
@ -182,7 +182,7 @@ describe('Playlist thumbnail', function () {
|
|||
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
|
||||
})
|
||||
|
@ -198,7 +198,7 @@ describe('Playlist thumbnail', function () {
|
|||
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
|
||||
})
|
||||
|
@ -214,7 +214,7 @@ describe('Playlist thumbnail', function () {
|
|||
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
|
||||
})
|
||||
|
|
|
@ -36,7 +36,7 @@ async function checkPlaylistElementType (
|
|||
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)
|
||||
|
@ -86,26 +86,26 @@ describe('Test video playlists', function () {
|
|||
// 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)
|
||||
})
|
||||
|
@ -149,7 +149,7 @@ describe('Test video playlists', function () {
|
|||
})
|
||||
|
||||
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' })
|
||||
|
||||
|
@ -172,7 +172,7 @@ describe('Test video playlists', function () {
|
|||
privacy: VideoPlaylistPrivacy.PUBLIC,
|
||||
description: 'my super description',
|
||||
thumbnailfile: 'thumbnail.jpg',
|
||||
videoChannelId: servers[0].videoChannel.id
|
||||
videoChannelId: servers[0].store.channel.id
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -181,13 +181,13 @@ describe('Test video playlists', function () {
|
|||
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')
|
||||
|
@ -217,23 +217,23 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -242,13 +242,13 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
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 }
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
|
@ -267,7 +267,7 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
})
|
||||
|
@ -278,7 +278,7 @@ describe('Test video playlists', function () {
|
|||
// 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
|
||||
|
@ -294,7 +294,7 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
|
@ -304,7 +304,7 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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
|
||||
|
@ -331,7 +331,7 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
|
@ -340,7 +340,7 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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
|
||||
|
@ -349,7 +349,7 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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
|
||||
|
@ -358,7 +358,7 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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
|
||||
|
@ -375,17 +375,17 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
|
@ -400,8 +400,8 @@ describe('Test video playlists', function () {
|
|||
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)
|
||||
|
@ -417,23 +417,23 @@ describe('Test video playlists', function () {
|
|||
})
|
||||
|
||||
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 })
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -443,13 +443,13 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
})
|
||||
|
@ -457,7 +457,7 @@ describe('Test video playlists', function () {
|
|||
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')
|
||||
|
@ -491,23 +491,23 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ describe('Test video playlists', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -576,7 +576,7 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ describe('Test video playlists', function () {
|
|||
attributes: {
|
||||
displayName: 'playlist 56',
|
||||
privacy: VideoPlaylistPrivacy.PUBLIC,
|
||||
videoChannelId: servers[0].videoChannel.id
|
||||
videoChannelId: servers[0].store.channel.id
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -617,9 +617,9 @@ describe('Test video playlists', function () {
|
|||
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)
|
||||
|
||||
|
@ -637,7 +637,7 @@ describe('Test video playlists', function () {
|
|||
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)
|
||||
|
@ -647,7 +647,7 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
|
@ -665,7 +665,7 @@ describe('Test video playlists', function () {
|
|||
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)
|
||||
|
@ -675,7 +675,7 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
|
@ -689,7 +689,7 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
|
@ -778,7 +778,7 @@ describe('Test video playlists', function () {
|
|||
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([
|
||||
|
@ -807,7 +807,7 @@ describe('Test video playlists', function () {
|
|||
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([
|
||||
|
@ -835,7 +835,7 @@ describe('Test video playlists', function () {
|
|||
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([
|
||||
|
@ -878,7 +878,7 @@ describe('Test video playlists', function () {
|
|||
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)
|
||||
|
@ -894,16 +894,16 @@ describe('Test video playlists', function () {
|
|||
|
||||
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)
|
||||
|
@ -912,7 +912,7 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
|
@ -921,7 +921,7 @@ describe('Test video playlists', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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)
|
||||
|
@ -934,29 +934,29 @@ describe('Test video playlists', function () {
|
|||
|
||||
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')
|
||||
|
@ -972,7 +972,7 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
|
@ -1005,14 +1005,14 @@ describe('Test video playlists', function () {
|
|||
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 }
|
||||
|
@ -1021,7 +1021,7 @@ describe('Test video playlists', function () {
|
|||
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 })
|
||||
|
@ -1039,7 +1039,7 @@ describe('Test video playlists', function () {
|
|||
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 })
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -1057,16 +1057,16 @@ describe('Test video playlists', function () {
|
|||
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
|
||||
|
@ -1076,7 +1076,7 @@ describe('Test video playlists', function () {
|
|||
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: {
|
||||
|
@ -1088,7 +1088,7 @@ describe('Test video playlists', function () {
|
|||
|
||||
await waitJobs(servers)
|
||||
|
||||
await servers[0].channelsCommand.delete({ channelName: 'super_channel' })
|
||||
await servers[0].channels.delete({ channelName: 'super_channel' })
|
||||
|
||||
await waitJobs(servers)
|
||||
|
||||
|
@ -1096,15 +1096,15 @@ describe('Test video playlists', function () {
|
|||
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({
|
||||
|
@ -1121,18 +1121,18 @@ describe('Test video playlists', function () {
|
|||
|
||||
{
|
||||
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
|
||||
}
|
||||
|
|
|
@ -52,28 +52,28 @@ describe('Test video privacy', function () {
|
|||
|
||||
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)
|
||||
|
@ -82,7 +82,7 @@ describe('Test video privacy', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -97,8 +97,8 @@ describe('Test video privacy', function () {
|
|||
})
|
||||
|
||||
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 () {
|
||||
|
@ -108,11 +108,11 @@ describe('Test video privacy', 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
|
||||
|
@ -120,11 +120,11 @@ describe('Test video privacy', function () {
|
|||
})
|
||||
|
||||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -137,7 +137,7 @@ describe('Test video privacy', function () {
|
|||
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)
|
||||
|
@ -145,7 +145,7 @@ describe('Test video privacy', function () {
|
|||
|
||||
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)
|
||||
|
@ -153,7 +153,7 @@ describe('Test video privacy', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -162,13 +162,13 @@ describe('Test video privacy', function () {
|
|||
})
|
||||
|
||||
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')
|
||||
}
|
||||
|
@ -182,13 +182,13 @@ describe('Test video privacy', function () {
|
|||
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)
|
||||
|
@ -197,13 +197,13 @@ describe('Test video privacy', function () {
|
|||
})
|
||||
|
||||
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 })
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -220,7 +220,7 @@ describe('Test video privacy', function () {
|
|||
privacy: VideoPrivacy.PUBLIC
|
||||
}
|
||||
|
||||
await servers[0].videosCommand.update({ id: privateVideoId, attributes })
|
||||
await servers[0].videos.update({ id: privateVideoId, attributes })
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ describe('Test video privacy', function () {
|
|||
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)
|
||||
|
@ -236,7 +236,7 @@ describe('Test video privacy', function () {
|
|||
|
||||
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)
|
||||
|
||||
|
@ -258,20 +258,20 @@ describe('Test video privacy', function () {
|
|||
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)
|
||||
|
||||
|
|
|
@ -49,25 +49,25 @@ describe('Test video update scheduler', function () {
|
|||
}
|
||||
}
|
||||
|
||||
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')
|
||||
|
@ -84,7 +84,7 @@ describe('Test video update scheduler', function () {
|
|||
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')
|
||||
|
@ -99,7 +99,7 @@ describe('Test video update scheduler', function () {
|
|||
privacy: VideoPrivacy.PRIVATE
|
||||
}
|
||||
|
||||
const { uuid } = await servers[0].videosCommand.upload({ attributes })
|
||||
const { uuid } = await servers[0].videos.upload({ attributes })
|
||||
video2UUID = uuid
|
||||
|
||||
await waitJobs(servers)
|
||||
|
@ -116,20 +116,20 @@ describe('Test video update scheduler', function () {
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -149,7 +149,7 @@ describe('Test video update scheduler', function () {
|
|||
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)
|
||||
|
|
|
@ -32,7 +32,7 @@ import {
|
|||
const expect = chai.expect
|
||||
|
||||
function updateConfigForTranscoding (server: ServerInfo) {
|
||||
return server.configCommand.updateCustomSubConfig({
|
||||
return server.config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
transcoding: {
|
||||
enabled: true,
|
||||
|
@ -82,15 +82,15 @@ describe('Test video transcoding', function () {
|
|||
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
|
||||
|
@ -111,15 +111,15 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
|
||||
|
@ -143,11 +143,11 @@ describe('Test video transcoding', function () {
|
|||
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')
|
||||
|
@ -155,7 +155,7 @@ describe('Test video transcoding', function () {
|
|||
|
||||
{
|
||||
// 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)
|
||||
|
@ -165,23 +165,23 @@ describe('Test video transcoding', function () {
|
|||
|
||||
{
|
||||
// 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')
|
||||
|
@ -207,15 +207,15 @@ describe('Test video transcoding', function () {
|
|||
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
|
||||
|
@ -232,7 +232,7 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
|
@ -240,7 +240,7 @@ describe('Test video transcoding', function () {
|
|||
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) {
|
||||
|
@ -260,19 +260,19 @@ describe('Test video transcoding', function () {
|
|||
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) {
|
||||
|
@ -291,18 +291,18 @@ describe('Test video transcoding', function () {
|
|||
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')
|
||||
}
|
||||
|
@ -315,21 +315,21 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
|
||||
|
@ -348,7 +348,7 @@ describe('Test video transcoding', function () {
|
|||
function runSuite (mode: 'legacy' | 'resumable') {
|
||||
|
||||
before(async function () {
|
||||
await servers[1].configCommand.updateCustomSubConfig({
|
||||
await servers[1].config.updateCustomSubConfig({
|
||||
newConfig: {
|
||||
transcoding: {
|
||||
hls: { enabled: true },
|
||||
|
@ -372,15 +372,15 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
|
||||
|
@ -396,15 +396,15 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
|
||||
|
@ -419,7 +419,7 @@ describe('Test video transcoding', function () {
|
|||
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 },
|
||||
|
@ -434,12 +434,12 @@ describe('Test video transcoding', function () {
|
|||
})
|
||||
|
||||
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)
|
||||
|
@ -470,15 +470,15 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
|
@ -487,13 +487,13 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
|
@ -518,23 +518,23 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
}
|
||||
|
@ -561,17 +561,17 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
|
@ -602,21 +602,21 @@ describe('Test video transcoding', function () {
|
|||
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)
|
||||
}
|
||||
})
|
||||
|
@ -627,11 +627,11 @@ describe('Test video transcoding', function () {
|
|||
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
|
||||
|
@ -661,7 +661,7 @@ describe('Test video transcoding', function () {
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -673,7 +673,7 @@ describe('Test video transcoding', function () {
|
|||
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')
|
||||
}
|
||||
}
|
||||
|
@ -690,7 +690,7 @@ describe('Test video transcoding', function () {
|
|||
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',
|
||||
|
|
|
@ -55,19 +55,19 @@ describe('Test videos filter', function () {
|
|||
|
||||
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 })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,20 +33,20 @@ describe('Test videos history', function () {
|
|||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -54,15 +54,15 @@ describe('Test videos history', function () {
|
|||
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
|
||||
|
@ -78,12 +78,12 @@ describe('Test videos history', function () {
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -102,21 +102,21 @@ describe('Test videos history', function () {
|
|||
}
|
||||
|
||||
{
|
||||
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
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ describe('Test videos history', function () {
|
|||
})
|
||||
|
||||
it('Should disable videos history', async function () {
|
||||
await server.usersCommand.updateMe({
|
||||
await server.users.updateMe({
|
||||
videosHistoryEnabled: false
|
||||
})
|
||||
|
||||
|
@ -172,7 +172,7 @@ describe('Test videos history', function () {
|
|||
})
|
||||
|
||||
it('Should re-enable videos history', async function () {
|
||||
await server.usersCommand.updateMe({
|
||||
await server.users.updateMe({
|
||||
videosHistoryEnabled: true
|
||||
})
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue