Introduce server commands
This commit is contained in:
parent
0d8ecb7592
commit
6c5065a011
|
@ -2,11 +2,10 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { buildRequestStub } from '../../../../shared/extra-utils/miscs/stubs'
|
|
||||||
import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto'
|
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { buildAbsoluteFixturePath, buildRequestStub } from '@shared/extra-utils'
|
||||||
import { buildSignedActivity } from '../../../helpers/activitypub'
|
import { buildSignedActivity } from '../../../helpers/activitypub'
|
||||||
import { buildAbsoluteFixturePath } from '@shared/extra-utils'
|
import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto'
|
||||||
|
|
||||||
describe('Test activity pub helpers', function () {
|
describe('Test activity pub helpers', function () {
|
||||||
describe('When checking the Linked Signature', function () {
|
describe('When checking the Linked Signature', function () {
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import { omit } from 'lodash'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
|
import { omit } from 'lodash'
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
immutableAssign,
|
|
||||||
makeDeleteRequest,
|
makeDeleteRequest,
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePutBodyRequest,
|
makePutBodyRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
userLogin
|
userLogin
|
||||||
} from '../../../../shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { CustomConfig } from '@shared/models'
|
||||||
|
|
||||||
describe('Test config API validators', function () {
|
describe('Test config API validators', function () {
|
||||||
const path = '/api/v1/config/custom'
|
const path = '/api/v1/config/custom'
|
||||||
|
@ -265,11 +263,13 @@ describe('Test config API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad default NSFW policy', async function () {
|
it('Should fail with a bad default NSFW policy', async function () {
|
||||||
const newUpdateParams = immutableAssign(updateParams, {
|
const newUpdateParams = {
|
||||||
|
...updateParams,
|
||||||
|
|
||||||
instance: {
|
instance: {
|
||||||
defaultNSFWPolicy: 'hello'
|
defaultNSFWPolicy: 'hello'
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
await makePutBodyRequest({
|
await makePutBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -282,13 +282,15 @@ describe('Test config API validators', function () {
|
||||||
|
|
||||||
it('Should fail if email disabled and signup requires email verification', async function () {
|
it('Should fail if email disabled and signup requires email verification', async function () {
|
||||||
// opposite scenario - success when enable enabled - covered via tests/api/users/user-verification.ts
|
// opposite scenario - success when enable enabled - covered via tests/api/users/user-verification.ts
|
||||||
const newUpdateParams = immutableAssign(updateParams, {
|
const newUpdateParams = {
|
||||||
|
...updateParams,
|
||||||
|
|
||||||
signup: {
|
signup: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
limit: 5,
|
limit: 5,
|
||||||
requiresEmailVerification: true
|
requiresEmailVerification: true
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
await makePutBodyRequest({
|
await makePutBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -300,7 +302,9 @@ describe('Test config API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a disabled webtorrent & hls transcoding', async function () {
|
it('Should fail with a disabled webtorrent & hls transcoding', async function () {
|
||||||
const newUpdateParams = immutableAssign(updateParams, {
|
const newUpdateParams = {
|
||||||
|
...updateParams,
|
||||||
|
|
||||||
transcoding: {
|
transcoding: {
|
||||||
hls: {
|
hls: {
|
||||||
enabled: false
|
enabled: false
|
||||||
|
@ -309,7 +313,7 @@ describe('Test config API validators', function () {
|
||||||
enabled: false
|
enabled: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
await makePutBodyRequest({
|
await makePutBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
immutableAssign,
|
|
||||||
LiveCommand,
|
LiveCommand,
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
makeUploadRequest,
|
makeUploadRequest,
|
||||||
|
@ -97,37 +96,37 @@ describe('Test video lives API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long name', async function () {
|
it('Should fail with a long name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
|
const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad category', async function () {
|
it('Should fail with a bad category', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { category: 125 })
|
const fields = { ...baseCorrectParams, category: 125 }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad licence', async function () {
|
it('Should fail with a bad licence', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { licence: 125 })
|
const fields = { ...baseCorrectParams, licence: 125 }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad language', async function () {
|
it('Should fail with a bad language', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) })
|
const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long description', async function () {
|
it('Should fail with a long description', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
|
const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long support text', async function () {
|
it('Should fail with a long support text', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
|
const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -139,7 +138,7 @@ describe('Test video lives API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad channel', async function () {
|
it('Should fail with a bad channel', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
|
const fields = { ...baseCorrectParams, channelId: 545454 }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -155,25 +154,25 @@ describe('Test video lives API validator', function () {
|
||||||
const res = await getMyUserInformation(server.url, accessTokenUser)
|
const res = await getMyUserInformation(server.url, accessTokenUser)
|
||||||
const customChannelId = res.body.videoChannels[0].id
|
const customChannelId = res.body.videoChannels[0].id
|
||||||
|
|
||||||
const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId })
|
const fields = { ...baseCorrectParams, channelId: customChannelId }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with too many tags', async function () {
|
it('Should fail with too many tags', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a tag length too low', async function () {
|
it('Should fail with a tag length too low', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a tag length too big', async function () {
|
it('Should fail with a tag length too big', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -215,7 +214,7 @@ describe('Test video lives API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with save replay and permanent live set to true', async function () {
|
it('Should fail with save replay and permanent live set to true', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { saveReplay: true, permanentLive: true })
|
const fields = { ...baseCorrectParams, saveReplay: true, permanentLive: true }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -253,7 +252,7 @@ describe('Test video lives API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should forbid to save replay if not enabled by the admin', async function () {
|
it('Should forbid to save replay if not enabled by the admin', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
|
const fields = { ...baseCorrectParams, saveReplay: true }
|
||||||
|
|
||||||
await server.configCommand.updateCustomSubConfig({
|
await server.configCommand.updateCustomSubConfig({
|
||||||
newConfig: {
|
newConfig: {
|
||||||
|
@ -274,7 +273,7 @@ describe('Test video lives API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should allow to save replay if enabled by the admin', async function () {
|
it('Should allow to save replay if enabled by the admin', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { saveReplay: true })
|
const fields = { ...baseCorrectParams, saveReplay: true }
|
||||||
|
|
||||||
await server.configCommand.updateCustomSubConfig({
|
await server.configCommand.updateCustomSubConfig({
|
||||||
newConfig: {
|
newConfig: {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
immutableAssign,
|
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
makePutBodyRequest,
|
makePutBodyRequest,
|
||||||
|
@ -200,7 +199,7 @@ describe('Test server plugins API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid plugin type', async function () {
|
it('Should fail with an invalid plugin type', async function () {
|
||||||
const query = immutableAssign(baseQuery, { pluginType: 5 })
|
const query = { ...baseQuery, pluginType: 5 }
|
||||||
|
|
||||||
await makeGetRequest({
|
await makeGetRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -211,7 +210,7 @@ describe('Test server plugins API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid current peertube engine', async function () {
|
it('Should fail with an invalid current peertube engine', async function () {
|
||||||
const query = immutableAssign(baseQuery, { currentPeerTubeEngine: '1.0' })
|
const query = { ...baseQuery, currentPeerTubeEngine: '1.0' }
|
||||||
|
|
||||||
await makeGetRequest({
|
await makeGetRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -271,7 +270,7 @@ describe('Test server plugins API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid plugin type', async function () {
|
it('Should fail with an invalid plugin type', async function () {
|
||||||
const query = immutableAssign(baseQuery, { pluginType: 5 })
|
const query = { ...baseQuery, pluginType: 5 }
|
||||||
|
|
||||||
await makeGetRequest({
|
await makeGetRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
checkBadStartPagination,
|
checkBadStartPagination,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
immutableAssign,
|
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers
|
setAccessTokensToServers
|
||||||
|
@ -63,78 +62,78 @@ describe('Test videos API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid category', async function () {
|
it('Should fail with an invalid category', async function () {
|
||||||
const customQuery1 = immutableAssign(query, { categoryOneOf: [ 'aa', 'b' ] })
|
const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
const customQuery2 = immutableAssign(query, { categoryOneOf: 'a' })
|
const customQuery2 = { ...query, categoryOneOf: 'a' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should succeed with a valid category', async function () {
|
it('Should succeed with a valid category', async function () {
|
||||||
const customQuery1 = immutableAssign(query, { categoryOneOf: [ 1, 7 ] })
|
const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
|
|
||||||
const customQuery2 = immutableAssign(query, { categoryOneOf: 1 })
|
const customQuery2 = { ...query, categoryOneOf: 1 }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid licence', async function () {
|
it('Should fail with an invalid licence', async function () {
|
||||||
const customQuery1 = immutableAssign(query, { licenceOneOf: [ 'aa', 'b' ] })
|
const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
const customQuery2 = immutableAssign(query, { licenceOneOf: 'a' })
|
const customQuery2 = { ...query, licenceOneOf: 'a' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should succeed with a valid licence', async function () {
|
it('Should succeed with a valid licence', async function () {
|
||||||
const customQuery1 = immutableAssign(query, { licenceOneOf: [ 1, 2 ] })
|
const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
|
|
||||||
const customQuery2 = immutableAssign(query, { licenceOneOf: 1 })
|
const customQuery2 = { ...query, licenceOneOf: 1 }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should succeed with a valid language', async function () {
|
it('Should succeed with a valid language', async function () {
|
||||||
const customQuery1 = immutableAssign(query, { languageOneOf: [ 'fr', 'en' ] })
|
const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
|
|
||||||
const customQuery2 = immutableAssign(query, { languageOneOf: 'fr' })
|
const customQuery2 = { ...query, languageOneOf: 'fr' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should succeed with valid tags', async function () {
|
it('Should succeed with valid tags', async function () {
|
||||||
const customQuery1 = immutableAssign(query, { tagsOneOf: [ 'tag1', 'tag2' ] })
|
const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
|
|
||||||
const customQuery2 = immutableAssign(query, { tagsOneOf: 'tag1' })
|
const customQuery2 = { ...query, tagsOneOf: 'tag1' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
|
|
||||||
const customQuery3 = immutableAssign(query, { tagsAllOf: [ 'tag1', 'tag2' ] })
|
const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
|
|
||||||
const customQuery4 = immutableAssign(query, { tagsAllOf: 'tag1' })
|
const customQuery4 = { ...query, tagsAllOf: 'tag1' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with invalid durations', async function () {
|
it('Should fail with invalid durations', async function () {
|
||||||
const customQuery1 = immutableAssign(query, { durationMin: 'hello' })
|
const customQuery1 = { ...query, durationMin: 'hello' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
const customQuery2 = immutableAssign(query, { durationMax: 'hello' })
|
const customQuery2 = { ...query, durationMax: 'hello' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with invalid dates', async function () {
|
it('Should fail with invalid dates', async function () {
|
||||||
const customQuery1 = immutableAssign(query, { startDate: 'hello' })
|
const customQuery1 = { ...query, startDate: 'hello' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
const customQuery2 = immutableAssign(query, { endDate: 'hello' })
|
const customQuery2 = { ...query, endDate: 'hello' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
const customQuery3 = immutableAssign(query, { originallyPublishedStartDate: 'hello' })
|
const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
|
|
||||||
const customQuery4 = immutableAssign(query, { originallyPublishedEndDate: 'hello' })
|
const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -201,41 +200,41 @@ describe('Test videos API validator', function () {
|
||||||
|
|
||||||
for (const path of paths) {
|
for (const path of paths) {
|
||||||
{
|
{
|
||||||
const customQuery = immutableAssign(query, { searchTarget: 'hello' })
|
const customQuery = { ...query, searchTarget: 'hello' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const customQuery = immutableAssign(query, { searchTarget: undefined })
|
const customQuery = { ...query, searchTarget: undefined }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const customQuery = immutableAssign(query, { searchTarget: 'local' })
|
const customQuery = { ...query, searchTarget: 'local' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const customQuery = immutableAssign(query, { searchTarget: 'search-index' })
|
const customQuery = { ...query, searchTarget: 'search-index' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateSearchIndex(server, true, true)
|
await updateSearchIndex(server, true, true)
|
||||||
|
|
||||||
{
|
{
|
||||||
const customQuery = immutableAssign(query, { searchTarget: 'local' })
|
const customQuery = { ...query, searchTarget: 'local' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const customQuery = immutableAssign(query, { searchTarget: 'search-index' })
|
const customQuery = { ...query, searchTarget: 'search-index' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
}
|
}
|
||||||
|
|
||||||
await updateSearchIndex(server, true, false)
|
await updateSearchIndex(server, true, false)
|
||||||
|
|
||||||
{
|
{
|
||||||
const customQuery = immutableAssign(query, { searchTarget: 'local' })
|
const customQuery = { ...query, searchTarget: 'local' }
|
||||||
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
|
await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,25 +2,21 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { io } from 'socket.io-client'
|
import { io } from 'socket.io-client'
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
|
checkBadCountPagination,
|
||||||
|
checkBadSortPagination,
|
||||||
|
checkBadStartPagination,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
immutableAssign,
|
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
makePutBodyRequest,
|
makePutBodyRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
wait
|
wait
|
||||||
} from '../../../../shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import {
|
import { UserNotificationSetting, UserNotificationSettingValue } from '@shared/models'
|
||||||
checkBadCountPagination,
|
|
||||||
checkBadSortPagination,
|
|
||||||
checkBadStartPagination
|
|
||||||
} from '../../../../shared/extra-utils/requests/check-api-params'
|
|
||||||
import { UserNotificationSetting, UserNotificationSettingValue } from '../../../../shared/models/users'
|
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
describe('Test user notifications API validators', function () {
|
describe('Test user notifications API validators', function () {
|
||||||
let server: ServerInfo
|
let server: ServerInfo
|
||||||
|
@ -193,7 +189,7 @@ describe('Test user notifications API validators', function () {
|
||||||
|
|
||||||
it('Should fail with incorrect field values', async function () {
|
it('Should fail with incorrect field values', async function () {
|
||||||
{
|
{
|
||||||
const fields = immutableAssign(correctFields, { newCommentOnMyVideo: 15 })
|
const fields = { ...correctFields, newCommentOnMyVideo: 15 }
|
||||||
|
|
||||||
await makePutBodyRequest({
|
await makePutBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -205,7 +201,7 @@ describe('Test user notifications API validators', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const fields = immutableAssign(correctFields, { newCommentOnMyVideo: 'toto' })
|
const fields = { ...correctFields, newCommentOnMyVideo: 'toto' }
|
||||||
|
|
||||||
await makePutBodyRequest({
|
await makePutBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
|
|
@ -15,7 +15,6 @@ import {
|
||||||
getMyUserVideoRating,
|
getMyUserVideoRating,
|
||||||
getUserScopedTokens,
|
getUserScopedTokens,
|
||||||
getUsersList,
|
getUsersList,
|
||||||
immutableAssign,
|
|
||||||
killallServers,
|
killallServers,
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
|
@ -181,25 +180,25 @@ describe('Test users API validators', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
it('Should fail with a too small username', async function () {
|
it('Should fail with a too small username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: '' })
|
const fields = { ...baseCorrectParams, username: '' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a too long username', async function () {
|
it('Should fail with a too long username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
|
const fields = { ...baseCorrectParams, username: 'super'.repeat(50) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a not lowercase username', async function () {
|
it('Should fail with a not lowercase username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'Toto' })
|
const fields = { ...baseCorrectParams, username: 'Toto' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an incorrect username', async function () {
|
it('Should fail with an incorrect username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'my username' })
|
const fields = { ...baseCorrectParams, username: 'my username' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -211,25 +210,25 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid email', async function () {
|
it('Should fail with an invalid email', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { email: 'test_example.com' })
|
const fields = { ...baseCorrectParams, email: 'test_example.com' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a too small password', async function () {
|
it('Should fail with a too small password', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { password: 'bla' })
|
const fields = { ...baseCorrectParams, password: 'bla' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a too long password', async function () {
|
it('Should fail with a too long password', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) })
|
const fields = { ...baseCorrectParams, password: 'super'.repeat(61) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with empty password and no smtp configured', async function () {
|
it('Should fail with empty password and no smtp configured', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { password: '' })
|
const fields = { ...baseCorrectParams, password: '' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -239,19 +238,23 @@ describe('Test users API validators', function () {
|
||||||
|
|
||||||
await killallServers([ server ])
|
await killallServers([ server ])
|
||||||
|
|
||||||
const config = immutableAssign(overrideConfig, {
|
const config = {
|
||||||
|
...overrideConfig,
|
||||||
|
|
||||||
smtp: {
|
smtp: {
|
||||||
hostname: 'localhost',
|
hostname: 'localhost',
|
||||||
port: emailPort
|
port: emailPort
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
await reRunServer(server, config)
|
await reRunServer(server, config)
|
||||||
|
|
||||||
const fields = immutableAssign(baseCorrectParams, {
|
const fields = {
|
||||||
|
...baseCorrectParams,
|
||||||
|
|
||||||
password: '',
|
password: '',
|
||||||
username: 'create_password',
|
username: 'create_password',
|
||||||
email: 'create_password@example.com'
|
email: 'create_password@example.com'
|
||||||
})
|
}
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -263,7 +266,7 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with invalid admin flags', async function () {
|
it('Should fail with invalid admin flags', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { adminFlags: 'toto' })
|
const fields = { ...baseCorrectParams, adminFlags: 'toto' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -279,7 +282,7 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail if we add a user with the same username', async function () {
|
it('Should fail if we add a user with the same username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'user1' })
|
const fields = { ...baseCorrectParams, username: 'user1' }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -291,7 +294,7 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail if we add a user with the same email', async function () {
|
it('Should fail if we add a user with the same email', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { email: 'user1@example.com' })
|
const fields = { ...baseCorrectParams, email: 'user1@example.com' }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -315,13 +318,13 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid videoQuota', async function () {
|
it('Should fail with an invalid videoQuota', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { videoQuota: -5 })
|
const fields = { ...baseCorrectParams, videoQuota: -5 }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid videoQuotaDaily', async function () {
|
it('Should fail with an invalid videoQuotaDaily', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { videoQuotaDaily: -7 })
|
const fields = { ...baseCorrectParams, videoQuotaDaily: -7 }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -333,13 +336,13 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid user role', async function () {
|
it('Should fail with an invalid user role', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { role: 88989 })
|
const fields = { ...baseCorrectParams, role: 88989 }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a "peertube" username', async function () {
|
it('Should fail with a "peertube" username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
|
const fields = { ...baseCorrectParams, username: 'peertube' }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -352,7 +355,7 @@ describe('Test users API validators', function () {
|
||||||
|
|
||||||
it('Should fail to create a moderator or an admin with a moderator', async function () {
|
it('Should fail to create a moderator or an admin with a moderator', async function () {
|
||||||
for (const role of [ UserRole.MODERATOR, UserRole.ADMINISTRATOR ]) {
|
for (const role of [ UserRole.MODERATOR, UserRole.ADMINISTRATOR ]) {
|
||||||
const fields = immutableAssign(baseCorrectParams, { role })
|
const fields = { ...baseCorrectParams, role }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -365,7 +368,7 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should succeed to create a user with a moderator', async function () {
|
it('Should succeed to create a user with a moderator', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'a4656', email: 'a4656@example.com', role: UserRole.USER })
|
const fields = { ...baseCorrectParams, username: 'a4656', email: 'a4656@example.com', role: UserRole.USER }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -937,19 +940,19 @@ describe('Test users API validators', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
it('Should fail with a too small username', async function () {
|
it('Should fail with a too small username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: '' })
|
const fields = { ...baseCorrectParams, username: '' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a too long username', async function () {
|
it('Should fail with a too long username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
|
const fields = { ...baseCorrectParams, username: 'super'.repeat(50) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an incorrect username', async function () {
|
it('Should fail with an incorrect username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'my username' })
|
const fields = { ...baseCorrectParams, username: 'my username' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -961,25 +964,25 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid email', async function () {
|
it('Should fail with an invalid email', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { email: 'test_example.com' })
|
const fields = { ...baseCorrectParams, email: 'test_example.com' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a too small password', async function () {
|
it('Should fail with a too small password', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { password: 'bla' })
|
const fields = { ...baseCorrectParams, password: 'bla' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a too long password', async function () {
|
it('Should fail with a too long password', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) })
|
const fields = { ...baseCorrectParams, password: 'super'.repeat(61) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail if we register a user with the same username', async function () {
|
it('Should fail if we register a user with the same username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'root' })
|
const fields = { ...baseCorrectParams, username: 'root' }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -991,7 +994,7 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a "peertube" username', async function () {
|
it('Should fail with a "peertube" username', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
|
const fields = { ...baseCorrectParams, username: 'peertube' }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -1003,7 +1006,7 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail if we register a user with the same email', async function () {
|
it('Should fail if we register a user with the same email', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { email: 'admin' + server.internalServerNumber + '@example.com' })
|
const fields = { ...baseCorrectParams, email: 'admin' + server.internalServerNumber + '@example.com' }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -1015,26 +1018,26 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad display name', async function () {
|
it('Should fail with a bad display name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { displayName: 'a'.repeat(150) })
|
const fields = { ...baseCorrectParams, displayName: 'a'.repeat(150) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad channel name', async function () {
|
it('Should fail with a bad channel name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { channel: { name: '[]azf', displayName: 'toto' } })
|
const fields = { ...baseCorrectParams, channel: { name: '[]azf', displayName: 'toto' } }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad channel display name', async function () {
|
it('Should fail with a bad channel display name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { channel: { name: 'toto', displayName: '' } })
|
const fields = { ...baseCorrectParams, channel: { name: 'toto', displayName: '' } }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a channel name that is the same as username', async function () {
|
it('Should fail with a channel name that is the same as username', async function () {
|
||||||
const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } }
|
const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } }
|
||||||
const fields = immutableAssign(baseCorrectParams, source)
|
const fields = { ...baseCorrectParams, ...source }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -1043,7 +1046,7 @@ describe('Test users API validators', function () {
|
||||||
const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
|
const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
|
||||||
await server.channelsCommand.create({ attributes })
|
await server.channelsCommand.create({ attributes })
|
||||||
|
|
||||||
const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } })
|
const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
@ -1055,7 +1058,7 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should succeed with the correct params', async function () {
|
it('Should succeed with the correct params', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { channel: { name: 'super_channel', displayName: 'toto' } })
|
const fields = { ...baseCorrectParams, channel: { name: 'super_channel', displayName: 'toto' } }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
|
|
@ -3,14 +3,16 @@
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { omit } from 'lodash'
|
import { omit } from 'lodash'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
buildAbsoluteFixturePath,
|
buildAbsoluteFixturePath,
|
||||||
ChannelsCommand,
|
ChannelsCommand,
|
||||||
|
checkBadCountPagination,
|
||||||
|
checkBadSortPagination,
|
||||||
|
checkBadStartPagination,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
immutableAssign,
|
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
makePutBodyRequest,
|
makePutBodyRequest,
|
||||||
|
@ -18,13 +20,8 @@ import {
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
userLogin
|
userLogin
|
||||||
} from '../../../../shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import {
|
import { VideoChannelUpdate } from '@shared/models'
|
||||||
checkBadCountPagination,
|
|
||||||
checkBadSortPagination,
|
|
||||||
checkBadStartPagination
|
|
||||||
} from '../../../../shared/extra-utils/requests/check-api-params'
|
|
||||||
import { VideoChannelUpdate } from '../../../../shared/models/videos'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -127,7 +124,7 @@ describe('Test video channels API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad name', async function () {
|
it('Should fail with a bad name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { name: 'super name' })
|
const fields = { ...baseCorrectParams, name: 'super name' }
|
||||||
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -137,17 +134,17 @@ describe('Test video channels API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long name', async function () {
|
it('Should fail with a long name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { displayName: 'super'.repeat(25) })
|
const fields = { ...baseCorrectParams, displayName: 'super'.repeat(25) }
|
||||||
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long description', async function () {
|
it('Should fail with a long description', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(201) })
|
const fields = { ...baseCorrectParams, description: 'super'.repeat(201) }
|
||||||
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long support text', async function () {
|
it('Should fail with a long support text', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
|
const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
|
||||||
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -206,22 +203,22 @@ describe('Test video channels API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long name', async function () {
|
it('Should fail with a long name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { displayName: 'super'.repeat(25) })
|
const fields = { ...baseCorrectParams, displayName: 'super'.repeat(25) }
|
||||||
await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long description', async function () {
|
it('Should fail with a long description', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(201) })
|
const fields = { ...baseCorrectParams, description: 'super'.repeat(201) }
|
||||||
await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long support text', async function () {
|
it('Should fail with a long support text', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
|
const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
|
||||||
await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad bulkVideosSupportUpdate field', async function () {
|
it('Should fail with a bad bulkVideosSupportUpdate field', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { bulkVideosSupportUpdate: 'super' })
|
const fields = { ...baseCorrectParams, bulkVideosSupportUpdate: 'super' }
|
||||||
await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
immutableAssign,
|
|
||||||
ImportsCommand,
|
ImportsCommand,
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePostBodyRequest,
|
makePostBodyRequest,
|
||||||
|
@ -108,43 +107,43 @@ describe('Test video imports API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad target url', async function () {
|
it('Should fail with a bad target url', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { targetUrl: 'htt://hello' })
|
const fields = { ...baseCorrectParams, targetUrl: 'htt://hello' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long name', async function () {
|
it('Should fail with a long name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
|
const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad category', async function () {
|
it('Should fail with a bad category', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { category: 125 })
|
const fields = { ...baseCorrectParams, category: 125 }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad licence', async function () {
|
it('Should fail with a bad licence', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { licence: 125 })
|
const fields = { ...baseCorrectParams, licence: 125 }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad language', async function () {
|
it('Should fail with a bad language', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) })
|
const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long description', async function () {
|
it('Should fail with a long description', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
|
const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long support text', async function () {
|
it('Should fail with a long support text', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
|
const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -156,7 +155,7 @@ describe('Test video imports API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad channel', async function () {
|
it('Should fail with a bad channel', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
|
const fields = { ...baseCorrectParams, channelId: 545454 }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -172,25 +171,25 @@ describe('Test video imports API validator', function () {
|
||||||
const res = await getMyUserInformation(server.url, accessTokenUser)
|
const res = await getMyUserInformation(server.url, accessTokenUser)
|
||||||
const customChannelId = res.body.videoChannels[0].id
|
const customChannelId = res.body.videoChannels[0].id
|
||||||
|
|
||||||
const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId })
|
const fields = { ...baseCorrectParams, channelId: customChannelId }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with too many tags', async function () {
|
it('Should fail with too many tags', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a tag length too low', async function () {
|
it('Should fail with a tag length too low', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a tag length too big', async function () {
|
it('Should fail with a tag length too big', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -242,7 +241,7 @@ describe('Test video imports API validator', function () {
|
||||||
|
|
||||||
it('Should fail with an invalid magnet URI', async function () {
|
it('Should fail with an invalid magnet URI', async function () {
|
||||||
let fields = omit(baseCorrectParams, 'targetUrl')
|
let fields = omit(baseCorrectParams, 'targetUrl')
|
||||||
fields = immutableAssign(fields, { magnetUri: 'blabla' })
|
fields = { ...fields, magnetUri: 'blabla' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -301,7 +300,7 @@ describe('Test video imports API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
let fields = omit(baseCorrectParams, 'targetUrl')
|
let fields = omit(baseCorrectParams, 'targetUrl')
|
||||||
fields = immutableAssign(fields, { magnetUri: ImportsCommand.getMagnetURI() })
|
fields = { ...fields, magnetUri: ImportsCommand.getMagnetURI() }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
VideoPlaylistCreate,
|
VideoPlaylistCreate,
|
||||||
VideoPlaylistCreateResult,
|
VideoPlaylistCreateResult,
|
||||||
|
@ -10,7 +11,6 @@ import {
|
||||||
VideoPlaylistReorder,
|
VideoPlaylistReorder,
|
||||||
VideoPlaylistType
|
VideoPlaylistType
|
||||||
} from '@shared/models'
|
} from '@shared/models'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
import {
|
import {
|
||||||
checkBadCountPagination,
|
checkBadCountPagination,
|
||||||
checkBadSortPagination,
|
checkBadSortPagination,
|
||||||
|
@ -18,7 +18,6 @@ import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
generateUserAccessToken,
|
generateUserAccessToken,
|
||||||
immutableAssign,
|
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
PlaylistsCommand,
|
PlaylistsCommand,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
@ -214,7 +213,7 @@ describe('Test video playlists API validator', function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const getUpdate = (params: any, playlistId: number | string) => {
|
const getUpdate = (params: any, playlistId: number | string) => {
|
||||||
return immutableAssign(params, { playlistId: playlistId })
|
return { ...params, playlistId: playlistId }
|
||||||
}
|
}
|
||||||
|
|
||||||
it('Should fail with an unauthenticated user', async function () {
|
it('Should fail with an unauthenticated user', async function () {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import {
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
immutableAssign,
|
|
||||||
makeDeleteRequest,
|
makeDeleteRequest,
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
makePutBodyRequest,
|
makePutBodyRequest,
|
||||||
|
@ -225,42 +224,42 @@ describe('Test videos API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long name', async function () {
|
it('Should fail with a long name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
|
const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad category', async function () {
|
it('Should fail with a bad category', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { category: 125 })
|
const fields = { ...baseCorrectParams, category: 125 }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad licence', async function () {
|
it('Should fail with a bad licence', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { licence: 125 })
|
const fields = { ...baseCorrectParams, licence: 125 }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad language', async function () {
|
it('Should fail with a bad language', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) })
|
const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long description', async function () {
|
it('Should fail with a long description', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
|
const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long support text', async function () {
|
it('Should fail with a long support text', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
|
const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
|
@ -274,7 +273,7 @@ describe('Test videos API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad channel', async function () {
|
it('Should fail with a bad channel', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
|
const fields = { ...baseCorrectParams, channelId: 545454 }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
|
@ -291,54 +290,56 @@ describe('Test videos API validator', function () {
|
||||||
const res = await getMyUserInformation(server.url, accessTokenUser)
|
const res = await getMyUserInformation(server.url, accessTokenUser)
|
||||||
const customChannelId = res.body.videoChannels[0].id
|
const customChannelId = res.body.videoChannels[0].id
|
||||||
|
|
||||||
const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId })
|
const fields = { ...baseCorrectParams, channelId: customChannelId }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with too many tags', async function () {
|
it('Should fail with too many tags', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a tag length too low', async function () {
|
it('Should fail with a tag length too low', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a tag length too big', async function () {
|
it('Should fail with a tag length too big', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad schedule update (miss updateAt)', async function () {
|
it('Should fail with a bad schedule update (miss updateAt)', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } })
|
const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad schedule update (wrong updateAt)', async function () {
|
it('Should fail with a bad schedule update (wrong updateAt)', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, {
|
const fields = {
|
||||||
|
...baseCorrectParams,
|
||||||
|
|
||||||
scheduleUpdate: {
|
scheduleUpdate: {
|
||||||
privacy: VideoPrivacy.PUBLIC,
|
privacy: VideoPrivacy.PUBLIC,
|
||||||
updateAt: 'toto'
|
updateAt: 'toto'
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad originally published at attribute', async function () {
|
it('Should fail with a bad originally published at attribute', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' })
|
const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
|
@ -413,7 +414,7 @@ describe('Test videos API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should report the appropriate error', async function () {
|
it('Should report the appropriate error', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) })
|
const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
const attributes = { ...fields, ...attaches }
|
const attributes = { ...fields, ...attaches }
|
||||||
|
@ -448,17 +449,21 @@ describe('Test videos API validator', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const attaches = immutableAssign(baseCorrectAttaches, {
|
const attaches = {
|
||||||
|
...baseCorrectAttaches,
|
||||||
|
|
||||||
videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
|
videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
|
||||||
})
|
}
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const attaches = immutableAssign(baseCorrectAttaches, {
|
const attaches = {
|
||||||
|
...baseCorrectAttaches,
|
||||||
|
|
||||||
videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
|
videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
|
||||||
})
|
}
|
||||||
|
|
||||||
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
|
await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode)
|
||||||
}
|
}
|
||||||
|
@ -516,79 +521,79 @@ describe('Test videos API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long name', async function () {
|
it('Should fail with a long name', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
|
const fields = { ...baseCorrectParams, name: 'super'.repeat(65) }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad category', async function () {
|
it('Should fail with a bad category', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { category: 125 })
|
const fields = { ...baseCorrectParams, category: 125 }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad licence', async function () {
|
it('Should fail with a bad licence', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { licence: 125 })
|
const fields = { ...baseCorrectParams, licence: 125 }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad language', async function () {
|
it('Should fail with a bad language', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) })
|
const fields = { ...baseCorrectParams, language: 'a'.repeat(15) }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long description', async function () {
|
it('Should fail with a long description', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
|
const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a long support text', async function () {
|
it('Should fail with a long support text', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
|
const fields = { ...baseCorrectParams, support: 'super'.repeat(201) }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad channel', async function () {
|
it('Should fail with a bad channel', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
|
const fields = { ...baseCorrectParams, channelId: 545454 }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with too many tags', async function () {
|
it('Should fail with too many tags', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a tag length too low', async function () {
|
it('Should fail with a tag length too low', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a tag length too big', async function () {
|
it('Should fail with a tag length too big', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
|
const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad schedule update (miss updateAt)', async function () {
|
it('Should fail with a bad schedule update (miss updateAt)', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } })
|
const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad schedule update (wrong updateAt)', async function () {
|
it('Should fail with a bad schedule update (wrong updateAt)', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } })
|
const fields = { ...baseCorrectParams, scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a bad originally published at param', async function () {
|
it('Should fail with a bad originally published at param', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' })
|
const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' }
|
||||||
|
|
||||||
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -672,7 +677,7 @@ describe('Test videos API validator', function () {
|
||||||
it('Should fail with a video of another server')
|
it('Should fail with a video of another server')
|
||||||
|
|
||||||
it('Shoud report the appropriate error', async function () {
|
it('Shoud report the appropriate error', async function () {
|
||||||
const fields = immutableAssign(baseCorrectParams, { licence: 125 })
|
const fields = { ...baseCorrectParams, licence: 125 }
|
||||||
|
|
||||||
const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
|
||||||
const error = res.body as PeerTubeProblemDocument
|
const error = res.body as PeerTubeProblemDocument
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-
|
||||||
import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
|
import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
import {
|
import {
|
||||||
buildServerDirectory,
|
|
||||||
checkLiveCleanup,
|
checkLiveCleanup,
|
||||||
checkLiveSegmentHash,
|
checkLiveSegmentHash,
|
||||||
checkResolutionsInMasterPlaylist,
|
checkResolutionsInMasterPlaylist,
|
||||||
|
@ -532,7 +531,7 @@ describe('Test live', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
const filename = `${video.uuid}-${resolution}-fragmented.mp4`
|
const filename = `${video.uuid}-${resolution}-fragmented.mp4`
|
||||||
const segmentPath = buildServerDirectory(servers[0], join('streaming-playlists', 'hls', video.uuid, filename))
|
const segmentPath = servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
|
||||||
|
|
||||||
const probe = await ffprobePromise(segmentPath)
|
const probe = await ffprobePromise(segmentPath)
|
||||||
const videoStream = await getVideoStreamFromFile(segmentPath, probe)
|
const videoStream = await getVideoStreamFromFile(segmentPath, probe)
|
||||||
|
|
|
@ -20,7 +20,6 @@ import {
|
||||||
createUser,
|
createUser,
|
||||||
generateUserAccessToken,
|
generateUserAccessToken,
|
||||||
getVideoIdFromUUID,
|
getVideoIdFromUUID,
|
||||||
immutableAssign,
|
|
||||||
MockInstancesIndex,
|
MockInstancesIndex,
|
||||||
MockSmtpServer,
|
MockSmtpServer,
|
||||||
prepareNotificationsTest,
|
prepareNotificationsTest,
|
||||||
|
@ -347,7 +346,7 @@ describe('Test moderation notifications', function () {
|
||||||
await checkUserRegistered(baseParams, 'user_45', 'presence')
|
await checkUserRegistered(baseParams, 'user_45', 'presence')
|
||||||
|
|
||||||
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
|
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
|
||||||
await checkUserRegistered(immutableAssign(baseParams, userOverride), 'user_45', 'absence')
|
await checkUserRegistered({ ...baseParams, ...userOverride }, 'user_45', 'absence')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -389,7 +388,7 @@ describe('Test moderation notifications', function () {
|
||||||
await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence')
|
await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence')
|
||||||
|
|
||||||
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
|
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
|
||||||
await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:' + servers[2].port, 'absence')
|
await checkNewInstanceFollower({ ...baseParams, ...userOverride }, 'localhost:' + servers[2].port, 'absence')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should send a notification on auto follow back', async function () {
|
it('Should send a notification on auto follow back', async function () {
|
||||||
|
@ -416,7 +415,7 @@ describe('Test moderation notifications', function () {
|
||||||
await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
|
await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
|
||||||
|
|
||||||
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
|
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
|
||||||
await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence')
|
await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence')
|
||||||
|
|
||||||
config.followings.instance.autoFollowBack.enabled = false
|
config.followings.instance.autoFollowBack.enabled = false
|
||||||
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
|
await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
|
||||||
|
@ -476,7 +475,9 @@ describe('Test moderation notifications', function () {
|
||||||
|
|
||||||
currentCustomConfig = await servers[0].configCommand.getCustomConfig()
|
currentCustomConfig = await servers[0].configCommand.getCustomConfig()
|
||||||
|
|
||||||
const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, {
|
const autoBlacklistTestsCustomConfig = {
|
||||||
|
...currentCustomConfig,
|
||||||
|
|
||||||
autoBlacklist: {
|
autoBlacklist: {
|
||||||
videos: {
|
videos: {
|
||||||
ofUsers: {
|
ofUsers: {
|
||||||
|
@ -484,7 +485,7 @@ describe('Test moderation notifications', function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
// enable transcoding otherwise own publish notification after transcoding not expected
|
// enable transcoding otherwise own publish notification after transcoding not expected
|
||||||
autoBlacklistTestsCustomConfig.transcoding.enabled = true
|
autoBlacklistTestsCustomConfig.transcoding.enabled = true
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
getAllNotificationsSettings,
|
getAllNotificationsSettings,
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
immutableAssign,
|
|
||||||
MockSmtpServer,
|
MockSmtpServer,
|
||||||
prepareNotificationsTest,
|
prepareNotificationsTest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
@ -118,7 +117,7 @@ describe('Test notifications API', function () {
|
||||||
const { name, uuid } = await uploadRandomVideo(server)
|
const { name, uuid } = await uploadRandomVideo(server)
|
||||||
|
|
||||||
const check = { web: true, mail: true }
|
const check = { web: true, mail: true }
|
||||||
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence')
|
await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should only have web notifications', async function () {
|
it('Should only have web notifications', async function () {
|
||||||
|
@ -139,12 +138,12 @@ describe('Test notifications API', function () {
|
||||||
|
|
||||||
{
|
{
|
||||||
const check = { mail: true, web: false }
|
const check = { mail: true, web: false }
|
||||||
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence')
|
await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence')
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const check = { mail: false, web: true }
|
const check = { mail: false, web: true }
|
||||||
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence')
|
await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -166,12 +165,12 @@ describe('Test notifications API', function () {
|
||||||
|
|
||||||
{
|
{
|
||||||
const check = { mail: false, web: true }
|
const check = { mail: false, web: true }
|
||||||
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence')
|
await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence')
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const check = { mail: true, web: false }
|
const check = { mail: true, web: false }
|
||||||
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence')
|
await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,7 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
waitJobs,
|
waitJobs
|
||||||
waitUntilLog
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models'
|
import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models'
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ describe('Test manage videos redundancy', function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await waitUntilLog(servers[0], 'Duplicated ', 10)
|
await servers[0].serversCommand.waitUntilLog('Duplicated ', 10)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
const body = await commands[1].listVideos({ target: 'remote-videos' })
|
const body = await commands[1].listVideos({ target: 'remote-videos' })
|
||||||
|
@ -214,7 +213,7 @@ describe('Test manage videos redundancy', function () {
|
||||||
await commands[0].addVideo({ videoId })
|
await commands[0].addVideo({ videoId })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await waitUntilLog(servers[0], 'Duplicated ', 15)
|
await servers[0].serversCommand.waitUntilLog('Duplicated ', 15)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,8 +11,7 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
waitJobs,
|
waitJobs
|
||||||
waitUntilLog
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { VideoPrivacy } from '@shared/models'
|
import { VideoPrivacy } from '@shared/models'
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ describe('Test redundancy constraints', function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await waitUntilLog(remoteServer, 'Duplicated ', 5)
|
await remoteServer.serversCommand.waitUntilLog('Duplicated ', 5)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -126,7 +125,7 @@ describe('Test redundancy constraints', function () {
|
||||||
|
|
||||||
await uploadWrapper('video 2 server 2')
|
await uploadWrapper('video 2 server 2')
|
||||||
|
|
||||||
await waitUntilLog(remoteServer, 'Duplicated ', 10)
|
await remoteServer.serversCommand.waitUntilLog('Duplicated ', 10)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -155,7 +154,7 @@ describe('Test redundancy constraints', function () {
|
||||||
|
|
||||||
await uploadWrapper('video 3 server 2')
|
await uploadWrapper('video 3 server 2')
|
||||||
|
|
||||||
await waitUntilLog(remoteServer, 'Duplicated ', 15)
|
await remoteServer.serversCommand.waitUntilLog('Duplicated ', 15)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -176,7 +175,7 @@ describe('Test redundancy constraints', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await uploadWrapper('video 4 server 2')
|
await uploadWrapper('video 4 server 2')
|
||||||
await waitUntilLog(remoteServer, 'Duplicated ', 20)
|
await remoteServer.serversCommand.waitUntilLog('Duplicated ', 20)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,6 @@ import {
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideoWithToken,
|
getVideoWithToken,
|
||||||
immutableAssign,
|
|
||||||
killallServers,
|
killallServers,
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
removeVideo,
|
removeVideo,
|
||||||
|
@ -26,8 +25,7 @@ import {
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
viewVideo,
|
viewVideo,
|
||||||
wait,
|
wait,
|
||||||
waitJobs,
|
waitJobs
|
||||||
waitUntilLog
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { VideoDetails, VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models'
|
import { VideoDetails, VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models'
|
||||||
|
|
||||||
|
@ -53,11 +51,13 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add
|
||||||
|
|
||||||
if (strategy !== null) {
|
if (strategy !== null) {
|
||||||
strategies.push(
|
strategies.push(
|
||||||
immutableAssign({
|
{
|
||||||
min_lifetime: '1 hour',
|
min_lifetime: '1 hour',
|
||||||
strategy: strategy,
|
strategy: strategy,
|
||||||
size: '400KB'
|
size: '400KB',
|
||||||
}, additionalParams)
|
|
||||||
|
...additionalParams
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ describe('Test videos redundancy', function () {
|
||||||
this.timeout(80000)
|
this.timeout(80000)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await waitUntilLog(servers[0], 'Duplicated ', 5)
|
await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check2Webseeds()
|
await check2Webseeds()
|
||||||
|
@ -335,7 +335,7 @@ describe('Test videos redundancy', function () {
|
||||||
await check1WebSeed()
|
await check1WebSeed()
|
||||||
await check0PlaylistRedundancies()
|
await check0PlaylistRedundancies()
|
||||||
|
|
||||||
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].internalServerNumber, [ 'videos', join('playlists', 'hls') ])
|
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ 'videos', join('playlists', 'hls') ])
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
@ -366,7 +366,7 @@ describe('Test videos redundancy', function () {
|
||||||
this.timeout(80000)
|
this.timeout(80000)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await waitUntilLog(servers[0], 'Duplicated ', 5)
|
await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check2Webseeds()
|
await check2Webseeds()
|
||||||
|
@ -385,7 +385,7 @@ describe('Test videos redundancy', function () {
|
||||||
await check1WebSeed()
|
await check1WebSeed()
|
||||||
await check0PlaylistRedundancies()
|
await check0PlaylistRedundancies()
|
||||||
|
|
||||||
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].internalServerNumber, [ 'videos' ])
|
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ 'videos' ])
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
@ -438,7 +438,7 @@ describe('Test videos redundancy', function () {
|
||||||
this.timeout(80000)
|
this.timeout(80000)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await waitUntilLog(servers[0], 'Duplicated ', 5)
|
await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check2Webseeds()
|
await check2Webseeds()
|
||||||
|
@ -454,7 +454,7 @@ describe('Test videos redundancy', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber)
|
await checkVideoFilesWereRemoved(video1Server2UUID, server)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ describe('Test videos redundancy', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await waitUntilLog(servers[0], 'Duplicated ', 1)
|
await servers[0].serversCommand.waitUntilLog('Duplicated ', 1)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check1PlaylistRedundancies()
|
await check1PlaylistRedundancies()
|
||||||
|
@ -517,7 +517,7 @@ describe('Test videos redundancy', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber)
|
await checkVideoFilesWereRemoved(video1Server2UUID, server)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -547,7 +547,7 @@ describe('Test videos redundancy', function () {
|
||||||
this.timeout(80000)
|
this.timeout(80000)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await waitUntilLog(servers[0], 'Duplicated ', 5)
|
await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check2Webseeds()
|
await check2Webseeds()
|
||||||
|
@ -575,7 +575,7 @@ describe('Test videos redundancy', function () {
|
||||||
await check1WebSeed()
|
await check1WebSeed()
|
||||||
await check0PlaylistRedundancies()
|
await check0PlaylistRedundancies()
|
||||||
|
|
||||||
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ])
|
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ 'videos' ])
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
@ -658,7 +658,7 @@ describe('Test videos redundancy', function () {
|
||||||
await enableRedundancyOnServer1()
|
await enableRedundancyOnServer1()
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await waitUntilLog(servers[0], 'Duplicated ', 5)
|
await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check2Webseeds(video1Server2UUID)
|
await check2Webseeds(video1Server2UUID)
|
||||||
|
@ -715,7 +715,7 @@ describe('Test videos redundancy', function () {
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].internalServerNumber, [ join('redundancy', 'hls') ])
|
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0], [ join('redundancy', 'hls') ])
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
|
|
@ -2,16 +2,8 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import {
|
import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers, uploadVideo } from '@shared/extra-utils'
|
||||||
cleanupTests,
|
import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
|
||||||
flushAndRunServer,
|
|
||||||
immutableAssign,
|
|
||||||
SearchCommand,
|
|
||||||
ServerInfo,
|
|
||||||
setAccessTokensToServers,
|
|
||||||
uploadVideo
|
|
||||||
} from '@shared/extra-utils'
|
|
||||||
import { VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -174,32 +166,32 @@ describe('Test videos search', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const search = immutableAssign(baseSearch, { startDate: '2018-10-01T10:54:46.396Z' })
|
const search = { ...baseSearch, startDate: '2018-10-01T10:54:46.396Z' }
|
||||||
await check(search, false)
|
await check(search, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const search = immutableAssign(baseSearch, { tagsAllOf: [ 'toto', 'framasoft' ] })
|
const search = { ...baseSearch, tagsAllOf: [ 'toto', 'framasoft' ] }
|
||||||
await check(search, false)
|
await check(search, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const search = immutableAssign(baseSearch, { durationMin: 2000 })
|
const search = { ...baseSearch, durationMin: 2000 }
|
||||||
await check(search, false)
|
await check(search, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const search = immutableAssign(baseSearch, { nsfw: 'true' })
|
const search = { ...baseSearch, nsfw: 'true' as BooleanBothQuery }
|
||||||
await check(search, false)
|
await check(search, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const search = immutableAssign(baseSearch, { nsfw: 'false' })
|
const search = { ...baseSearch, nsfw: 'false' as BooleanBothQuery }
|
||||||
await check(search, true)
|
await check(search, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const search = immutableAssign(baseSearch, { nsfw: 'both' })
|
const search = { ...baseSearch, nsfw: 'both' as BooleanBothQuery }
|
||||||
await check(search, true)
|
await check(search, true)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,7 +5,6 @@ import * as chai from 'chai'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
immutableAssign,
|
|
||||||
SearchCommand,
|
SearchCommand,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
|
@ -44,11 +43,11 @@ describe('Test videos search', function () {
|
||||||
}
|
}
|
||||||
await uploadVideo(server.url, server.accessToken, attributes1)
|
await uploadVideo(server.url, server.accessToken, attributes1)
|
||||||
|
|
||||||
const attributes2 = immutableAssign(attributes1, { name: attributes1.name + ' - 2', fixture: 'video_short.mp4' })
|
const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }
|
||||||
await uploadVideo(server.url, server.accessToken, attributes2)
|
await uploadVideo(server.url, server.accessToken, attributes2)
|
||||||
|
|
||||||
{
|
{
|
||||||
const attributes3 = immutableAssign(attributes1, { name: attributes1.name + ' - 3', language: undefined })
|
const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined }
|
||||||
const res = await uploadVideo(server.url, server.accessToken, attributes3)
|
const res = await uploadVideo(server.url, server.accessToken, attributes3)
|
||||||
const videoId = res.body.video.id
|
const videoId = res.body.video.id
|
||||||
videoUUID = res.body.video.uuid
|
videoUUID = res.body.video.uuid
|
||||||
|
@ -68,26 +67,23 @@ describe('Test videos search', function () {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const attributes4 = immutableAssign(attributes1, { name: attributes1.name + ' - 4', language: 'pl', nsfw: true })
|
const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true }
|
||||||
await uploadVideo(server.url, server.accessToken, attributes4)
|
await uploadVideo(server.url, server.accessToken, attributes4)
|
||||||
|
|
||||||
await wait(1000)
|
await wait(1000)
|
||||||
|
|
||||||
startDate = new Date().toISOString()
|
startDate = new Date().toISOString()
|
||||||
|
|
||||||
const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2, language: undefined })
|
const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined }
|
||||||
await uploadVideo(server.url, server.accessToken, attributes5)
|
await uploadVideo(server.url, server.accessToken, attributes5)
|
||||||
|
|
||||||
const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] })
|
const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }
|
||||||
await uploadVideo(server.url, server.accessToken, attributes6)
|
await uploadVideo(server.url, server.accessToken, attributes6)
|
||||||
|
|
||||||
const attributes7 = immutableAssign(attributes1, {
|
const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' }
|
||||||
name: attributes1.name + ' - 7',
|
|
||||||
originallyPublishedAt: '2019-02-12T09:58:08.286Z'
|
|
||||||
})
|
|
||||||
await uploadVideo(server.url, server.accessToken, attributes7)
|
await uploadVideo(server.url, server.accessToken, attributes7)
|
||||||
|
|
||||||
const attributes8 = immutableAssign(attributes1, { name: attributes1.name + ' - 8', licence: 4 })
|
const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 }
|
||||||
await uploadVideo(server.url, server.accessToken, attributes8)
|
await uploadVideo(server.url, server.accessToken, attributes8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +97,7 @@ describe('Test videos search', function () {
|
||||||
}
|
}
|
||||||
await uploadVideo(server.url, server.accessToken, attributes)
|
await uploadVideo(server.url, server.accessToken, attributes)
|
||||||
|
|
||||||
await uploadVideo(server.url, server.accessToken, immutableAssign(attributes, { name: attributes.name + ' duplicate' }))
|
await uploadVideo(server.url, server.accessToken, { ...attributes, name: attributes.name + ' duplicate' })
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -122,10 +118,10 @@ describe('Test videos search', function () {
|
||||||
category: 1
|
category: 1
|
||||||
}
|
}
|
||||||
await uploadVideo(server.url, server.accessToken, attributes1)
|
await uploadVideo(server.url, server.accessToken, attributes1)
|
||||||
await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 }))
|
await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 })
|
||||||
|
|
||||||
await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'cccc', 'dddd' ] }))
|
await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'cccc', 'dddd' ] })
|
||||||
await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'eeee', 'ffff' ] }))
|
await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'eeee', 'ffff' ] })
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -134,7 +130,7 @@ describe('Test videos search', function () {
|
||||||
category: 1
|
category: 1
|
||||||
}
|
}
|
||||||
await uploadVideo(server.url, server.accessToken, attributes1)
|
await uploadVideo(server.url, server.accessToken, attributes1)
|
||||||
await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 }))
|
await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 })
|
||||||
}
|
}
|
||||||
|
|
||||||
command = server.searchCommand
|
command = server.searchCommand
|
||||||
|
@ -414,7 +410,7 @@ describe('Test videos search', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' })
|
const query = { ...baseQuery, originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }
|
||||||
const body = await command.advancedVideoSearch({ search: query })
|
const body = await command.advancedVideoSearch({ search: query })
|
||||||
|
|
||||||
expect(body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
|
@ -422,7 +418,7 @@ describe('Test videos search', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' })
|
const query = { ...baseQuery, originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }
|
||||||
const body = await command.advancedVideoSearch({ search: query })
|
const body = await command.advancedVideoSearch({ search: query })
|
||||||
|
|
||||||
expect(body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
|
@ -430,34 +426,36 @@ describe('Test videos search', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' })
|
const query = { ...baseQuery, originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }
|
||||||
const body = await command.advancedVideoSearch({ search: query })
|
const body = await command.advancedVideoSearch({ search: query })
|
||||||
|
|
||||||
expect(body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' })
|
const query = { ...baseQuery, originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }
|
||||||
const body = await command.advancedVideoSearch({ search: query })
|
const body = await command.advancedVideoSearch({ search: query })
|
||||||
|
|
||||||
expect(body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const query = immutableAssign(baseQuery, {
|
const query = {
|
||||||
|
...baseQuery,
|
||||||
originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
|
originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
|
||||||
originallyPublishedEndDate: '2019-01-10T09:58:08.286Z'
|
originallyPublishedEndDate: '2019-01-10T09:58:08.286Z'
|
||||||
})
|
}
|
||||||
const body = await command.advancedVideoSearch({ search: query })
|
const body = await command.advancedVideoSearch({ search: query })
|
||||||
|
|
||||||
expect(body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const query = immutableAssign(baseQuery, {
|
const query = {
|
||||||
|
...baseQuery,
|
||||||
originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
|
originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
|
||||||
originallyPublishedEndDate: '2019-04-11T09:58:08.286Z'
|
originallyPublishedEndDate: '2019-04-11T09:58:08.286Z'
|
||||||
})
|
}
|
||||||
const body = await command.advancedVideoSearch({ search: query })
|
const body = await command.advancedVideoSearch({ search: query })
|
||||||
|
|
||||||
expect(body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
immutableAssign,
|
|
||||||
killallServers,
|
killallServers,
|
||||||
reRunServer,
|
reRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
@ -50,9 +49,7 @@ describe('Test handle downs', function () {
|
||||||
fixture: 'video_short1.webm'
|
fixture: 'video_short1.webm'
|
||||||
}
|
}
|
||||||
|
|
||||||
const unlistedVideoAttributes = immutableAssign(videoAttributes, {
|
const unlistedVideoAttributes = { ...videoAttributes, privacy: VideoPrivacy.UNLISTED }
|
||||||
privacy: VideoPrivacy.UNLISTED
|
|
||||||
})
|
|
||||||
|
|
||||||
let checkAttributes: any
|
let checkAttributes: any
|
||||||
let unlistedCheckAttributes: any
|
let unlistedCheckAttributes: any
|
||||||
|
@ -97,9 +94,7 @@ describe('Test handle downs', function () {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
unlistedCheckAttributes = immutableAssign(checkAttributes, {
|
unlistedCheckAttributes = { ...checkAttributes, privacy: VideoPrivacy.UNLISTED }
|
||||||
privacy: VideoPrivacy.UNLISTED
|
|
||||||
})
|
|
||||||
|
|
||||||
// Get the access tokens
|
// Get the access tokens
|
||||||
await setAccessTokensToServers(servers)
|
await setAccessTokensToServers(servers)
|
||||||
|
|
|
@ -7,7 +7,6 @@ import {
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
killallServers,
|
killallServers,
|
||||||
LogsCommand,
|
LogsCommand,
|
||||||
makePingRequest,
|
|
||||||
reRunServer,
|
reRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
|
@ -102,7 +101,7 @@ describe('Test logs', function () {
|
||||||
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
|
|
||||||
await makePingRequest(server)
|
await server.serversCommand.ping()
|
||||||
|
|
||||||
const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
|
const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
|
||||||
const logsString = JSON.stringify(body)
|
const logsString = JSON.stringify(body)
|
||||||
|
@ -119,7 +118,7 @@ describe('Test logs', function () {
|
||||||
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
|
|
||||||
await makePingRequest(server)
|
await server.serversCommand.ping()
|
||||||
|
|
||||||
const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
|
const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
|
||||||
const logsString = JSON.stringify(body)
|
const logsString = JSON.stringify(body)
|
||||||
|
|
|
@ -14,8 +14,7 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
testHelloWorldRegisteredSettings,
|
testHelloWorldRegisteredSettings,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
wait,
|
wait
|
||||||
waitUntilLog
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { PluginType, User } from '@shared/models'
|
import { PluginType, User } from '@shared/models'
|
||||||
|
|
||||||
|
@ -194,7 +193,7 @@ describe('Test plugins', function () {
|
||||||
it('Should have watched settings changes', async function () {
|
it('Should have watched settings changes', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await waitUntilLog(server, 'Settings changed!')
|
await server.serversCommand.waitUntilLog('Settings changed!')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should get a plugin and a theme', async function () {
|
it('Should get a plugin and a theme', async function () {
|
||||||
|
|
|
@ -227,7 +227,7 @@ describe('Test users with multiple servers', function () {
|
||||||
|
|
||||||
it('Should not have video files', async () => {
|
it('Should not have video files', async () => {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await checkVideoFilesWereRemoved(videoUUID, server.internalServerNumber)
|
await checkVideoFilesWereRemoved(videoUUID, server)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import * as chai from 'chai'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
|
import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
|
||||||
import {
|
import {
|
||||||
buildServerDirectory,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
|
@ -81,8 +80,8 @@ describe('Test audio only video transcoding', function () {
|
||||||
|
|
||||||
it('0p transcoded video should not have video', async function () {
|
it('0p transcoded video should not have video', async function () {
|
||||||
const paths = [
|
const paths = [
|
||||||
buildServerDirectory(servers[0], join('videos', videoUUID + '-0.mp4')),
|
servers[0].serversCommand.buildDirectory(join('videos', videoUUID + '-0.mp4')),
|
||||||
buildServerDirectory(servers[0], join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
|
servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const path of paths) {
|
for (const path of paths) {
|
||||||
|
|
|
@ -689,8 +689,8 @@ describe('Test multiple servers', function () {
|
||||||
|
|
||||||
it('Should not have files of videos 3 and 3-2 on each server', async function () {
|
it('Should not have files of videos 3 and 3-2 on each server', async function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await checkVideoFilesWereRemoved(toRemove[0].uuid, server.internalServerNumber)
|
await checkVideoFilesWereRemoved(toRemove[0].uuid, server)
|
||||||
await checkVideoFilesWereRemoved(toRemove[1].uuid, server.internalServerNumber)
|
await checkVideoFilesWereRemoved(toRemove[1].uuid, server)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { join } from 'path'
|
||||||
import { HttpStatusCode } from '@shared/core-utils'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
buildAbsoluteFixturePath,
|
buildAbsoluteFixturePath,
|
||||||
buildServerDirectory,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
|
@ -82,7 +81,7 @@ describe('Test resumable upload', function () {
|
||||||
const uploadId = uploadIdArg.replace(/^upload_id=/, '')
|
const uploadId = uploadIdArg.replace(/^upload_id=/, '')
|
||||||
|
|
||||||
const subPath = join('tmp', 'resumable-uploads', uploadId)
|
const subPath = join('tmp', 'resumable-uploads', uploadId)
|
||||||
const filePath = buildServerDirectory(server, subPath)
|
const filePath = server.serversCommand.buildDirectory(subPath)
|
||||||
const exists = await pathExists(filePath)
|
const exists = await pathExists(filePath)
|
||||||
|
|
||||||
if (expectedSize === null) {
|
if (expectedSize === null) {
|
||||||
|
@ -97,7 +96,7 @@ describe('Test resumable upload', function () {
|
||||||
|
|
||||||
async function countResumableUploads () {
|
async function countResumableUploads () {
|
||||||
const subPath = join('tmp', 'resumable-uploads')
|
const subPath = join('tmp', 'resumable-uploads')
|
||||||
const filePath = buildServerDirectory(server, subPath)
|
const filePath = server.serversCommand.buildDirectory(subPath)
|
||||||
|
|
||||||
const files = await readdir(filePath)
|
const files = await readdir(filePath)
|
||||||
return files.length
|
return files.length
|
||||||
|
|
|
@ -230,7 +230,7 @@ describe('Test a single server', function () {
|
||||||
it('Should remove the video', async function () {
|
it('Should remove the video', async function () {
|
||||||
await removeVideo(server.url, server.accessToken, videoId)
|
await removeVideo(server.url, server.accessToken, videoId)
|
||||||
|
|
||||||
await checkVideoFilesWereRemoved(videoUUID, 1)
|
await checkVideoFilesWereRemoved(videoUUID, server)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not have videos', async function () {
|
it('Should not have videos', async function () {
|
||||||
|
|
|
@ -182,7 +182,7 @@ describe('Test video captions', function () {
|
||||||
it('Should remove the video, and thus all video captions', async function () {
|
it('Should remove the video, and thus all video captions', async function () {
|
||||||
await removeVideo(servers[0].url, servers[0].accessToken, videoUUID)
|
await removeVideo(servers[0].url, servers[0].accessToken, videoUUID)
|
||||||
|
|
||||||
await checkVideoFilesWereRemoved(videoUUID, 1)
|
await checkVideoFilesWereRemoved(videoUUID, servers[0])
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
getMyVideos,
|
getMyVideos,
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
immutableAssign,
|
|
||||||
ImportsCommand,
|
ImportsCommand,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
|
@ -119,7 +118,7 @@ describe('Test video imports', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const attributes = immutableAssign(baseAttributes, { targetUrl: ImportsCommand.getYoutubeVideoUrl() })
|
const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() }
|
||||||
const { video } = await servers[0].importsCommand.importVideo({ attributes })
|
const { video } = await servers[0].importsCommand.importVideo({ attributes })
|
||||||
expect(video.name).to.equal('small video - youtube')
|
expect(video.name).to.equal('small video - youtube')
|
||||||
|
|
||||||
|
@ -169,21 +168,23 @@ Ajouter un sous-titre est vraiment facile`)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const attributes = immutableAssign(baseAttributes, {
|
const attributes = {
|
||||||
|
...baseAttributes,
|
||||||
magnetUri: ImportsCommand.getMagnetURI(),
|
magnetUri: ImportsCommand.getMagnetURI(),
|
||||||
description: 'this is a super torrent description',
|
description: 'this is a super torrent description',
|
||||||
tags: [ 'tag_torrent1', 'tag_torrent2' ]
|
tags: [ 'tag_torrent1', 'tag_torrent2' ]
|
||||||
})
|
}
|
||||||
const { video } = await servers[0].importsCommand.importVideo({ attributes })
|
const { video } = await servers[0].importsCommand.importVideo({ attributes })
|
||||||
expect(video.name).to.equal('super peertube2 video')
|
expect(video.name).to.equal('super peertube2 video')
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const attributes = immutableAssign(baseAttributes, {
|
const attributes = {
|
||||||
|
...baseAttributes,
|
||||||
torrentfile: 'video-720p.torrent' as any,
|
torrentfile: 'video-720p.torrent' as any,
|
||||||
description: 'this is a super torrent description',
|
description: 'this is a super torrent description',
|
||||||
tags: [ 'tag_torrent1', 'tag_torrent2' ]
|
tags: [ 'tag_torrent1', 'tag_torrent2' ]
|
||||||
})
|
}
|
||||||
const { video } = await servers[0].importsCommand.importVideo({ attributes })
|
const { video } = await servers[0].importsCommand.importVideo({ attributes })
|
||||||
expect(video.name).to.equal('你好 世界 720p.mp4')
|
expect(video.name).to.equal('你好 世界 720p.mp4')
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,12 @@ import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||||
import {
|
import {
|
||||||
buildAbsoluteFixturePath,
|
buildAbsoluteFixturePath,
|
||||||
buildServerDirectory,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
generateHighBitrateVideo,
|
generateHighBitrateVideo,
|
||||||
generateVideoWithFramerate,
|
generateVideoWithFramerate,
|
||||||
getMyVideos,
|
getMyVideos,
|
||||||
getServerFileSize,
|
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideoFileMetadataUrl,
|
getVideoFileMetadataUrl,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
|
@ -285,7 +283,7 @@ describe('Test video transcoding', function () {
|
||||||
|
|
||||||
expect(videoDetails.files).to.have.lengthOf(4)
|
expect(videoDetails.files).to.have.lengthOf(4)
|
||||||
|
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
|
const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
|
||||||
const probe = await getAudioStream(path)
|
const probe = await getAudioStream(path)
|
||||||
|
|
||||||
if (probe.audioStream) {
|
if (probe.audioStream) {
|
||||||
|
@ -316,7 +314,7 @@ describe('Test video transcoding', function () {
|
||||||
const videoDetails: VideoDetails = res2.body
|
const videoDetails: VideoDetails = res2.body
|
||||||
|
|
||||||
expect(videoDetails.files).to.have.lengthOf(4)
|
expect(videoDetails.files).to.have.lengthOf(4)
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
|
const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
|
||||||
const probe = await getAudioStream(path)
|
const probe = await getAudioStream(path)
|
||||||
expect(probe).to.not.have.property('audioStream')
|
expect(probe).to.not.have.property('audioStream')
|
||||||
}
|
}
|
||||||
|
@ -344,7 +342,7 @@ describe('Test video transcoding', function () {
|
||||||
|
|
||||||
const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
|
const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
|
||||||
const fixtureVideoProbe = await getAudioStream(fixturePath)
|
const fixtureVideoProbe = await getAudioStream(fixturePath)
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
|
const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
|
||||||
|
|
||||||
const videoProbe = await getAudioStream(path)
|
const videoProbe = await getAudioStream(path)
|
||||||
|
|
||||||
|
@ -506,13 +504,13 @@ describe('Test video transcoding', function () {
|
||||||
expect(videoDetails.files[3].fps).to.be.below(31)
|
expect(videoDetails.files[3].fps).to.be.below(31)
|
||||||
|
|
||||||
for (const resolution of [ '240', '360', '480' ]) {
|
for (const resolution of [ '240', '360', '480' ]) {
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
|
const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
|
||||||
const fps = await getVideoFileFPS(path)
|
const fps = await getVideoFileFPS(path)
|
||||||
|
|
||||||
expect(fps).to.be.below(31)
|
expect(fps).to.be.below(31)
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4'))
|
const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4'))
|
||||||
const fps = await getVideoFileFPS(path)
|
const fps = await getVideoFileFPS(path)
|
||||||
|
|
||||||
expect(fps).to.be.above(58).and.below(62)
|
expect(fps).to.be.above(58).and.below(62)
|
||||||
|
@ -547,13 +545,13 @@ describe('Test video transcoding', function () {
|
||||||
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
||||||
|
|
||||||
{
|
{
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
|
const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
|
||||||
const fps = await getVideoFileFPS(path)
|
const fps = await getVideoFileFPS(path)
|
||||||
expect(fps).to.be.equal(25)
|
expect(fps).to.be.equal(25)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4'))
|
const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4'))
|
||||||
const fps = await getVideoFileFPS(path)
|
const fps = await getVideoFileFPS(path)
|
||||||
expect(fps).to.be.equal(59)
|
expect(fps).to.be.equal(59)
|
||||||
}
|
}
|
||||||
|
@ -590,7 +588,7 @@ describe('Test video transcoding', function () {
|
||||||
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
||||||
|
|
||||||
for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
|
for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
|
const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
|
||||||
|
|
||||||
const bitrate = await getVideoFileBitrate(path)
|
const bitrate = await getVideoFileBitrate(path)
|
||||||
const fps = await getVideoFileFPS(path)
|
const fps = await getVideoFileFPS(path)
|
||||||
|
@ -636,7 +634,7 @@ describe('Test video transcoding', function () {
|
||||||
const resolutions = [ 240, 360, 480, 720, 1080 ]
|
const resolutions = [ 240, 360, 480, 720, 1080 ]
|
||||||
for (const r of resolutions) {
|
for (const r of resolutions) {
|
||||||
const path = `videos/${videoUUID}-${r}.mp4`
|
const path = `videos/${videoUUID}-${r}.mp4`
|
||||||
const size = await getServerFileSize(servers[1], path)
|
const size = await servers[1].serversCommand.getServerFileSize(path)
|
||||||
expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
|
expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -651,7 +649,7 @@ describe('Test video transcoding', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
{
|
{
|
||||||
const path = buildServerDirectory(servers[1], join('videos', videoUUID + '-240.mp4'))
|
const path = servers[1].serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4'))
|
||||||
const metadata = await getMetadataFromFile(path)
|
const metadata = await getMetadataFromFile(path)
|
||||||
|
|
||||||
// expected format properties
|
// expected format properties
|
||||||
|
|
|
@ -4,7 +4,6 @@ import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import {
|
import {
|
||||||
buildServerDirectory,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
|
@ -96,7 +95,7 @@ describe('Test optimize old videos', function () {
|
||||||
|
|
||||||
expect(file.size).to.be.below(8000000)
|
expect(file.size).to.be.below(8000000)
|
||||||
|
|
||||||
const path = buildServerDirectory(servers[0], join('videos', video.uuid + '-' + file.resolution.id + '.mp4'))
|
const path = servers[0].serversCommand.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4'))
|
||||||
const bitrate = await getVideoFileBitrate(path)
|
const bitrate = await getVideoFileBitrate(path)
|
||||||
const fps = await getVideoFileFPS(path)
|
const fps = await getVideoFileFPS(path)
|
||||||
const resolution = await getVideoFileResolution(path)
|
const resolution = await getVideoFileResolution(path)
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { join } from 'path'
|
||||||
import { buildUUID } from '@server/helpers/uuid'
|
import { buildUUID } from '@server/helpers/uuid'
|
||||||
import { HttpStatusCode } from '@shared/core-utils'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
buildServerDirectory,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
CLICommand,
|
CLICommand,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
|
@ -26,14 +25,14 @@ import { VideoPlaylistPrivacy } from '@shared/models'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
async function countFiles (internalServerNumber: number, directory: string) {
|
async function countFiles (server: ServerInfo, directory: string) {
|
||||||
const files = await readdir(buildServerDirectory({ internalServerNumber }, directory))
|
const files = await readdir(server.serversCommand.buildDirectory(directory))
|
||||||
|
|
||||||
return files.length
|
return files.length
|
||||||
}
|
}
|
||||||
|
|
||||||
async function assertNotExists (internalServerNumber: number, directory: string, substring: string) {
|
async function assertNotExists (server: ServerInfo, directory: string, substring: string) {
|
||||||
const files = await readdir(buildServerDirectory({ internalServerNumber }, directory))
|
const files = await readdir(server.serversCommand.buildDirectory(directory))
|
||||||
|
|
||||||
for (const f of files) {
|
for (const f of files) {
|
||||||
expect(f).to.not.contain(substring)
|
expect(f).to.not.contain(substring)
|
||||||
|
@ -42,19 +41,19 @@ async function assertNotExists (internalServerNumber: number, directory: string,
|
||||||
|
|
||||||
async function assertCountAreOkay (servers: ServerInfo[]) {
|
async function assertCountAreOkay (servers: ServerInfo[]) {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const videosCount = await countFiles(server.internalServerNumber, 'videos')
|
const videosCount = await countFiles(server, 'videos')
|
||||||
expect(videosCount).to.equal(8)
|
expect(videosCount).to.equal(8)
|
||||||
|
|
||||||
const torrentsCount = await countFiles(server.internalServerNumber, 'torrents')
|
const torrentsCount = await countFiles(server, 'torrents')
|
||||||
expect(torrentsCount).to.equal(16)
|
expect(torrentsCount).to.equal(16)
|
||||||
|
|
||||||
const previewsCount = await countFiles(server.internalServerNumber, 'previews')
|
const previewsCount = await countFiles(server, 'previews')
|
||||||
expect(previewsCount).to.equal(2)
|
expect(previewsCount).to.equal(2)
|
||||||
|
|
||||||
const thumbnailsCount = await countFiles(server.internalServerNumber, 'thumbnails')
|
const thumbnailsCount = await countFiles(server, 'thumbnails')
|
||||||
expect(thumbnailsCount).to.equal(6)
|
expect(thumbnailsCount).to.equal(6)
|
||||||
|
|
||||||
const avatarsCount = await countFiles(server.internalServerNumber, 'avatars')
|
const avatarsCount = await countFiles(server, 'avatars')
|
||||||
expect(avatarsCount).to.equal(2)
|
expect(avatarsCount).to.equal(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +121,7 @@ describe('Test prune storage scripts', function () {
|
||||||
it('Should create some dirty files', async function () {
|
it('Should create some dirty files', async function () {
|
||||||
for (let i = 0; i < 2; i++) {
|
for (let i = 0; i < 2; i++) {
|
||||||
{
|
{
|
||||||
const base = buildServerDirectory(servers[0], 'videos')
|
const base = servers[0].serversCommand.buildDirectory('videos')
|
||||||
|
|
||||||
const n1 = buildUUID() + '.mp4'
|
const n1 = buildUUID() + '.mp4'
|
||||||
const n2 = buildUUID() + '.webm'
|
const n2 = buildUUID() + '.webm'
|
||||||
|
@ -134,7 +133,7 @@ describe('Test prune storage scripts', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const base = buildServerDirectory(servers[0], 'torrents')
|
const base = servers[0].serversCommand.buildDirectory('torrents')
|
||||||
|
|
||||||
const n1 = buildUUID() + '-240.torrent'
|
const n1 = buildUUID() + '-240.torrent'
|
||||||
const n2 = buildUUID() + '-480.torrent'
|
const n2 = buildUUID() + '-480.torrent'
|
||||||
|
@ -146,7 +145,7 @@ describe('Test prune storage scripts', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const base = buildServerDirectory(servers[0], 'thumbnails')
|
const base = servers[0].serversCommand.buildDirectory('thumbnails')
|
||||||
|
|
||||||
const n1 = buildUUID() + '.jpg'
|
const n1 = buildUUID() + '.jpg'
|
||||||
const n2 = buildUUID() + '.jpg'
|
const n2 = buildUUID() + '.jpg'
|
||||||
|
@ -158,7 +157,7 @@ describe('Test prune storage scripts', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const base = buildServerDirectory(servers[0], 'previews')
|
const base = servers[0].serversCommand.buildDirectory('previews')
|
||||||
|
|
||||||
const n1 = buildUUID() + '.jpg'
|
const n1 = buildUUID() + '.jpg'
|
||||||
const n2 = buildUUID() + '.jpg'
|
const n2 = buildUUID() + '.jpg'
|
||||||
|
@ -170,7 +169,7 @@ describe('Test prune storage scripts', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const base = buildServerDirectory(servers[0], 'avatars')
|
const base = servers[0].serversCommand.buildDirectory('avatars')
|
||||||
|
|
||||||
const n1 = buildUUID() + '.png'
|
const n1 = buildUUID() + '.png'
|
||||||
const n2 = buildUUID() + '.jpg'
|
const n2 = buildUUID() + '.jpg'
|
||||||
|
@ -195,7 +194,7 @@ describe('Test prune storage scripts', function () {
|
||||||
|
|
||||||
for (const directory of Object.keys(badNames)) {
|
for (const directory of Object.keys(badNames)) {
|
||||||
for (const name of badNames[directory]) {
|
for (const name of badNames[directory]) {
|
||||||
await assertNotExists(servers[0].internalServerNumber, directory, name)
|
await assertNotExists(servers[0], directory, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { writeFile } from 'fs-extra'
|
||||||
import { basename, join } from 'path'
|
import { basename, join } from 'path'
|
||||||
import { Video, VideoDetails } from '@shared/models'
|
import { Video, VideoDetails } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
buildServerDirectory,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
|
@ -50,7 +49,7 @@ describe('Test regenerate thumbnails script', function () {
|
||||||
const videoUUID1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid
|
const videoUUID1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid
|
||||||
video1 = await (getVideo(servers[0].url, videoUUID1).then(res => res.body))
|
video1 = await (getVideo(servers[0].url, videoUUID1).then(res => res.body))
|
||||||
|
|
||||||
thumbnail1Path = join(buildServerDirectory(servers[0], 'thumbnails'), basename(video1.thumbnailPath))
|
thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath))
|
||||||
|
|
||||||
const videoUUID2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid
|
const videoUUID2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid
|
||||||
video2 = await (getVideo(servers[0].url, videoUUID2).then(res => res.body))
|
video2 = await (getVideo(servers[0].url, videoUUID2).then(res => res.body))
|
||||||
|
@ -62,7 +61,7 @@ describe('Test regenerate thumbnails script', function () {
|
||||||
|
|
||||||
remoteVideo = await (getVideo(servers[0].url, videoUUID).then(res => res.body))
|
remoteVideo = await (getVideo(servers[0].url, videoUUID).then(res => res.body))
|
||||||
|
|
||||||
thumbnailRemotePath = join(buildServerDirectory(servers[0], 'thumbnails'), basename(remoteVideo.thumbnailPath))
|
thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
await writeFile(thumbnail1Path, '')
|
await writeFile(thumbnail1Path, '')
|
||||||
|
|
|
@ -22,8 +22,7 @@ import {
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
killallServers,
|
killallServers,
|
||||||
reRunServer,
|
reRunServer,
|
||||||
ServerInfo,
|
ServerInfo
|
||||||
waitUntilLog
|
|
||||||
} from '../../../shared/extra-utils/server/servers'
|
} from '../../../shared/extra-utils/server/servers'
|
||||||
|
|
||||||
describe('Test plugin action hooks', function () {
|
describe('Test plugin action hooks', function () {
|
||||||
|
@ -32,7 +31,7 @@ describe('Test plugin action hooks', function () {
|
||||||
let threadId: number
|
let threadId: number
|
||||||
|
|
||||||
function checkHook (hook: ServerHookName) {
|
function checkHook (hook: ServerHookName) {
|
||||||
return waitUntilLog(servers[0], 'Run hook ' + hook)
|
return servers[0].serversCommand.waitUntilLog('Run hook ' + hook)
|
||||||
}
|
}
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
|
|
@ -17,8 +17,7 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
userLogin,
|
userLogin,
|
||||||
wait,
|
wait
|
||||||
waitUntilLog
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { User, UserRole } from '@shared/models'
|
import { User, UserRole } from '@shared/models'
|
||||||
|
|
||||||
|
@ -127,7 +126,7 @@ describe('Test external auth plugins', function () {
|
||||||
|
|
||||||
await loginUsingExternalToken(server, 'cyan', externalAuthToken, HttpStatusCode.BAD_REQUEST_400)
|
await loginUsingExternalToken(server, 'cyan', externalAuthToken, HttpStatusCode.BAD_REQUEST_400)
|
||||||
|
|
||||||
await waitUntilLog(server, 'expired external auth token', 2)
|
await server.serversCommand.waitUntilLog('expired external auth token', 2)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should auto login Cyan, create the user and use the token', async function () {
|
it('Should auto login Cyan, create the user and use the token', async function () {
|
||||||
|
@ -217,7 +216,7 @@ describe('Test external auth plugins', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have logged out Cyan', async function () {
|
it('Should have logged out Cyan', async function () {
|
||||||
await waitUntilLog(server, 'On logout cyan')
|
await server.serversCommand.waitUntilLog('On logout cyan')
|
||||||
|
|
||||||
await getMyUserInformation(server.url, cyanAccessToken, HttpStatusCode.UNAUTHORIZED_401)
|
await getMyUserInformation(server.url, cyanAccessToken, HttpStatusCode.UNAUTHORIZED_401)
|
||||||
})
|
})
|
||||||
|
|
|
@ -24,8 +24,7 @@ import {
|
||||||
updateVideo,
|
updateVideo,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
waitJobs,
|
waitJobs
|
||||||
waitUntilLog
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
|
import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
|
||||||
|
|
||||||
|
@ -475,8 +474,8 @@ describe('Test plugin filter hooks', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.result', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run filter:api.search.videos.index.list.{params,result}', async function () {
|
it('Should run filter:api.search.videos.index.list.{params,result}', async function () {
|
||||||
|
@ -487,10 +486,10 @@ describe('Test plugin filter hooks', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.result', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.index.list.params', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.index.list.result', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () {
|
it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () {
|
||||||
|
@ -500,8 +499,8 @@ describe('Test plugin filter hooks', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.result', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () {
|
it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () {
|
||||||
|
@ -512,10 +511,10 @@ describe('Test plugin filter hooks', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.result', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.params', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.result', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () {
|
it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () {
|
||||||
|
@ -525,8 +524,8 @@ describe('Test plugin filter hooks', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () {
|
it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () {
|
||||||
|
@ -537,10 +536,10 @@ describe('Test plugin filter hooks', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.params', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1)
|
||||||
await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.result', 1)
|
await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,7 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
userLogin,
|
userLogin,
|
||||||
wait,
|
wait
|
||||||
waitUntilLog
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { User, UserRole } from '@shared/models'
|
import { User, UserRole } from '@shared/models'
|
||||||
|
|
||||||
|
@ -137,7 +136,7 @@ describe('Test id and pass auth plugins', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have logged out Crash', async function () {
|
it('Should have logged out Crash', async function () {
|
||||||
await waitUntilLog(server, 'On logout for auth 1 - 2')
|
await server.serversCommand.waitUntilLog('On logout for auth 1 - 2')
|
||||||
|
|
||||||
await getMyUserInformation(server.url, crashAccessToken, 401)
|
await getMyUserInformation(server.url, crashAccessToken, 401)
|
||||||
})
|
})
|
||||||
|
@ -164,16 +163,16 @@ describe('Test id and pass auth plugins', function () {
|
||||||
|
|
||||||
it('Should reject an invalid username, email, role or display name', async function () {
|
it('Should reject an invalid username, email, role or display name', async function () {
|
||||||
await userLogin(server, { username: 'ward', password: 'ward password' }, 400)
|
await userLogin(server, { username: 'ward', password: 'ward password' }, 400)
|
||||||
await waitUntilLog(server, 'valid username')
|
await server.serversCommand.waitUntilLog('valid username')
|
||||||
|
|
||||||
await userLogin(server, { username: 'kiros', password: 'kiros password' }, 400)
|
await userLogin(server, { username: 'kiros', password: 'kiros password' }, 400)
|
||||||
await waitUntilLog(server, 'valid display name')
|
await server.serversCommand.waitUntilLog('valid display name')
|
||||||
|
|
||||||
await userLogin(server, { username: 'raine', password: 'raine password' }, 400)
|
await userLogin(server, { username: 'raine', password: 'raine password' }, 400)
|
||||||
await waitUntilLog(server, 'valid role')
|
await server.serversCommand.waitUntilLog('valid role')
|
||||||
|
|
||||||
await userLogin(server, { username: 'ellone', password: 'elonne password' }, 400)
|
await userLogin(server, { username: 'ellone', password: 'elonne password' }, 400)
|
||||||
await waitUntilLog(server, 'valid email')
|
await server.serversCommand.waitUntilLog('valid email')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should unregister spyro-auth and do not login existing Spyro', async function () {
|
it('Should unregister spyro-auth and do not login existing Spyro', async function () {
|
||||||
|
|
|
@ -17,8 +17,7 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideoAndGetId,
|
uploadVideoAndGetId,
|
||||||
viewVideo,
|
viewVideo,
|
||||||
waitJobs,
|
waitJobs
|
||||||
waitUntilLog
|
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
|
|
||||||
function postCommand (server: ServerInfo, command: string, bodyArg?: object) {
|
function postCommand (server: ServerInfo, command: string, bodyArg?: object) {
|
||||||
|
@ -50,22 +49,22 @@ describe('Test plugin helpers', function () {
|
||||||
describe('Logger', function () {
|
describe('Logger', function () {
|
||||||
|
|
||||||
it('Should have logged things', async function () {
|
it('Should have logged things', async function () {
|
||||||
await waitUntilLog(servers[0], 'localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false)
|
await servers[0].serversCommand.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false)
|
||||||
await waitUntilLog(servers[0], 'Hello world from plugin four', 1)
|
await servers[0].serversCommand.waitUntilLog('Hello world from plugin four', 1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Database', function () {
|
describe('Database', function () {
|
||||||
|
|
||||||
it('Should have made a query', async function () {
|
it('Should have made a query', async function () {
|
||||||
await waitUntilLog(servers[0], `root email is admin${servers[0].internalServerNumber}@example.com`)
|
await servers[0].serversCommand.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Config', function () {
|
describe('Config', function () {
|
||||||
|
|
||||||
it('Should have the correct webserver url', async function () {
|
it('Should have the correct webserver url', async function () {
|
||||||
await waitUntilLog(servers[0], `server url is http://localhost:${servers[0].port}`)
|
await servers[0].serversCommand.waitUntilLog(`server url is http://localhost:${servers[0].port}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have the correct config', async function () {
|
it('Should have the correct config', async function () {
|
||||||
|
@ -83,7 +82,7 @@ describe('Test plugin helpers', function () {
|
||||||
describe('Server', function () {
|
describe('Server', function () {
|
||||||
|
|
||||||
it('Should get the server actor', async function () {
|
it('Should get the server actor', async function () {
|
||||||
await waitUntilLog(servers[0], 'server actor name is peertube')
|
await servers[0].serversCommand.waitUntilLog('server actor name is peertube')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -248,7 +247,7 @@ describe('Test plugin helpers', function () {
|
||||||
// Should delete the video
|
// Should delete the video
|
||||||
await viewVideo(servers[0].url, videoUUID)
|
await viewVideo(servers[0].url, videoUUID)
|
||||||
|
|
||||||
await waitUntilLog(servers[0], 'Video deleted by plugin four.')
|
await servers[0].serversCommand.waitUntilLog('Video deleted by plugin four.')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Should throw because the video should have been deleted
|
// Should throw because the video should have been deleted
|
||||||
|
@ -258,11 +257,11 @@ describe('Test plugin helpers', function () {
|
||||||
if (err.message.includes('exists')) throw err
|
if (err.message.includes('exists')) throw err
|
||||||
}
|
}
|
||||||
|
|
||||||
await checkVideoFilesWereRemoved(videoUUID, servers[0].internalServerNumber)
|
await checkVideoFilesWereRemoved(videoUUID, servers[0])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have fetched the video by URL', async function () {
|
it('Should have fetched the video by URL', async function () {
|
||||||
await waitUntilLog(servers[0], `video from DB uuid is ${videoUUID}`)
|
await servers[0].serversCommand.waitUntilLog(`video from DB uuid is ${videoUUID}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,7 @@ import { expect } from 'chai'
|
||||||
import { pathExists, readdir, readFile } from 'fs-extra'
|
import { pathExists, readdir, readFile } from 'fs-extra'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { HttpStatusCode } from '@shared/core-utils'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import {
|
import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
|
||||||
buildServerDirectory,
|
|
||||||
cleanupTests,
|
|
||||||
flushAndRunServer,
|
|
||||||
makeGetRequest,
|
|
||||||
PluginsCommand,
|
|
||||||
ServerInfo,
|
|
||||||
setAccessTokensToServers,
|
|
||||||
waitUntilLog
|
|
||||||
} from '@shared/extra-utils'
|
|
||||||
|
|
||||||
describe('Test plugin storage', function () {
|
describe('Test plugin storage', function () {
|
||||||
let server: ServerInfo
|
let server: ServerInfo
|
||||||
|
@ -31,7 +22,7 @@ describe('Test plugin storage', function () {
|
||||||
describe('DB storage', function () {
|
describe('DB storage', function () {
|
||||||
|
|
||||||
it('Should correctly store a subkey', async function () {
|
it('Should correctly store a subkey', async function () {
|
||||||
await waitUntilLog(server, 'superkey stored value is toto')
|
await server.serversCommand.waitUntilLog('superkey stored value is toto')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -47,12 +38,12 @@ describe('Test plugin storage', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
before(function () {
|
before(function () {
|
||||||
dataPath = buildServerDirectory(server, 'plugins/data')
|
dataPath = server.serversCommand.buildDirectory('plugins/data')
|
||||||
pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
|
pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have created the directory on install', async function () {
|
it('Should have created the directory on install', async function () {
|
||||||
const dataPath = buildServerDirectory(server, 'plugins/data')
|
const dataPath = server.serversCommand.buildDirectory('plugins/data')
|
||||||
const pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
|
const pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
|
||||||
|
|
||||||
expect(await pathExists(dataPath)).to.be.true
|
expect(await pathExists(dataPath)).to.be.true
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { expect } from 'chai'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
|
import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
|
||||||
import {
|
import {
|
||||||
buildServerDirectory,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getVideo,
|
getVideo,
|
||||||
|
@ -247,7 +246,7 @@ describe('Test transcoding plugins', function () {
|
||||||
const videoUUID = (await uploadVideoAndGetId({ server, videoName: 'video', fixture: 'video_short_240p.mp4' })).uuid
|
const videoUUID = (await uploadVideoAndGetId({ server, videoName: 'video', fixture: 'video_short_240p.mp4' })).uuid
|
||||||
await waitJobs([ server ])
|
await waitJobs([ server ])
|
||||||
|
|
||||||
const path = buildServerDirectory(server, join('videos', videoUUID + '-240.mp4'))
|
const path = server.serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4'))
|
||||||
const audioProbe = await getAudioStream(path)
|
const audioProbe = await getAudioStream(path)
|
||||||
expect(audioProbe.audioStream.codec_name).to.equal('opus')
|
expect(audioProbe.audioStream.codec_name).to.equal('opus')
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
|
||||||
|
|
||||||
|
import { expect } from 'chai'
|
||||||
|
import { pathExists, readFile } from 'fs-extra'
|
||||||
|
import { join } from 'path'
|
||||||
|
import { root } from '@server/helpers/core-utils'
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
|
import { makeGetRequest } from '../requests'
|
||||||
|
import { ServerInfo } from '../server'
|
||||||
|
|
||||||
|
// Default interval -> 5 minutes
|
||||||
|
function dateIsValid (dateString: string, interval = 300000) {
|
||||||
|
const dateToCheck = new Date(dateString)
|
||||||
|
const now = new Date()
|
||||||
|
|
||||||
|
return Math.abs(now.getTime() - dateToCheck.getTime()) <= interval
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') {
|
||||||
|
const res = await makeGetRequest({
|
||||||
|
url,
|
||||||
|
path: imagePath,
|
||||||
|
statusCodeExpected: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
|
||||||
|
const body = res.body
|
||||||
|
|
||||||
|
const data = await readFile(join(root(), 'server', 'tests', 'fixtures', imageName + extension))
|
||||||
|
const minLength = body.length - ((30 * body.length) / 100)
|
||||||
|
const maxLength = body.length + ((30 * body.length) / 100)
|
||||||
|
|
||||||
|
expect(data.length).to.be.above(minLength, 'the generated image is way smaller than the recorded fixture')
|
||||||
|
expect(data.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testFileExistsOrNot (server: ServerInfo, directory: string, filePath: string, exist: boolean) {
|
||||||
|
const base = server.serversCommand.buildDirectory(directory)
|
||||||
|
|
||||||
|
expect(await pathExists(join(base, filePath))).to.equal(exist)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
dateIsValid,
|
||||||
|
testImage,
|
||||||
|
testFileExistsOrNot
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
import { ensureDir, pathExists } from 'fs-extra'
|
||||||
|
import { dirname } from 'path'
|
||||||
|
import { buildAbsoluteFixturePath } from './tests'
|
||||||
|
import * as ffmpeg from 'fluent-ffmpeg'
|
||||||
|
|
||||||
|
async function generateHighBitrateVideo () {
|
||||||
|
const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true)
|
||||||
|
|
||||||
|
await ensureDir(dirname(tempFixturePath))
|
||||||
|
|
||||||
|
const exists = await pathExists(tempFixturePath)
|
||||||
|
if (!exists) {
|
||||||
|
console.log('Generating high bitrate video.')
|
||||||
|
|
||||||
|
// Generate a random, high bitrate video on the fly, so we don't have to include
|
||||||
|
// a large file in the repo. The video needs to have a certain minimum length so
|
||||||
|
// that FFmpeg properly applies bitrate limits.
|
||||||
|
// https://stackoverflow.com/a/15795112
|
||||||
|
return new Promise<string>((res, rej) => {
|
||||||
|
ffmpeg()
|
||||||
|
.outputOptions([ '-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom' ])
|
||||||
|
.outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ])
|
||||||
|
.outputOptions([ '-maxrate 10M', '-bufsize 10M' ])
|
||||||
|
.output(tempFixturePath)
|
||||||
|
.on('error', rej)
|
||||||
|
.on('end', () => res(tempFixturePath))
|
||||||
|
.run()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempFixturePath
|
||||||
|
}
|
||||||
|
|
||||||
|
async function generateVideoWithFramerate (fps = 60) {
|
||||||
|
const tempFixturePath = buildAbsoluteFixturePath(`video_${fps}fps.mp4`, true)
|
||||||
|
|
||||||
|
await ensureDir(dirname(tempFixturePath))
|
||||||
|
|
||||||
|
const exists = await pathExists(tempFixturePath)
|
||||||
|
if (!exists) {
|
||||||
|
console.log('Generating video with framerate %d.', fps)
|
||||||
|
|
||||||
|
return new Promise<string>((res, rej) => {
|
||||||
|
ffmpeg()
|
||||||
|
.outputOptions([ '-f rawvideo', '-video_size 1280x720', '-i /dev/urandom' ])
|
||||||
|
.outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ])
|
||||||
|
.outputOptions([ `-r ${fps}` ])
|
||||||
|
.output(tempFixturePath)
|
||||||
|
.on('error', rej)
|
||||||
|
.on('end', () => res(tempFixturePath))
|
||||||
|
.run()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempFixturePath
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
generateHighBitrateVideo,
|
||||||
|
generateVideoWithFramerate
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
export * from './miscs'
|
export * from './checks'
|
||||||
|
export * from './generate'
|
||||||
export * from './sql-command'
|
export * from './sql-command'
|
||||||
export * from './stubs'
|
export * from './tests'
|
||||||
|
export * from './webtorrent'
|
||||||
|
|
|
@ -1,170 +0,0 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import * as ffmpeg from 'fluent-ffmpeg'
|
|
||||||
import { ensureDir, pathExists, readFile, stat } from 'fs-extra'
|
|
||||||
import { basename, dirname, isAbsolute, join, resolve } from 'path'
|
|
||||||
import * as request from 'supertest'
|
|
||||||
import * as WebTorrent from 'webtorrent'
|
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
|
||||||
let webtorrent: WebTorrent.Instance
|
|
||||||
|
|
||||||
function immutableAssign<T, U> (target: T, source: U) {
|
|
||||||
return Object.assign<{}, T, U>({}, target, source)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default interval -> 5 minutes
|
|
||||||
function dateIsValid (dateString: string, interval = 300000) {
|
|
||||||
const dateToCheck = new Date(dateString)
|
|
||||||
const now = new Date()
|
|
||||||
|
|
||||||
return Math.abs(now.getTime() - dateToCheck.getTime()) <= interval
|
|
||||||
}
|
|
||||||
|
|
||||||
function wait (milliseconds: number) {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
|
||||||
}
|
|
||||||
|
|
||||||
function webtorrentAdd (torrent: string, refreshWebTorrent = false) {
|
|
||||||
const WebTorrent = require('webtorrent')
|
|
||||||
|
|
||||||
if (!webtorrent) webtorrent = new WebTorrent()
|
|
||||||
if (refreshWebTorrent === true) webtorrent = new WebTorrent()
|
|
||||||
|
|
||||||
return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res))
|
|
||||||
}
|
|
||||||
|
|
||||||
function root () {
|
|
||||||
// We are in /miscs
|
|
||||||
let root = join(__dirname, '..', '..', '..')
|
|
||||||
|
|
||||||
if (basename(root) === 'dist') root = resolve(root, '..')
|
|
||||||
|
|
||||||
return root
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildServerDirectory (server: { internalServerNumber: number }, directory: string) {
|
|
||||||
return join(root(), 'test' + server.internalServerNumber, directory)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') {
|
|
||||||
const res = await request(url)
|
|
||||||
.get(imagePath)
|
|
||||||
.expect(HttpStatusCode.OK_200)
|
|
||||||
|
|
||||||
const body = res.body
|
|
||||||
|
|
||||||
const data = await readFile(join(root(), 'server', 'tests', 'fixtures', imageName + extension))
|
|
||||||
const minLength = body.length - ((30 * body.length) / 100)
|
|
||||||
const maxLength = body.length + ((30 * body.length) / 100)
|
|
||||||
|
|
||||||
expect(data.length).to.be.above(minLength, 'the generated image is way smaller than the recorded fixture')
|
|
||||||
expect(data.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function testFileExistsOrNot (server: { internalServerNumber: number }, directory: string, filePath: string, exist: boolean) {
|
|
||||||
const base = buildServerDirectory(server, directory)
|
|
||||||
|
|
||||||
expect(await pathExists(join(base, filePath))).to.equal(exist)
|
|
||||||
}
|
|
||||||
|
|
||||||
function isGithubCI () {
|
|
||||||
return !!process.env.GITHUB_WORKSPACE
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildAbsoluteFixturePath (path: string, customCIPath = false) {
|
|
||||||
if (isAbsolute(path)) return path
|
|
||||||
|
|
||||||
if (customCIPath && process.env.GITHUB_WORKSPACE) {
|
|
||||||
return join(process.env.GITHUB_WORKSPACE, 'fixtures', path)
|
|
||||||
}
|
|
||||||
|
|
||||||
return join(root(), 'server', 'tests', 'fixtures', path)
|
|
||||||
}
|
|
||||||
|
|
||||||
function areHttpImportTestsDisabled () {
|
|
||||||
const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'
|
|
||||||
|
|
||||||
if (disabled) console.log('Import tests are disabled')
|
|
||||||
|
|
||||||
return disabled
|
|
||||||
}
|
|
||||||
|
|
||||||
async function generateHighBitrateVideo () {
|
|
||||||
const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true)
|
|
||||||
|
|
||||||
await ensureDir(dirname(tempFixturePath))
|
|
||||||
|
|
||||||
const exists = await pathExists(tempFixturePath)
|
|
||||||
if (!exists) {
|
|
||||||
console.log('Generating high bitrate video.')
|
|
||||||
|
|
||||||
// Generate a random, high bitrate video on the fly, so we don't have to include
|
|
||||||
// a large file in the repo. The video needs to have a certain minimum length so
|
|
||||||
// that FFmpeg properly applies bitrate limits.
|
|
||||||
// https://stackoverflow.com/a/15795112
|
|
||||||
return new Promise<string>((res, rej) => {
|
|
||||||
ffmpeg()
|
|
||||||
.outputOptions([ '-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom' ])
|
|
||||||
.outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ])
|
|
||||||
.outputOptions([ '-maxrate 10M', '-bufsize 10M' ])
|
|
||||||
.output(tempFixturePath)
|
|
||||||
.on('error', rej)
|
|
||||||
.on('end', () => res(tempFixturePath))
|
|
||||||
.run()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return tempFixturePath
|
|
||||||
}
|
|
||||||
|
|
||||||
async function generateVideoWithFramerate (fps = 60) {
|
|
||||||
const tempFixturePath = buildAbsoluteFixturePath(`video_${fps}fps.mp4`, true)
|
|
||||||
|
|
||||||
await ensureDir(dirname(tempFixturePath))
|
|
||||||
|
|
||||||
const exists = await pathExists(tempFixturePath)
|
|
||||||
if (!exists) {
|
|
||||||
console.log('Generating video with framerate %d.', fps)
|
|
||||||
|
|
||||||
return new Promise<string>((res, rej) => {
|
|
||||||
ffmpeg()
|
|
||||||
.outputOptions([ '-f rawvideo', '-video_size 1280x720', '-i /dev/urandom' ])
|
|
||||||
.outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ])
|
|
||||||
.outputOptions([ `-r ${fps}` ])
|
|
||||||
.output(tempFixturePath)
|
|
||||||
.on('error', rej)
|
|
||||||
.on('end', () => res(tempFixturePath))
|
|
||||||
.run()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return tempFixturePath
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getFileSize (path: string) {
|
|
||||||
const stats = await stat(path)
|
|
||||||
|
|
||||||
return stats.size
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export {
|
|
||||||
dateIsValid,
|
|
||||||
wait,
|
|
||||||
areHttpImportTestsDisabled,
|
|
||||||
buildServerDirectory,
|
|
||||||
webtorrentAdd,
|
|
||||||
getFileSize,
|
|
||||||
immutableAssign,
|
|
||||||
testImage,
|
|
||||||
isGithubCI,
|
|
||||||
buildAbsoluteFixturePath,
|
|
||||||
testFileExistsOrNot,
|
|
||||||
root,
|
|
||||||
generateHighBitrateVideo,
|
|
||||||
generateVideoWithFramerate
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { QueryTypes, Sequelize } from 'sequelize'
|
import { QueryTypes, Sequelize } from 'sequelize'
|
||||||
import { AbstractCommand } from '../shared'
|
import { AbstractCommand } from '../shared/abstract-command'
|
||||||
|
|
||||||
export class SQLCommand extends AbstractCommand {
|
export class SQLCommand extends AbstractCommand {
|
||||||
private sequelize: Sequelize
|
private sequelize: Sequelize
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
function buildRequestStub (): any {
|
|
||||||
return { }
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
|
||||||
buildRequestStub
|
|
||||||
}
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
import { stat } from 'fs-extra'
|
||||||
|
import { basename, isAbsolute, join, resolve } from 'path'
|
||||||
|
|
||||||
|
function parallelTests () {
|
||||||
|
return process.env.MOCHA_PARALLEL === 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
function isGithubCI () {
|
||||||
|
return !!process.env.GITHUB_WORKSPACE
|
||||||
|
}
|
||||||
|
|
||||||
|
function areHttpImportTestsDisabled () {
|
||||||
|
const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'
|
||||||
|
|
||||||
|
if (disabled) console.log('Import tests are disabled')
|
||||||
|
|
||||||
|
return disabled
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildAbsoluteFixturePath (path: string, customCIPath = false) {
|
||||||
|
if (isAbsolute(path)) return path
|
||||||
|
|
||||||
|
if (customCIPath && process.env.GITHUB_WORKSPACE) {
|
||||||
|
return join(process.env.GITHUB_WORKSPACE, 'fixtures', path)
|
||||||
|
}
|
||||||
|
|
||||||
|
return join(root(), 'server', 'tests', 'fixtures', path)
|
||||||
|
}
|
||||||
|
|
||||||
|
function root () {
|
||||||
|
// We are in /miscs
|
||||||
|
let root = join(__dirname, '..', '..', '..')
|
||||||
|
|
||||||
|
if (basename(root) === 'dist') root = resolve(root, '..')
|
||||||
|
|
||||||
|
return root
|
||||||
|
}
|
||||||
|
|
||||||
|
function wait (milliseconds: number) {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getFileSize (path: string) {
|
||||||
|
const stats = await stat(path)
|
||||||
|
|
||||||
|
return stats.size
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildRequestStub (): any {
|
||||||
|
return { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
parallelTests,
|
||||||
|
isGithubCI,
|
||||||
|
areHttpImportTestsDisabled,
|
||||||
|
buildAbsoluteFixturePath,
|
||||||
|
getFileSize,
|
||||||
|
buildRequestStub,
|
||||||
|
wait,
|
||||||
|
root
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
import * as WebTorrent from 'webtorrent'
|
||||||
|
|
||||||
|
let webtorrent: WebTorrent.Instance
|
||||||
|
|
||||||
|
function webtorrentAdd (torrent: string, refreshWebTorrent = false) {
|
||||||
|
const WebTorrent = require('webtorrent')
|
||||||
|
|
||||||
|
if (!webtorrent) webtorrent = new WebTorrent()
|
||||||
|
if (refreshWebTorrent === true) webtorrent = new WebTorrent()
|
||||||
|
|
||||||
|
return new Promise<WebTorrent.Torrent>(res => webtorrent.add(torrent, res))
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
webtorrentAdd
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import { ChildProcess } from 'child_process'
|
import { ChildProcess } from 'child_process'
|
||||||
import { randomInt } from '../../core-utils/miscs/miscs'
|
import { randomInt } from '@shared/core-utils'
|
||||||
import { parallelTests } from '../server/servers'
|
import { parallelTests } from '../miscs'
|
||||||
|
|
||||||
const MailDev = require('maildev')
|
const MailDev = require('maildev')
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { makeGetRequest } from './requests'
|
import { makeGetRequest } from './requests'
|
||||||
import { immutableAssign } from '../miscs/miscs'
|
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
|
function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
|
||||||
return makeGetRequest({
|
return makeGetRequest({
|
||||||
url,
|
url,
|
||||||
path,
|
path,
|
||||||
token,
|
token,
|
||||||
query: immutableAssign(query, { start: 'hello' }),
|
query: { ...query, start: 'hello' },
|
||||||
statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
|
statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -17,7 +16,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin
|
||||||
url,
|
url,
|
||||||
path,
|
path,
|
||||||
token,
|
token,
|
||||||
query: immutableAssign(query, { count: 'hello' }),
|
query: { ...query, count: 'hello' },
|
||||||
statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
|
statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -25,7 +24,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin
|
||||||
url,
|
url,
|
||||||
path,
|
path,
|
||||||
token,
|
token,
|
||||||
query: immutableAssign(query, { count: 2000 }),
|
query: { ...query, count: 2000 },
|
||||||
statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
|
statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -35,7 +34,7 @@ function checkBadSortPagination (url: string, path: string, token?: string, quer
|
||||||
url,
|
url,
|
||||||
path,
|
path,
|
||||||
token,
|
token,
|
||||||
query: immutableAssign(query, { sort: 'hello' }),
|
query: { ...query, sort: 'hello' },
|
||||||
statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
|
statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import { isAbsolute, join } from 'path'
|
||||||
import { decode } from 'querystring'
|
import { decode } from 'querystring'
|
||||||
import * as request from 'supertest'
|
import * as request from 'supertest'
|
||||||
import { URL } from 'url'
|
import { URL } from 'url'
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { buildAbsoluteFixturePath, root } from '../miscs/miscs'
|
import { buildAbsoluteFixturePath, root } from '../miscs/tests'
|
||||||
|
|
||||||
function get4KFileUrl () {
|
function get4KFileUrl () {
|
||||||
return 'https://download.cpy.re/peertube/4k_file.txt'
|
return 'https://download.cpy.re/peertube/4k_file.txt'
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
|
import { expect } from 'chai'
|
||||||
|
import { pathExists, readdir } from 'fs-extra'
|
||||||
|
import { join } from 'path'
|
||||||
|
import { root } from '@server/helpers/core-utils'
|
||||||
|
import { ServerInfo } from './servers'
|
||||||
|
|
||||||
|
async function checkTmpIsEmpty (server: ServerInfo) {
|
||||||
|
await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ])
|
||||||
|
|
||||||
|
if (await pathExists(join('test' + server.internalServerNumber, 'tmp', 'hls'))) {
|
||||||
|
await checkDirectoryIsEmpty(server, 'tmp/hls')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkDirectoryIsEmpty (server: ServerInfo, directory: string, exceptions: string[] = []) {
|
||||||
|
const testDirectory = 'test' + server.internalServerNumber
|
||||||
|
|
||||||
|
const directoryPath = join(root(), testDirectory, directory)
|
||||||
|
|
||||||
|
const directoryExists = await pathExists(directoryPath)
|
||||||
|
expect(directoryExists).to.be.true
|
||||||
|
|
||||||
|
const files = await readdir(directoryPath)
|
||||||
|
const filtered = files.filter(f => exceptions.includes(f) === false)
|
||||||
|
|
||||||
|
expect(filtered).to.have.lengthOf(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
checkTmpIsEmpty,
|
||||||
|
checkDirectoryIsEmpty
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
export * from './config-command'
|
export * from './config-command'
|
||||||
export * from './contact-form-command'
|
export * from './contact-form-command'
|
||||||
export * from './debug-command'
|
export * from './debug-command'
|
||||||
|
export * from './directories'
|
||||||
export * from './follows-command'
|
export * from './follows-command'
|
||||||
export * from './follows'
|
export * from './follows'
|
||||||
export * from './jobs'
|
export * from './jobs'
|
||||||
|
@ -8,5 +9,6 @@ export * from './jobs-command'
|
||||||
export * from './plugins-command'
|
export * from './plugins-command'
|
||||||
export * from './plugins'
|
export * from './plugins'
|
||||||
export * from './redundancy-command'
|
export * from './redundancy-command'
|
||||||
|
export * from './servers-command'
|
||||||
export * from './servers'
|
export * from './servers'
|
||||||
export * from './stats-command'
|
export * from './stats-command'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
import { JobState } from '../../models'
|
import { JobState } from '../../models'
|
||||||
import { wait } from '../miscs/miscs'
|
import { wait } from '../miscs'
|
||||||
import { ServerInfo } from './servers'
|
import { ServerInfo } from './servers'
|
||||||
|
|
||||||
async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
|
async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import {
|
||||||
RegisteredServerSettings,
|
RegisteredServerSettings,
|
||||||
ResultList
|
ResultList
|
||||||
} from '@shared/models'
|
} from '@shared/models'
|
||||||
import { buildServerDirectory } from '../miscs'
|
|
||||||
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||||
|
|
||||||
export class PluginsCommand extends AbstractCommand {
|
export class PluginsCommand extends AbstractCommand {
|
||||||
|
@ -252,6 +251,6 @@ export class PluginsCommand extends AbstractCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPackageJSONPath (npmName: string) {
|
private getPackageJSONPath (npmName: string) {
|
||||||
return buildServerDirectory(this.server, join('plugins', 'node_modules', npmName, 'package.json'))
|
return this.server.serversCommand.buildDirectory(join('plugins', 'node_modules', npmName, 'package.json'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
import { exec } from 'child_process'
|
||||||
|
import { copy, ensureDir, readFile, remove } from 'fs-extra'
|
||||||
|
import { join } from 'path'
|
||||||
|
import { root } from '@server/helpers/core-utils'
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
|
import { getFileSize } from '@uploadx/core'
|
||||||
|
import { isGithubCI, wait } from '../miscs'
|
||||||
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||||
|
|
||||||
|
export class ServersCommand extends AbstractCommand {
|
||||||
|
|
||||||
|
static flushTests (internalServerNumber: number) {
|
||||||
|
return new Promise<void>((res, rej) => {
|
||||||
|
const suffix = ` -- ${internalServerNumber}`
|
||||||
|
|
||||||
|
return exec('npm run clean:server:test' + suffix, (err, _stdout, stderr) => {
|
||||||
|
if (err || stderr) return rej(err || new Error(stderr))
|
||||||
|
|
||||||
|
return res()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ping (options: OverrideCommandOptions = {}) {
|
||||||
|
return this.getRequestBody({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path: '/api/v1/ping',
|
||||||
|
implicitToken: false,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async cleanupTests () {
|
||||||
|
const p: Promise<any>[] = []
|
||||||
|
|
||||||
|
if (isGithubCI()) {
|
||||||
|
await ensureDir('artifacts')
|
||||||
|
|
||||||
|
const origin = this.server.serversCommand.buildDirectory('logs/peertube.log')
|
||||||
|
const destname = `peertube-${this.server.internalServerNumber}.log`
|
||||||
|
console.log('Saving logs %s.', destname)
|
||||||
|
|
||||||
|
await copy(origin, join('artifacts', destname))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.server.parallel) {
|
||||||
|
p.push(ServersCommand.flushTests(this.server.internalServerNumber))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.server.customConfigFile) {
|
||||||
|
p.push(remove(this.server.customConfigFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
async waitUntilLog (str: string, count = 1, strictCount = true) {
|
||||||
|
const logfile = this.server.serversCommand.buildDirectory('logs/peertube.log')
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const buf = await readFile(logfile)
|
||||||
|
|
||||||
|
const matches = buf.toString().match(new RegExp(str, 'g'))
|
||||||
|
if (matches && matches.length === count) return
|
||||||
|
if (matches && strictCount === false && matches.length >= count) return
|
||||||
|
|
||||||
|
await wait(1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildDirectory (directory: string) {
|
||||||
|
return join(root(), 'test' + this.server.internalServerNumber, directory)
|
||||||
|
}
|
||||||
|
|
||||||
|
async getServerFileSize (subPath: string) {
|
||||||
|
const path = this.server.serversCommand.buildDirectory(subPath)
|
||||||
|
|
||||||
|
return getFileSize(path)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
|
||||||
|
|
||||||
import { expect } from 'chai'
|
import { ChildProcess, fork } from 'child_process'
|
||||||
import { ChildProcess, exec, fork } from 'child_process'
|
import { copy, ensureDir } from 'fs-extra'
|
||||||
import { copy, ensureDir, pathExists, readdir, readFile, remove } from 'fs-extra'
|
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
import { root } from '@server/helpers/core-utils'
|
||||||
import { randomInt } from '../../core-utils/miscs/miscs'
|
import { randomInt } from '../../core-utils/miscs/miscs'
|
||||||
import { VideoChannel } from '../../models/videos'
|
import { VideoChannel } from '../../models/videos'
|
||||||
import { BulkCommand } from '../bulk'
|
import { BulkCommand } from '../bulk'
|
||||||
|
@ -11,11 +11,9 @@ import { CLICommand } from '../cli'
|
||||||
import { CustomPagesCommand } from '../custom-pages'
|
import { CustomPagesCommand } from '../custom-pages'
|
||||||
import { FeedCommand } from '../feeds'
|
import { FeedCommand } from '../feeds'
|
||||||
import { LogsCommand } from '../logs'
|
import { LogsCommand } from '../logs'
|
||||||
import { SQLCommand } from '../miscs'
|
import { isGithubCI, parallelTests, SQLCommand } from '../miscs'
|
||||||
import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs'
|
|
||||||
import { AbusesCommand } from '../moderation'
|
import { AbusesCommand } from '../moderation'
|
||||||
import { OverviewsCommand } from '../overviews'
|
import { OverviewsCommand } from '../overviews'
|
||||||
import { makeGetRequest } from '../requests/requests'
|
|
||||||
import { SearchCommand } from '../search'
|
import { SearchCommand } from '../search'
|
||||||
import { SocketIOCommand } from '../socket'
|
import { SocketIOCommand } from '../socket'
|
||||||
import { AccountsCommand, BlocklistCommand, NotificationsCommand, SubscriptionsCommand } from '../users'
|
import { AccountsCommand, BlocklistCommand, NotificationsCommand, SubscriptionsCommand } from '../users'
|
||||||
|
@ -39,6 +37,7 @@ import { FollowsCommand } from './follows-command'
|
||||||
import { JobsCommand } from './jobs-command'
|
import { JobsCommand } from './jobs-command'
|
||||||
import { PluginsCommand } from './plugins-command'
|
import { PluginsCommand } from './plugins-command'
|
||||||
import { RedundancyCommand } from './redundancy-command'
|
import { RedundancyCommand } from './redundancy-command'
|
||||||
|
import { ServersCommand } from './servers-command'
|
||||||
import { StatsCommand } from './stats-command'
|
import { StatsCommand } from './stats-command'
|
||||||
|
|
||||||
interface ServerInfo {
|
interface ServerInfo {
|
||||||
|
@ -126,10 +125,7 @@ interface ServerInfo {
|
||||||
commentsCommand?: CommentsCommand
|
commentsCommand?: CommentsCommand
|
||||||
sqlCommand?: SQLCommand
|
sqlCommand?: SQLCommand
|
||||||
notificationsCommand?: NotificationsCommand
|
notificationsCommand?: NotificationsCommand
|
||||||
}
|
serversCommand?: ServersCommand
|
||||||
|
|
||||||
function parallelTests () {
|
|
||||||
return process.env.MOCHA_PARALLEL === 'true'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) {
|
function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) {
|
||||||
|
@ -151,18 +147,6 @@ function flushAndRunMultipleServers (totalServers: number, configOverride?: Obje
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushTests (serverNumber?: number) {
|
|
||||||
return new Promise<void>((res, rej) => {
|
|
||||||
const suffix = serverNumber ? ` -- ${serverNumber}` : ''
|
|
||||||
|
|
||||||
return exec('npm run clean:server:test' + suffix, (err, _stdout, stderr) => {
|
|
||||||
if (err || stderr) return rej(err || new Error(stderr))
|
|
||||||
|
|
||||||
return res()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function randomServer () {
|
function randomServer () {
|
||||||
const low = 10
|
const low = 10
|
||||||
const high = 10000
|
const high = 10000
|
||||||
|
@ -189,7 +173,7 @@ async function flushAndRunServer (serverNumber: number, configOverride?: Object,
|
||||||
const rtmpPort = parallel ? randomRTMP() : 1936
|
const rtmpPort = parallel ? randomRTMP() : 1936
|
||||||
const port = 9000 + internalServerNumber
|
const port = 9000 + internalServerNumber
|
||||||
|
|
||||||
await flushTests(internalServerNumber)
|
await ServersCommand.flushTests(internalServerNumber)
|
||||||
|
|
||||||
const server: ServerInfo = {
|
const server: ServerInfo = {
|
||||||
app: null,
|
app: null,
|
||||||
|
@ -372,6 +356,7 @@ function assignCommands (server: ServerInfo) {
|
||||||
server.commentsCommand = new CommentsCommand(server)
|
server.commentsCommand = new CommentsCommand(server)
|
||||||
server.sqlCommand = new SQLCommand(server)
|
server.sqlCommand = new SQLCommand(server)
|
||||||
server.notificationsCommand = new NotificationsCommand(server)
|
server.notificationsCommand = new NotificationsCommand(server)
|
||||||
|
server.serversCommand = new ServersCommand(server)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reRunServer (server: ServerInfo, configOverride?: any) {
|
async function reRunServer (server: ServerInfo, configOverride?: any) {
|
||||||
|
@ -381,28 +366,6 @@ async function reRunServer (server: ServerInfo, configOverride?: any) {
|
||||||
return server
|
return server
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkTmpIsEmpty (server: ServerInfo) {
|
|
||||||
await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ])
|
|
||||||
|
|
||||||
if (await pathExists(join('test' + server.internalServerNumber, 'tmp', 'hls'))) {
|
|
||||||
await checkDirectoryIsEmpty(server, 'tmp/hls')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function checkDirectoryIsEmpty (server: ServerInfo, directory: string, exceptions: string[] = []) {
|
|
||||||
const testDirectory = 'test' + server.internalServerNumber
|
|
||||||
|
|
||||||
const directoryPath = join(root(), testDirectory, directory)
|
|
||||||
|
|
||||||
const directoryExists = await pathExists(directoryPath)
|
|
||||||
expect(directoryExists).to.be.true
|
|
||||||
|
|
||||||
const files = await readdir(directoryPath)
|
|
||||||
const filtered = files.filter(f => exceptions.includes(f) === false)
|
|
||||||
|
|
||||||
expect(filtered).to.have.lengthOf(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function killallServers (servers: ServerInfo[]) {
|
async function killallServers (servers: ServerInfo[]) {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
if (!server.app) continue
|
if (!server.app) continue
|
||||||
|
@ -422,71 +385,22 @@ async function cleanupTests (servers: ServerInfo[]) {
|
||||||
await ensureDir('artifacts')
|
await ensureDir('artifacts')
|
||||||
}
|
}
|
||||||
|
|
||||||
const p: Promise<any>[] = []
|
let p: Promise<any>[] = []
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
if (isGithubCI()) {
|
p = p.concat(server.serversCommand.cleanupTests())
|
||||||
const origin = await buildServerDirectory(server, 'logs/peertube.log')
|
|
||||||
const destname = `peertube-${server.internalServerNumber}.log`
|
|
||||||
console.log('Saving logs %s.', destname)
|
|
||||||
|
|
||||||
await copy(origin, join('artifacts', destname))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (server.parallel) {
|
|
||||||
p.push(flushTests(server.internalServerNumber))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (server.customConfigFile) {
|
|
||||||
p.push(remove(server.customConfigFile))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(p)
|
return Promise.all(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitUntilLog (server: ServerInfo, str: string, count = 1, strictCount = true) {
|
|
||||||
const logfile = buildServerDirectory(server, 'logs/peertube.log')
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
const buf = await readFile(logfile)
|
|
||||||
|
|
||||||
const matches = buf.toString().match(new RegExp(str, 'g'))
|
|
||||||
if (matches && matches.length === count) return
|
|
||||||
if (matches && strictCount === false && matches.length >= count) return
|
|
||||||
|
|
||||||
await wait(1000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getServerFileSize (server: ServerInfo, subPath: string) {
|
|
||||||
const path = buildServerDirectory(server, subPath)
|
|
||||||
|
|
||||||
return getFileSize(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
function makePingRequest (server: ServerInfo) {
|
|
||||||
return makeGetRequest({
|
|
||||||
url: server.url,
|
|
||||||
path: '/api/v1/ping',
|
|
||||||
statusCodeExpected: 200
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export {
|
export {
|
||||||
checkDirectoryIsEmpty,
|
|
||||||
checkTmpIsEmpty,
|
|
||||||
getServerFileSize,
|
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
parallelTests,
|
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
flushTests,
|
|
||||||
makePingRequest,
|
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
killallServers,
|
killallServers,
|
||||||
reRunServer,
|
reRunServer,
|
||||||
assignCommands,
|
assignCommands
|
||||||
waitUntilLog
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { isAbsolute, join } from 'path'
|
import { isAbsolute, join } from 'path'
|
||||||
import { HttpStatusCode } from '@shared/core-utils'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { root } from '../miscs/miscs'
|
import { root } from '../miscs/tests'
|
||||||
import {
|
import {
|
||||||
makeDeleteRequest,
|
makeDeleteRequest,
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { ResultList, VideoCaption } from '@shared/models'
|
import { ResultList, VideoCaption } from '@shared/models'
|
||||||
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
|
import { buildAbsoluteFixturePath } from '../miscs'
|
||||||
import { buildAbsoluteFixturePath } from '../miscs/miscs'
|
|
||||||
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||||
|
|
||||||
export class CaptionsCommand extends AbstractCommand {
|
export class CaptionsCommand extends AbstractCommand {
|
||||||
|
|
|
@ -5,9 +5,8 @@ import { omit } from 'lodash'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'
|
import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'
|
||||||
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
|
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
|
||||||
import { buildServerDirectory, wait } from '../miscs/miscs'
|
import { wait } from '../miscs'
|
||||||
import { unwrapBody } from '../requests'
|
import { unwrapBody } from '../requests'
|
||||||
import { waitUntilLog } from '../server/servers'
|
|
||||||
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||||
import { sendRTMPStream, testFfmpegStreamError } from './live'
|
import { sendRTMPStream, testFfmpegStreamError } from './live'
|
||||||
import { getVideoWithToken } from './videos'
|
import { getVideoWithToken } from './videos'
|
||||||
|
@ -116,7 +115,7 @@ export class LiveCommand extends AbstractCommand {
|
||||||
const { resolution, segment, videoUUID } = options
|
const { resolution, segment, videoUUID } = options
|
||||||
const segmentName = `${resolution}-00000${segment}.ts`
|
const segmentName = `${resolution}-00000${segment}.ts`
|
||||||
|
|
||||||
return waitUntilLog(this.server, `${videoUUID}/${segmentName}`, 2, false)
|
return this.server.serversCommand.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilSaved (options: OverrideCommandOptions & {
|
async waitUntilSaved (options: OverrideCommandOptions & {
|
||||||
|
@ -135,7 +134,7 @@ export class LiveCommand extends AbstractCommand {
|
||||||
async countPlaylists (options: OverrideCommandOptions & {
|
async countPlaylists (options: OverrideCommandOptions & {
|
||||||
videoUUID: string
|
videoUUID: string
|
||||||
}) {
|
}) {
|
||||||
const basePath = buildServerDirectory(this.server, 'streaming-playlists')
|
const basePath = this.server.serversCommand.buildDirectory('streaming-playlists')
|
||||||
const hlsPath = join(basePath, 'hls', options.videoUUID)
|
const hlsPath = join(basePath, 'hls', options.videoUUID)
|
||||||
|
|
||||||
const files = await readdir(hlsPath)
|
const files = await readdir(hlsPath)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { expect } from 'chai'
|
||||||
import * as ffmpeg from 'fluent-ffmpeg'
|
import * as ffmpeg from 'fluent-ffmpeg'
|
||||||
import { pathExists, readdir } from 'fs-extra'
|
import { pathExists, readdir } from 'fs-extra'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { buildAbsoluteFixturePath, buildServerDirectory, wait } from '../miscs/miscs'
|
import { buildAbsoluteFixturePath, wait } from '../miscs'
|
||||||
import { ServerInfo } from '../server/servers'
|
import { ServerInfo } from '../server/servers'
|
||||||
|
|
||||||
function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = 'video_short.mp4') {
|
function sendRTMPStream (rtmpBaseUrl: string, streamKey: string, fixtureName = 'video_short.mp4') {
|
||||||
|
@ -77,7 +77,7 @@ async function waitUntilLivePublishedOnAllServers (servers: ServerInfo[], videoI
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
|
async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
|
||||||
const basePath = buildServerDirectory(server, 'streaming-playlists')
|
const basePath = server.serversCommand.buildDirectory('streaming-playlists')
|
||||||
const hlsPath = join(basePath, 'hls', videoUUID)
|
const hlsPath = join(basePath, 'hls', videoUUID)
|
||||||
|
|
||||||
if (resolutions.length === 0) {
|
if (resolutions.length === 0) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { readdir } from 'fs-extra'
|
import { readdir } from 'fs-extra'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { root } from '../'
|
import { root } from '../miscs'
|
||||||
|
|
||||||
async function checkPlaylistFilesWereRemoved (
|
async function checkPlaylistFilesWereRemoved (
|
||||||
playlistUUID: string,
|
playlistUUID: string,
|
||||||
|
|
|
@ -13,15 +13,7 @@ import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { BooleanBothQuery, VideosCommonQuery } from '@shared/models'
|
import { BooleanBothQuery, VideosCommonQuery } from '@shared/models'
|
||||||
import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
|
import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
|
||||||
import { VideoDetails, VideoPrivacy } from '../../models/videos'
|
import { VideoDetails, VideoPrivacy } from '../../models/videos'
|
||||||
import {
|
import { buildAbsoluteFixturePath, dateIsValid, testImage, wait, webtorrentAdd } from '../miscs'
|
||||||
buildAbsoluteFixturePath,
|
|
||||||
buildServerDirectory,
|
|
||||||
dateIsValid,
|
|
||||||
immutableAssign,
|
|
||||||
testImage,
|
|
||||||
wait,
|
|
||||||
webtorrentAdd
|
|
||||||
} from '../miscs/miscs'
|
|
||||||
import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests'
|
import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests'
|
||||||
import { waitJobs } from '../server/jobs'
|
import { waitJobs } from '../server/jobs'
|
||||||
import { ServerInfo } from '../server/servers'
|
import { ServerInfo } from '../server/servers'
|
||||||
|
@ -165,7 +157,7 @@ function getVideosListWithToken (url: string, token: string, query: { nsfw?: Boo
|
||||||
return request(url)
|
return request(url)
|
||||||
.get(path)
|
.get(path)
|
||||||
.set('Authorization', 'Bearer ' + token)
|
.set('Authorization', 'Bearer ' + token)
|
||||||
.query(immutableAssign(query, { sort: 'name' }))
|
.query({ sort: 'name', ...query })
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect(HttpStatusCode.OK_200)
|
.expect(HttpStatusCode.OK_200)
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
|
@ -228,11 +220,7 @@ function getAccountVideos (
|
||||||
return makeGetRequest({
|
return makeGetRequest({
|
||||||
url,
|
url,
|
||||||
path,
|
path,
|
||||||
query: immutableAssign(query, {
|
query: { ...query, start, count, sort },
|
||||||
start,
|
|
||||||
count,
|
|
||||||
sort
|
|
||||||
}),
|
|
||||||
token: accessToken,
|
token: accessToken,
|
||||||
statusCodeExpected: HttpStatusCode.OK_200
|
statusCodeExpected: HttpStatusCode.OK_200
|
||||||
})
|
})
|
||||||
|
@ -252,11 +240,7 @@ function getVideoChannelVideos (
|
||||||
return makeGetRequest({
|
return makeGetRequest({
|
||||||
url,
|
url,
|
||||||
path,
|
path,
|
||||||
query: immutableAssign(query, {
|
query: { ...query, start, count, sort },
|
||||||
start,
|
|
||||||
count,
|
|
||||||
sort
|
|
||||||
}),
|
|
||||||
token: accessToken,
|
token: accessToken,
|
||||||
statusCodeExpected: HttpStatusCode.OK_200
|
statusCodeExpected: HttpStatusCode.OK_200
|
||||||
})
|
})
|
||||||
|
@ -320,7 +304,7 @@ async function removeAllVideos (server: ServerInfo) {
|
||||||
|
|
||||||
async function checkVideoFilesWereRemoved (
|
async function checkVideoFilesWereRemoved (
|
||||||
videoUUID: string,
|
videoUUID: string,
|
||||||
serverNumber: number,
|
server: ServerInfo,
|
||||||
directories = [
|
directories = [
|
||||||
'redundancy',
|
'redundancy',
|
||||||
'videos',
|
'videos',
|
||||||
|
@ -333,7 +317,7 @@ async function checkVideoFilesWereRemoved (
|
||||||
]
|
]
|
||||||
) {
|
) {
|
||||||
for (const directory of directories) {
|
for (const directory of directories) {
|
||||||
const directoryPath = buildServerDirectory({ internalServerNumber: serverNumber }, directory)
|
const directoryPath = server.serversCommand.buildDirectory(directory)
|
||||||
|
|
||||||
const directoryExists = await pathExists(directoryPath)
|
const directoryExists = await pathExists(directoryPath)
|
||||||
if (directoryExists === false) continue
|
if (directoryExists === false) continue
|
||||||
|
@ -607,7 +591,7 @@ function rateVideo (url: string, accessToken: string, id: number | string, ratin
|
||||||
function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) {
|
function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) {
|
||||||
return new Promise<any>((res, rej) => {
|
return new Promise<any>((res, rej) => {
|
||||||
const torrentName = videoUUID + '-' + resolution + '.torrent'
|
const torrentName = videoUUID + '-' + resolution + '.torrent'
|
||||||
const torrentPath = buildServerDirectory(server, join('torrents', torrentName))
|
const torrentPath = server.serversCommand.buildDirectory(join('torrents', torrentName))
|
||||||
|
|
||||||
readFile(torrentPath, (err, data) => {
|
readFile(torrentPath, (err, data) => {
|
||||||
if (err) return rej(err)
|
if (err) return rej(err)
|
||||||
|
|
Loading…
Reference in New Issue