sh ./server/tests/api/travis-1.sh
elif [ "$1" = "api-2" ]; then
npm run build:server
- mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-2.ts
+ sh ./server/tests/api/travis-2.sh
elif [ "$1" = "api-3" ]; then
npm run build:server
- mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-3.ts
+ sh ./server/tests/api/travis-3.sh
elif [ "$1" = "api-4" ]; then
npm run build:server
- mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-4.ts
+ sh ./server/tests/api/travis-4.sh
elif [ "$1" = "lint" ]; then
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"
import * as chai from 'chai'
import 'mocha'
import {
+ cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
flushTests,
const object = res.body
expect(object.type).to.equal('Person')
- expect(object.id).to.equal('http://localhost:9001/accounts/root')
+ expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root')
expect(object.name).to.equal('root')
expect(object.preferredUsername).to.equal('root')
})
const object = res.body
expect(object.type).to.equal('Video')
- expect(object.id).to.equal('http://localhost:9001/videos/watch/' + videoUUID)
+ expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
expect(object.name).to.equal('video')
})
it('Should redirect to the origin video object', async function () {
const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302)
- expect(res.header.location).to.equal('http://localhost:9001/videos/watch/' + videoUUID)
+ expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import 'mocha'
import {
+ cleanupTests,
closeAllSequelize,
createUser,
doubleFollow,
const badVideoUUID = res.body.video.uuid
await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })
- await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1')
- await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID)
+ {
+ const to = 'http://localhost:' + servers[0].port + '/accounts/user1'
+ const value = 'http://localhost:' + servers[1].port + '/accounts/user1'
+ await setActorField(servers[0].internalServerNumber, to, 'url', value)
+ }
+
+ {
+ const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + badVideoUUID
+ await setVideoField(servers[0].internalServerNumber, badVideoUUID, 'url', value)
+ }
})
it('Should add only the video with a valid actor URL', async function () {
})
after(async function () {
- killallServers(servers)
+ this.timeout(10000)
+
+ await cleanupTests(servers)
await closeAllSequelize(servers)
})
import 'mocha'
import {
+ cleanupTests, closeAllSequelize,
createVideoPlaylist,
doubleFollow,
flushAndRunMultipleServers,
generateUserAccessToken,
getVideo,
getVideoPlaylist,
- killallServers, rateVideo,
+ killallServers,
reRunServer,
ServerInfo,
setAccessTokensToServers,
}
{
- const a1 = await generateUserAccessToken(servers[1], 'user1')
- await uploadVideo(servers[1].url, a1, { name: 'video4' })
+ const a1 = await generateUserAccessToken(servers[ 1 ], 'user1')
+ await uploadVideo(servers[ 1 ].url, a1, { name: 'video4' })
- const a2 = await generateUserAccessToken(servers[1], 'user2')
- await uploadVideo(servers[1].url, a2, { name: 'video5' })
+ const a2 = await generateUserAccessToken(servers[ 1 ], 'user2')
+ await uploadVideo(servers[ 1 ].url, a2, { name: 'video5' })
}
{
- const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
- const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
+ const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id }
+ const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })
playlistUUID1 = res.body.videoPlaylist.uuid
}
{
- const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
- const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
+ const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id }
+ const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })
playlistUUID2 = res.body.videoPlaylist.uuid
}
- await doubleFollow(servers[0], servers[1])
+ await doubleFollow(servers[ 0 ], servers[ 1 ])
})
describe('Videos refresher', function () {
await wait(10000)
// Change UUID so the remote server returns a 404
- await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
+ await setVideoField(servers[ 1 ].internalServerNumber, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
await getVideo(servers[ 0 ].url, videoUUID1)
await getVideo(servers[ 0 ].url, videoUUID2)
killallServers([ servers[ 1 ] ])
- await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
+ await setVideoField(servers[ 1 ].internalServerNumber, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
// Video will need a refresh
await wait(10000)
await wait(10000)
// Change actor name so the remote server returns a 404
- await setActorField(2, 'http://localhost:9002/accounts/user2', 'preferredUsername', 'toto')
+ const to = 'http://localhost:' + servers[ 1 ].port + '/accounts/user2'
+ await setActorField(servers[ 1 ].internalServerNumber, to, 'preferredUsername', 'toto')
- await getAccount(servers[ 0 ].url, 'user1@localhost:9002')
- await getAccount(servers[ 0 ].url, 'user2@localhost:9002')
+ await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port)
+ await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port)
await waitJobs(servers)
- await getAccount(servers[ 0 ].url, 'user1@localhost:9002', 200)
- await getAccount(servers[ 0 ].url, 'user2@localhost:9002', 404)
+ await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port, 200)
+ await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port, 404)
})
})
await wait(10000)
// Change UUID so the remote server returns a 404
- await setPlaylistField(2, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
+ await setPlaylistField(servers[ 1 ].internalServerNumber, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
await getVideoPlaylist(servers[ 0 ].url, playlistUUID1)
await getVideoPlaylist(servers[ 0 ].url, playlistUUID2)
})
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ this.timeout(10000)
+
+ await cleanupTests(servers)
+
+ await closeAllSequelize(servers)
})
})
import 'mocha'
import {
+ cleanupTests,
closeAllSequelize,
flushAndRunMultipleServers,
- flushTests,
killallServers,
ServerInfo,
setActorField
const expect = chai.expect
-function setKeysOfServer2 (serverNumber: number, publicKey: string, privateKey: string) {
+function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey: string, privateKey: string) {
return Promise.all([
- setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'publicKey', publicKey),
- setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'privateKey', privateKey)
+ setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'publicKey', publicKey),
+ setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'privateKey', privateKey)
])
}
-function setKeysOfServer3 (serverNumber: number, publicKey: string, privateKey: string) {
- return Promise.all([
- setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'publicKey', publicKey),
- setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'privateKey', privateKey)
- ])
+function getAnnounceWithoutContext (server2: ServerInfo) {
+ const json = require('./json/peertube/announce-without-context.json')
+ const result: typeof json = {}
+
+ for (const key of Object.keys(json)) {
+ if (Array.isArray(json[key])) {
+ result[key] = json[key].map(v => v.replace(':9002', `:${server2.port}`))
+ } else {
+ result[ key ] = json[ key ].replace(':9002', `:${server2.port}`)
+ }
+ }
+
+ return result
}
describe('Test ActivityPub security', function () {
const keys = require('./json/peertube/keys.json')
const invalidKeys = require('./json/peertube/invalid-keys.json')
- const baseHttpSignature = {
+ const baseHttpSignature = () => ({
algorithm: HTTP_SIGNATURE.ALGORITHM,
authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,
- keyId: 'acct:peertube@localhost:9002',
+ keyId: 'acct:peertube@localhost:' + servers[1].port,
key: keys.privateKey,
headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
- }
+ })
// ---------------------------------------------------------------
url = servers[0].url + '/inbox'
- await setKeysOfServer2(1, keys.publicKey, keys.privateKey)
+ await setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey)
- const to = { url: 'http://localhost:9001/accounts/peertube' }
- const by = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey }
+ const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }
+ const by = { url: 'http://localhost:' + servers[1].port + '/accounts/peertube', privateKey: keys.privateKey }
await makeFollowRequest(to, by)
})
describe('When checking HTTP signature', function () {
it('Should fail with an invalid digest', async function () {
- const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))
+ const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
const headers = {
Digest: buildDigest({ hello: 'coucou' })
}
- const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)
+ const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
expect(response.statusCode).to.equal(403)
})
it('Should fail with an invalid date', async function () {
- const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))
+ const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
const headers = buildGlobalHeaders(body)
headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT'
- const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)
+ const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
expect(response.statusCode).to.equal(403)
})
it('Should fail with bad keys', async function () {
- await setKeysOfServer2(1, invalidKeys.publicKey, invalidKeys.privateKey)
- await setKeysOfServer2(2, invalidKeys.publicKey, invalidKeys.privateKey)
+ await setKeysOfServer(servers[0], servers[1], invalidKeys.publicKey, invalidKeys.privateKey)
+ await setKeysOfServer(servers[1], servers[1], invalidKeys.publicKey, invalidKeys.privateKey)
- const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))
+ const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
const headers = buildGlobalHeaders(body)
- const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)
+ const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
expect(response.statusCode).to.equal(403)
})
it('Should succeed with a valid HTTP signature', async function () {
- await setKeysOfServer2(1, keys.publicKey, keys.privateKey)
- await setKeysOfServer2(2, keys.publicKey, keys.privateKey)
+ await setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey)
+ await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey)
- const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))
+ const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
const headers = buildGlobalHeaders(body)
- const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)
+ const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
expect(response.statusCode).to.equal(204)
})
describe('When checking Linked Data Signature', function () {
before(async () => {
- await setKeysOfServer3(3, keys.publicKey, keys.privateKey)
+ await setKeysOfServer(servers[2], servers[2], keys.publicKey, keys.privateKey)
- const to = { url: 'http://localhost:9001/accounts/peertube' }
- const by = { url: 'http://localhost:9003/accounts/peertube', privateKey: keys.privateKey }
+ const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }
+ const by = { url: 'http://localhost:' + servers[2].port + '/accounts/peertube', privateKey: keys.privateKey }
await makeFollowRequest(to, by)
})
it('Should fail with bad keys', async function () {
this.timeout(10000)
- await setKeysOfServer3(1, invalidKeys.publicKey, invalidKeys.privateKey)
- await setKeysOfServer3(3, invalidKeys.publicKey, invalidKeys.privateKey)
+ await setKeysOfServer(servers[0], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)
+ await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)
- const body = require('./json/peertube/announce-without-context.json')
- body.actor = 'http://localhost:9003/accounts/peertube'
+ const body = getAnnounceWithoutContext(servers[1])
+ body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'
- const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:9003/accounts/peertube' }
+ const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }
const signedBody = await buildSignedActivity(signer, body)
const headers = buildGlobalHeaders(signedBody)
- const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers)
+ const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
expect(response.statusCode).to.equal(403)
})
it('Should fail with an altered body', async function () {
this.timeout(10000)
- await setKeysOfServer3(1, keys.publicKey, keys.privateKey)
- await setKeysOfServer3(3, keys.publicKey, keys.privateKey)
+ await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey)
+ await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey)
- const body = require('./json/peertube/announce-without-context.json')
- body.actor = 'http://localhost:9003/accounts/peertube'
+ const body = getAnnounceWithoutContext(servers[1])
+ body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'
- const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:9003/accounts/peertube' }
+ const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }
const signedBody = await buildSignedActivity(signer, body)
- signedBody.actor = 'http://localhost:9003/account/peertube'
+ signedBody.actor = 'http://localhost:' + servers[2].port + '/account/peertube'
const headers = buildGlobalHeaders(signedBody)
- const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers)
+ const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
expect(response.statusCode).to.equal(403)
})
it('Should succeed with a valid signature', async function () {
this.timeout(10000)
- const body = require('./json/peertube/announce-without-context.json')
- body.actor = 'http://localhost:9003/accounts/peertube'
+ const body = getAnnounceWithoutContext(servers[1])
+ body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'
- const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:9003/accounts/peertube' }
+ const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }
const signedBody = await buildSignedActivity(signer, body)
const headers = buildGlobalHeaders(signedBody)
- const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers)
+ const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
expect(response.statusCode).to.equal(204)
})
})
after(async function () {
- killallServers(servers)
+ this.timeout(10000)
+
+ await cleanupTests(servers)
await closeAllSequelize(servers)
})
+++ /dev/null
-import './server'
-import './users'
+++ /dev/null
-import './videos'
+++ /dev/null
-import './redundancy'
-import './activitypub'
// Order of the tests we want to execute
-import './index-1'
-import './index-2'
-import './index-3'
-import './index-4'
+import './activitypub'
+import './check-params'
+import './notifications'
+import './redundancy'
+import './search'
+import './server'
+import './users'
+import './videos'
getAbout,
getConfig,
getCustomConfig,
- killallServers,
+ killallServers, parallelTests,
registerUser,
- reRunServer,
+ reRunServer, ServerInfo,
setAccessTokensToServers,
updateCustomConfig
} from '../../../../shared/extra-utils'
const expect = chai.expect
-function checkInitialConfig (data: CustomConfig) {
+function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
expect(data.instance.name).to.equal('PeerTube')
expect(data.instance.shortDescription).to.equal(
'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
expect(data.signup.limit).to.equal(4)
expect(data.signup.requiresEmailVerification).to.be.false
- expect(data.admin.email).to.equal('admin1@example.com')
+ expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(data.contactForm.enabled).to.be.true
expect(data.user.videoQuota).to.equal(5242880)
expect(data.signup.limit).to.equal(5)
expect(data.signup.requiresEmailVerification).to.be.false
- expect(data.admin.email).to.equal('superadmin1@example.com')
+ // We override admin email in parallel tests, so skip this exception
+ if (parallelTests() === false) {
+ expect(data.admin.email).to.equal('superadmin1@example.com')
+ }
+
expect(data.contactForm.enabled).to.be.false
expect(data.user.videoQuota).to.equal(5242881)
before(async function () {
this.timeout(30000)
+
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
})
const res = await getCustomConfig(server.url, server.accessToken)
const data = res.body as CustomConfig
- checkInitialConfig(data)
+ checkInitialConfig(server, data)
})
it('Should update the customized configuration', async function () {
const res = await getCustomConfig(server.url, server.accessToken)
const data = res.body
- checkInitialConfig(data)
+ checkInitialConfig(server, data)
})
after(async function () {
expect(email['from'][0]['address']).equal('test-admin@localhost')
expect(email['from'][0]['name']).equal('toto@example.com')
- expect(email['to'][0]['address']).equal('admin1@example.com')
+ expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com')
expect(email['subject']).contains('Contact form')
expect(email['text']).contains('my super message')
})
username: 'user_1',
password: 'super_password'
}
+ let emailPort: number
before(async function () {
this.timeout(30000)
- await MockSmtpServer.Instance.collectEmails(emails)
+ emailPort = await MockSmtpServer.Instance.collectEmails(emails)
const overrideConfig = {
smtp: {
- hostname: 'localhost'
+ hostname: 'localhost',
+ port: emailPort
}
}
server = await flushAndRunServer(1, overrideConfig)
expect(email['from'][0]['name']).equal('localhost:' + server.port)
expect(email['from'][0]['address']).equal('test-admin@localhost')
- expect(email['to'][0]['address']).equal('admin1@example.com')
+ expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com')
expect(email['subject']).contains('abuse')
expect(email['text']).contains(videoUUID)
})
const follow = res.body.data[0] as ActorFollow
expect(follow.state).to.equal(state)
- expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + 'accounts/peertube')
+ expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')
expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
}
const follow = res.body.data[0] as ActorFollow
expect(follow.state).to.equal(state)
- expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + 'accounts/peertube')
+ expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')
expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
}
}
it('Should search followers on server 2', async function () {
{
- const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', '9001')
+ const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', servers[0].port + '')
const follows = res.body.data
expect(res.body.total).to.equal(1)
privacy: VideoPrivacy.UNLISTED
})
- const checkAttributes = {
- name: 'my super name for server 1',
- category: 5,
- licence: 4,
- language: 'ja',
- nsfw: true,
- description: 'my super description for server 1',
- support: 'my super support text for server 1',
- account: {
- name: 'root',
- host: 'localhost:' + servers[0].port
- },
- isLocal: false,
- duration: 10,
- tags: [ 'tag1p1', 'tag2p1' ],
- privacy: VideoPrivacy.PUBLIC,
- commentsEnabled: true,
- downloadEnabled: true,
- channel: {
- name: 'root_channel',
- displayName: 'Main root channel',
- description: '',
- isLocal: false
- },
- fixture: 'video_short1.webm',
- files: [
- {
- resolution: 720,
- size: 572456
- }
- ]
- }
-
- const unlistedCheckAttributes = immutableAssign(checkAttributes, {
- privacy: VideoPrivacy.UNLISTED
- })
+ let checkAttributes: any
+ let unlistedCheckAttributes: any
before(async function () {
this.timeout(30000)
servers = await flushAndRunMultipleServers(3)
+ checkAttributes = {
+ name: 'my super name for server 1',
+ category: 5,
+ licence: 4,
+ language: 'ja',
+ nsfw: true,
+ description: 'my super description for server 1',
+ support: 'my super support text for server 1',
+ account: {
+ name: 'root',
+ host: 'localhost:' + servers[0].port
+ },
+ isLocal: false,
+ duration: 10,
+ tags: [ 'tag1p1', 'tag2p1' ],
+ privacy: VideoPrivacy.PUBLIC,
+ commentsEnabled: true,
+ downloadEnabled: true,
+ channel: {
+ name: 'root_channel',
+ displayName: 'Main root channel',
+ description: '',
+ isLocal: false
+ },
+ fixture: 'video_short1.webm',
+ files: [
+ {
+ resolution: 720,
+ size: 572456
+ }
+ ]
+ }
+ unlistedCheckAttributes = immutableAssign(checkAttributes, {
+ privacy: VideoPrivacy.UNLISTED
+ })
+
// Get the access tokens
await setAccessTokensToServers(servers)
})
})
it('Should get logs with an end date', async function () {
- this.timeout(10000)
+ this.timeout(20000)
await uploadVideo(server.url, server.accessToken, { name: 'video 3' })
await waitJobs([ server ])
set -eu
+checkParamFiles=$(find server/tests/api/check-params -type f | grep -v index.ts | xargs echo)
notificationsFiles=$(find server/tests/api/notifications -type f | grep -v index.ts | xargs echo)
searchFiles=$(find server/tests/api/search -type f | grep -v index.ts | xargs echo)
-checkParamFiles=$(find server/tests/api/check-params -type f | grep -v index.ts | xargs echo)
-MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 4 --timeout 5000 --exit --require ts-node/register --bail \
+MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \
$notificationsFiles $searchFiles $checkParamFiles
--- /dev/null
+#!/usr/bin/env sh
+
+set -eu
+
+serverFiles=$(find server/tests/api/server -type f | grep -v index.ts | xargs echo)
+usersFiles=$(find server/tests/api/users -type f | grep -v index.ts | xargs echo)
+
+MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \
+ $serverFiles $usersFiles
--- /dev/null
+#!/usr/bin/env sh
+
+set -eu
+
+videosFiles=$(find server/tests/api/videos -type f | grep -v index.ts | xargs echo)
+
+MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \
+ $videosFiles
--- /dev/null
+#!/usr/bin/env sh
+
+set -eu
+
+redundancyFiles=$(find server/tests/api/redundancy -type f | grep -v index.ts | xargs echo)
+activitypubFiles=$(find server/tests/api/activitypub -type f | grep -v index.ts | xargs echo)
+
+MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \
+ $redundancyFiles $activitypubFiles
it('User of server 1 should follow user of server 3 and root of server 1', async function () {
this.timeout(60000)
- await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003')
- await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001')
+ await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)
+ await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port)
await waitJobs(servers)
it('Should get subscription', async function () {
{
- const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:9003')
+ const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:' + servers[2].port)
const videoChannel: VideoChannel = res.body
expect(videoChannel.name).to.equal('user3_channel')
- expect(videoChannel.host).to.equal('localhost:9003')
+ expect(videoChannel.host).to.equal('localhost:' + servers[2].port)
expect(videoChannel.displayName).to.equal('Main user3 channel')
expect(videoChannel.followingCount).to.equal(0)
expect(videoChannel.followersCount).to.equal(1)
}
{
- const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:9001')
+ const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:' + servers[0].port)
const videoChannel: VideoChannel = res.body
expect(videoChannel.name).to.equal('root_channel')
- expect(videoChannel.host).to.equal('localhost:9001')
+ expect(videoChannel.host).to.equal('localhost:' + servers[0].port)
expect(videoChannel.displayName).to.equal('Main root channel')
expect(videoChannel.followingCount).to.equal(0)
expect(videoChannel.followersCount).to.equal(1)
it('Should return the existing subscriptions', async function () {
const uris = [
- 'user3_channel@localhost:9003',
- 'root2_channel@localhost:9001',
- 'root_channel@localhost:9001',
- 'user3_channel@localhost:9001'
+ 'user3_channel@localhost:' + servers[2].port,
+ 'root2_channel@localhost:' + servers[0].port,
+ 'root_channel@localhost:' + servers[0].port,
+ 'user3_channel@localhost:' + servers[0].port
]
const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris)
const body = res.body
- expect(body['user3_channel@localhost:9003']).to.be.true
- expect(body['root2_channel@localhost:9001']).to.be.false
- expect(body['root_channel@localhost:9001']).to.be.true
- expect(body['user3_channel@localhost:9001']).to.be.false
+ expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true
+ expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false
+ expect(body['root_channel@localhost:' + servers[0].port]).to.be.true
+ expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false
})
it('Should list subscription videos', async function () {
it('Should remove user of server 3 subscription', async function () {
this.timeout(30000)
- await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003')
+ await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)
await waitJobs(servers)
})
it('Should remove the root subscription and not display the videos anymore', async function () {
this.timeout(30000)
- await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001')
+ await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port)
await waitJobs(servers)
it('Should follow user of server 3 again', async function () {
this.timeout(60000)
- await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003')
+ await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)
await waitJobs(servers)
for (const server of servers) {
const resAccounts = await getAccountsList(server.url, '-createdAt')
- const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:9001') as Account
+ const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port) as Account
expect(rootServer1List).not.to.be.undefined
const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host)
const rootServer1Get = resAccount.body as Account
expect(rootServer1Get.name).to.equal('root')
- expect(rootServer1Get.host).to.equal('localhost:9001')
+ expect(rootServer1Get.host).to.equal('localhost:' + servers[0].port)
expect(rootServer1Get.displayName).to.equal('my super display name')
expect(rootServer1Get.description).to.equal('my super description updated')
for (const server of servers) {
const resAccounts = await getAccountsList(server.url, '-createdAt')
- const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account
+ const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account
expect(accountDeleted).not.to.be.undefined
const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
const videoChannelDeleted = resVideoChannels.body.data.find(a => {
- return a.displayName === 'Main user1 channel' && a.host === 'localhost:9001'
+ return a.displayName === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port
}) as VideoChannel
expect(videoChannelDeleted).not.to.be.undefined
}
for (const server of servers) {
const resAccounts = await getAccountsList(server.url, '-createdAt')
- const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account
+ const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account
expect(accountDeleted).to.be.undefined
const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
const videoChannelDeleted = resVideoChannels.body.data.find(a => {
- return a.name === 'Main user1 channel' && a.host === 'localhost:9001'
+ return a.name === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port
}) as VideoChannel
expect(videoChannelDeleted).to.be.undefined
}
it('Should not have actor files', async () => {
for (const server of servers) {
- await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber)
- await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber)
+ await checkActorFilesWereRemoved(userAccountUUID, server.internalServerNumber)
+ await checkActorFilesWereRemoved(userVideoChannelUUID, server.internalServerNumber)
}
})
it('Should not have video files', async () => {
for (const server of servers) {
- await checkVideoFilesWereRemoved(videoUUID, server.serverNumber)
+ await checkVideoFilesWereRemoved(videoUUID, server.internalServerNumber)
}
})
const rootUser = users[ 1 ]
expect(rootUser.username).to.equal('root')
- expect(rootUser.email).to.equal('admin1@example.com')
+ expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(user.nsfwPolicy).to.equal('display')
userId = user.id
const user = users[ 0 ]
expect(user.username).to.equal('root')
- expect(user.email).to.equal('admin1@example.com')
+ expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(user.roleLabel).to.equal('Administrator')
expect(user.nsfwPolicy).to.equal('display')
})
expect(users.length).to.equal(2)
expect(users[ 0 ].username).to.equal('root')
- expect(users[ 0 ].email).to.equal('admin1@example.com')
+ expect(users[ 0 ].email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(users[ 0 ].nsfwPolicy).to.equal('display')
expect(users[ 1 ].username).to.equal('user_1')
// All servers should have this video
let publishedAt: string = null
for (const server of servers) {
- const isLocal = server.url === 'http://localhost:' + servers[0].port
+ const isLocal = server.port === servers[0].port
const checkAttributes = {
name: 'my super name for server 1',
category: 5,
let videoUUID = ''
let videosListBase: any[] = null
- const getCheckAttributes = {
+ const getCheckAttributes = () => ({
name: 'my super name',
category: 2,
licence: 6,
size: 218910
}
]
- }
+ })
- const updateCheckAttributes = {
+ const updateCheckAttributes = () => ({
name: 'my super video updated',
category: 4,
licence: 2,
size: 292677
}
]
- }
+ })
before(async function () {
this.timeout(30000)
expect(res.body.data.length).to.equal(1)
const video = res.body.data[0]
- await completeVideoCheck(server.url, video, getCheckAttributes)
+ await completeVideoCheck(server.url, video, getCheckAttributes())
})
it('Should get the video by UUID', async function () {
const res = await getVideo(server.url, videoUUID)
const video = res.body
- await completeVideoCheck(server.url, video, getCheckAttributes)
+ await completeVideoCheck(server.url, video, getCheckAttributes())
})
it('Should have the views updated', async function () {
const res = await getVideo(server.url, videoId)
const video = res.body
- await completeVideoCheck(server.url, video, updateCheckAttributes)
+ await completeVideoCheck(server.url, video, updateCheckAttributes())
})
it('Should update only the tags of a video', async function () {
const res = await getVideo(server.url, videoId)
const video = res.body
- await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes))
+ await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes(), attributes))
})
it('Should update only the description of a video', async function () {
const res = await getVideo(server.url, videoId)
const video = res.body
- await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes))
+ const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes)
+ await completeVideoCheck(server.url, video, expectedAttributes)
})
it('Should like a video', async function () {
import 'mocha'
import {
acceptChangeOwnership,
- changeVideoOwnership, cleanupTests,
+ changeVideoOwnership,
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
getVideo,
getVideoChangeOwnershipList,
getVideosList,
- killallServers,
refuseChangeOwnership,
ServerInfo,
setAccessTokensToServers,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
let videoUUID: string
before(async function () {
- this.timeout(30000)
+ this.timeout(60000)
servers = await flushAndRunMultipleServers(2)
this.timeout(10000)
for (const server of servers) {
- const channelURI = 'second_video_channel@localhost:' + server.port
+ const channelURI = 'second_video_channel@localhost:' + servers[0].port
const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
expect(res1.body.total).to.equal(1)
expect(res1.body.data).to.be.an('array')
this.timeout(10000)
for (const server of servers) {
- const secondChannelURI = 'second_video_channel@localhost:' + server.port
+ const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5)
expect(res1.body.total).to.equal(0)
- const channelURI = 'root_channel@localhost:' + server.port
+ const channelURI = 'root_channel@localhost:' + servers[0].port
const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
expect(res2.body.total).to.equal(1)
{
for (const resolution of resolutions) {
- const res2 = await getPlaylist(`http://localhost:${server.port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`)
+ const res2 = await getPlaylist(`http://localhost:${servers[0].port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`)
const subPlaylist = res2.text
expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`)
}
{
- const baseUrl = 'http://localhost:' + server.port + '/static/streaming-playlists/hls'
+ const baseUrl = 'http://localhost:' + servers[0].port + '/static/streaming-playlists/hls'
for (const resolution of resolutions) {
await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist)
for (const server of servers) {
const results = [
- await getAccountPlaylistsList(server.url, 'root@localhost:9002', 0, 5, '-createdAt'),
+ await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'),
await getVideoPlaylistsList(server.url, 0, 2, '-createdAt')
]
this.timeout(30000)
for (const server of servers) {
- await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber)
+ await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber)
}
})
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
- uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests
+ uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests, closeAllSequelize
} from '../../../../shared/extra-utils'
import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
import { VideosOverview } from '../../../../shared/models/overviews'
{
for (const server of servers) {
- const total = await countVideoViewsOf(server.serverNumber, videoIdServer1)
+ const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)
expect(total).to.equal(2)
}
}
{
for (const server of servers) {
- const total = await countVideoViewsOf(server.serverNumber, videoIdServer2)
+ const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2)
expect(total).to.equal(2)
}
}
it('Should clean old video views', async function () {
this.timeout(50000)
- this.timeout(50000)
-
killallServers([ servers[0] ])
await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } })
{
for (const server of servers) {
- const total = await countVideoViewsOf(server.serverNumber, videoIdServer1)
+ const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)
expect(total).to.equal(2)
}
}
{
- const totalServer1 = await countVideoViewsOf(servers[0].serverNumber, videoIdServer2)
+ const totalServer1 = await countVideoViewsOf(servers[0].internalServerNumber, videoIdServer2)
expect(totalServer1).to.equal(0)
- const totalServer2 = await countVideoViewsOf(servers[1].serverNumber, videoIdServer2)
+ const totalServer2 = await countVideoViewsOf(servers[1].internalServerNumber, videoIdServer2)
expect(totalServer2).to.equal(2)
}
})
after(async function () {
+ await closeAllSequelize(servers)
+
await cleanupTests(servers)
})
})
import { QueryTypes, Sequelize } from 'sequelize'
+import { ServerInfo } from '../server/servers'
let sequelizes: { [ id: number ]: Sequelize } = {}
-function getSequelize (serverNumber: number) {
- if (sequelizes[serverNumber]) return sequelizes[serverNumber]
+function getSequelize (internalServerNumber: number) {
+ if (sequelizes[internalServerNumber]) return sequelizes[internalServerNumber]
- const dbname = 'peertube_test' + serverNumber
+ const dbname = 'peertube_test' + internalServerNumber
const username = 'peertube'
const password = 'peertube'
const host = 'localhost'
logging: false
})
- sequelizes[serverNumber] = seq
+ sequelizes[internalServerNumber] = seq
return seq
}
-function setActorField (serverNumber: number, to: string, field: string, value: string) {
- const seq = getSequelize(serverNumber)
+function setActorField (internalServerNumber: number, to: string, field: string, value: string) {
+ const seq = getSequelize(internalServerNumber)
const options = { type: QueryTypes.UPDATE }
return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options)
}
-function setVideoField (serverNumber: number, uuid: string, field: string, value: string) {
- const seq = getSequelize(serverNumber)
+function setVideoField (internalServerNumber: number, uuid: string, field: string, value: string) {
+ const seq = getSequelize(internalServerNumber)
const options = { type: QueryTypes.UPDATE }
return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
}
-function setPlaylistField (serverNumber: number, uuid: string, field: string, value: string) {
- const seq = getSequelize(serverNumber)
+function setPlaylistField (internalServerNumber: number, uuid: string, field: string, value: string) {
+ const seq = getSequelize(internalServerNumber)
const options = { type: QueryTypes.UPDATE }
return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
}
-async function countVideoViewsOf (serverNumber: number, uuid: string) {
- const seq = getSequelize(serverNumber)
+async function countVideoViewsOf (internalServerNumber: number, uuid: string) {
+ const seq = getSequelize(internalServerNumber)
// tslint:disable
const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'`
return parseInt(total + '', 10)
}
-async function closeAllSequelize (servers: any[]) {
- for (let i = 1; i <= servers.length; i++) {
- if (sequelizes[ i ]) {
- await sequelizes[ i ].close()
- delete sequelizes[ i ]
+async function closeAllSequelize (servers: ServerInfo[]) {
+ for (const server of servers) {
+ if (sequelizes[ server.internalServerNumber ]) {
+ await sequelizes[ server.internalServerNumber ].close()
+ delete sequelizes[ server.internalServerNumber ]
}
}
}
}
async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) {
- const testDirectory = 'test' + server.serverNumber
+ const testDirectory = 'test' + server.internalServerNumber
const directoryPath = join(root(), testDirectory, directory)
async function checkPlaylistFilesWereRemoved (
playlistUUID: string,
- serverNumber: number,
+ internalServerNumber: number,
directories = [ 'thumbnails' ]
) {
- const testDirectory = 'test' + serverNumber
+ const testDirectory = 'test' + internalServerNumber
for (const directory of directories) {
const directoryPath = join(root(), testDirectory, directory)
expect(file).not.to.be.undefined
let extension = extname(attributes.fixture)
- // Transcoding enabled on server 2, extension will always be .mp4
- if (attributes.account.host === 'localhost:9002') extension = '.mp4'
+ // Transcoding enabled: extension will always be .mp4
+ if (attributes.files.length > 1) extension = '.mp4'
const magnetUri = file.magnetUri
expect(file.magnetUri).to.have.lengthOf.above(2)