All API tests in parallel
This commit is contained in:
parent
7243f84db0
commit
48f07b4a40
34 changed files with 286 additions and 222 deletions
|
@ -23,13 +23,13 @@ elif [ "$1" = "api-1" ]; then
|
||||||
sh ./server/tests/api/travis-1.sh
|
sh ./server/tests/api/travis-1.sh
|
||||||
elif [ "$1" = "api-2" ]; then
|
elif [ "$1" = "api-2" ]; then
|
||||||
npm run build:server
|
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
|
elif [ "$1" = "api-3" ]; then
|
||||||
npm run build:server
|
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
|
elif [ "$1" = "api-4" ]; then
|
||||||
npm run build:server
|
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
|
elif [ "$1" = "lint" ]; then
|
||||||
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"
|
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import {
|
import {
|
||||||
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
flushTests,
|
flushTests,
|
||||||
|
@ -39,7 +40,7 @@ describe('Test activitypub', function () {
|
||||||
const object = res.body
|
const object = res.body
|
||||||
|
|
||||||
expect(object.type).to.equal('Person')
|
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.name).to.equal('root')
|
||||||
expect(object.preferredUsername).to.equal('root')
|
expect(object.preferredUsername).to.equal('root')
|
||||||
})
|
})
|
||||||
|
@ -49,17 +50,17 @@ describe('Test activitypub', function () {
|
||||||
const object = res.body
|
const object = res.body
|
||||||
|
|
||||||
expect(object.type).to.equal('Video')
|
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')
|
expect(object.name).to.equal('video')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should redirect to the origin video object', async function () {
|
it('Should redirect to the origin video object', async function () {
|
||||||
const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302)
|
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 () {
|
after(async function () {
|
||||||
killallServers(servers)
|
await cleanupTests(servers)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
cleanupTests,
|
||||||
closeAllSequelize,
|
closeAllSequelize,
|
||||||
createUser,
|
createUser,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
|
@ -48,8 +49,16 @@ describe('Test ActivityPub fetcher', function () {
|
||||||
const badVideoUUID = res.body.video.uuid
|
const badVideoUUID = res.body.video.uuid
|
||||||
await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })
|
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 () {
|
it('Should add only the video with a valid actor URL', async function () {
|
||||||
|
@ -78,7 +87,9 @@ describe('Test ActivityPub fetcher', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
killallServers(servers)
|
this.timeout(10000)
|
||||||
|
|
||||||
|
await cleanupTests(servers)
|
||||||
|
|
||||||
await closeAllSequelize(servers)
|
await closeAllSequelize(servers)
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import {
|
import {
|
||||||
|
cleanupTests, closeAllSequelize,
|
||||||
createVideoPlaylist,
|
createVideoPlaylist,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
generateUserAccessToken,
|
generateUserAccessToken,
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideoPlaylist,
|
getVideoPlaylist,
|
||||||
killallServers, rateVideo,
|
killallServers,
|
||||||
reRunServer,
|
reRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
|
@ -48,26 +49,26 @@ describe('Test AP refresher', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const a1 = await generateUserAccessToken(servers[1], 'user1')
|
const a1 = await generateUserAccessToken(servers[ 1 ], 'user1')
|
||||||
await uploadVideo(servers[1].url, a1, { name: 'video4' })
|
await uploadVideo(servers[ 1 ].url, a1, { name: 'video4' })
|
||||||
|
|
||||||
const a2 = await generateUserAccessToken(servers[1], 'user2')
|
const a2 = await generateUserAccessToken(servers[ 1 ], 'user2')
|
||||||
await uploadVideo(servers[1].url, a2, { name: 'video5' })
|
await uploadVideo(servers[ 1 ].url, a2, { name: 'video5' })
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
|
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 res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })
|
||||||
playlistUUID1 = res.body.videoPlaylist.uuid
|
playlistUUID1 = res.body.videoPlaylist.uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
|
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 res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })
|
||||||
playlistUUID2 = res.body.videoPlaylist.uuid
|
playlistUUID2 = res.body.videoPlaylist.uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
await doubleFollow(servers[0], servers[1])
|
await doubleFollow(servers[ 0 ], servers[ 1 ])
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Videos refresher', function () {
|
describe('Videos refresher', function () {
|
||||||
|
@ -78,7 +79,7 @@ describe('Test AP refresher', function () {
|
||||||
await wait(10000)
|
await wait(10000)
|
||||||
|
|
||||||
// Change UUID so the remote server returns a 404
|
// 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, videoUUID1)
|
||||||
await getVideo(servers[ 0 ].url, videoUUID2)
|
await getVideo(servers[ 0 ].url, videoUUID2)
|
||||||
|
@ -94,7 +95,7 @@ describe('Test AP refresher', function () {
|
||||||
|
|
||||||
killallServers([ servers[ 1 ] ])
|
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
|
// Video will need a refresh
|
||||||
await wait(10000)
|
await wait(10000)
|
||||||
|
@ -121,15 +122,16 @@ describe('Test AP refresher', function () {
|
||||||
await wait(10000)
|
await wait(10000)
|
||||||
|
|
||||||
// Change actor name so the remote server returns a 404
|
// 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, 'user1@localhost:' + servers[ 1 ].port)
|
||||||
await getAccount(servers[ 0 ].url, 'user2@localhost:9002')
|
await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await getAccount(servers[ 0 ].url, 'user1@localhost:9002', 200)
|
await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port, 200)
|
||||||
await getAccount(servers[ 0 ].url, 'user2@localhost:9002', 404)
|
await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port, 404)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -141,7 +143,7 @@ describe('Test AP refresher', function () {
|
||||||
await wait(10000)
|
await wait(10000)
|
||||||
|
|
||||||
// Change UUID so the remote server returns a 404
|
// 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, playlistUUID1)
|
||||||
await getVideoPlaylist(servers[ 0 ].url, playlistUUID2)
|
await getVideoPlaylist(servers[ 0 ].url, playlistUUID2)
|
||||||
|
@ -153,7 +155,11 @@ describe('Test AP refresher', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
after(function () {
|
after(async function () {
|
||||||
killallServers(servers)
|
this.timeout(10000)
|
||||||
|
|
||||||
|
await cleanupTests(servers)
|
||||||
|
|
||||||
|
await closeAllSequelize(servers)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
cleanupTests,
|
||||||
closeAllSequelize,
|
closeAllSequelize,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
flushTests,
|
|
||||||
killallServers,
|
killallServers,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setActorField
|
setActorField
|
||||||
|
@ -18,18 +18,26 @@ import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-u
|
||||||
|
|
||||||
const expect = chai.expect
|
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([
|
return Promise.all([
|
||||||
setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'publicKey', publicKey),
|
setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'publicKey', publicKey),
|
||||||
setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'privateKey', privateKey)
|
setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'privateKey', privateKey)
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
function setKeysOfServer3 (serverNumber: number, publicKey: string, privateKey: string) {
|
function getAnnounceWithoutContext (server2: ServerInfo) {
|
||||||
return Promise.all([
|
const json = require('./json/peertube/announce-without-context.json')
|
||||||
setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'publicKey', publicKey),
|
const result: typeof json = {}
|
||||||
setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'privateKey', privateKey)
|
|
||||||
])
|
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 () {
|
describe('Test ActivityPub security', function () {
|
||||||
|
@ -38,13 +46,13 @@ describe('Test ActivityPub security', function () {
|
||||||
|
|
||||||
const keys = require('./json/peertube/keys.json')
|
const keys = require('./json/peertube/keys.json')
|
||||||
const invalidKeys = require('./json/peertube/invalid-keys.json')
|
const invalidKeys = require('./json/peertube/invalid-keys.json')
|
||||||
const baseHttpSignature = {
|
const baseHttpSignature = () => ({
|
||||||
algorithm: HTTP_SIGNATURE.ALGORITHM,
|
algorithm: HTTP_SIGNATURE.ALGORITHM,
|
||||||
authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,
|
authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,
|
||||||
keyId: 'acct:peertube@localhost:9002',
|
keyId: 'acct:peertube@localhost:' + servers[1].port,
|
||||||
key: keys.privateKey,
|
key: keys.privateKey,
|
||||||
headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
|
headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
|
||||||
}
|
})
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -55,56 +63,56 @@ describe('Test ActivityPub security', function () {
|
||||||
|
|
||||||
url = servers[0].url + '/inbox'
|
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 to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }
|
||||||
const by = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey }
|
const by = { url: 'http://localhost:' + servers[1].port + '/accounts/peertube', privateKey: keys.privateKey }
|
||||||
await makeFollowRequest(to, by)
|
await makeFollowRequest(to, by)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When checking HTTP signature', function () {
|
describe('When checking HTTP signature', function () {
|
||||||
|
|
||||||
it('Should fail with an invalid digest', async 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 = {
|
const headers = {
|
||||||
Digest: buildDigest({ hello: 'coucou' })
|
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)
|
expect(response.statusCode).to.equal(403)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid date', async function () {
|
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)
|
const headers = buildGlobalHeaders(body)
|
||||||
headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT'
|
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)
|
expect(response.statusCode).to.equal(403)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with bad keys', async function () {
|
it('Should fail with bad keys', async function () {
|
||||||
await setKeysOfServer2(1, invalidKeys.publicKey, invalidKeys.privateKey)
|
await setKeysOfServer(servers[0], servers[1], invalidKeys.publicKey, invalidKeys.privateKey)
|
||||||
await setKeysOfServer2(2, 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 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)
|
expect(response.statusCode).to.equal(403)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should succeed with a valid HTTP signature', async function () {
|
it('Should succeed with a valid HTTP signature', async function () {
|
||||||
await setKeysOfServer2(1, keys.publicKey, keys.privateKey)
|
await setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey)
|
||||||
await setKeysOfServer2(2, 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 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)
|
expect(response.statusCode).to.equal(204)
|
||||||
})
|
})
|
||||||
|
@ -112,28 +120,28 @@ describe('Test ActivityPub security', function () {
|
||||||
|
|
||||||
describe('When checking Linked Data Signature', function () {
|
describe('When checking Linked Data Signature', function () {
|
||||||
before(async () => {
|
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 to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }
|
||||||
const by = { url: 'http://localhost:9003/accounts/peertube', privateKey: keys.privateKey }
|
const by = { url: 'http://localhost:' + servers[2].port + '/accounts/peertube', privateKey: keys.privateKey }
|
||||||
await makeFollowRequest(to, by)
|
await makeFollowRequest(to, by)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with bad keys', async function () {
|
it('Should fail with bad keys', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await setKeysOfServer3(1, invalidKeys.publicKey, invalidKeys.privateKey)
|
await setKeysOfServer(servers[0], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)
|
||||||
await setKeysOfServer3(3, invalidKeys.publicKey, invalidKeys.privateKey)
|
await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)
|
||||||
|
|
||||||
const body = require('./json/peertube/announce-without-context.json')
|
const body = getAnnounceWithoutContext(servers[1])
|
||||||
body.actor = 'http://localhost:9003/accounts/peertube'
|
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 signedBody = await buildSignedActivity(signer, body)
|
||||||
|
|
||||||
const headers = buildGlobalHeaders(signedBody)
|
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)
|
expect(response.statusCode).to.equal(403)
|
||||||
})
|
})
|
||||||
|
@ -141,20 +149,20 @@ describe('Test ActivityPub security', function () {
|
||||||
it('Should fail with an altered body', async function () {
|
it('Should fail with an altered body', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
await setKeysOfServer3(1, keys.publicKey, keys.privateKey)
|
await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey)
|
||||||
await setKeysOfServer3(3, keys.publicKey, keys.privateKey)
|
await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey)
|
||||||
|
|
||||||
const body = require('./json/peertube/announce-without-context.json')
|
const body = getAnnounceWithoutContext(servers[1])
|
||||||
body.actor = 'http://localhost:9003/accounts/peertube'
|
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 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 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)
|
expect(response.statusCode).to.equal(403)
|
||||||
})
|
})
|
||||||
|
@ -162,22 +170,24 @@ describe('Test ActivityPub security', function () {
|
||||||
it('Should succeed with a valid signature', async function () {
|
it('Should succeed with a valid signature', async function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
const body = require('./json/peertube/announce-without-context.json')
|
const body = getAnnounceWithoutContext(servers[1])
|
||||||
body.actor = 'http://localhost:9003/accounts/peertube'
|
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 signedBody = await buildSignedActivity(signer, body)
|
||||||
|
|
||||||
const headers = buildGlobalHeaders(signedBody)
|
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)
|
expect(response.statusCode).to.equal(204)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
killallServers(servers)
|
this.timeout(10000)
|
||||||
|
|
||||||
|
await cleanupTests(servers)
|
||||||
|
|
||||||
await closeAllSequelize(servers)
|
await closeAllSequelize(servers)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
import './server'
|
|
||||||
import './users'
|
|
|
@ -1 +0,0 @@
|
||||||
import './videos'
|
|
|
@ -1,2 +0,0 @@
|
||||||
import './redundancy'
|
|
||||||
import './activitypub'
|
|
|
@ -1,5 +1,9 @@
|
||||||
// Order of the tests we want to execute
|
// Order of the tests we want to execute
|
||||||
import './index-1'
|
import './activitypub'
|
||||||
import './index-2'
|
import './check-params'
|
||||||
import './index-3'
|
import './notifications'
|
||||||
import './index-4'
|
import './redundancy'
|
||||||
|
import './search'
|
||||||
|
import './server'
|
||||||
|
import './users'
|
||||||
|
import './videos'
|
||||||
|
|
|
@ -11,9 +11,9 @@ import {
|
||||||
getAbout,
|
getAbout,
|
||||||
getConfig,
|
getConfig,
|
||||||
getCustomConfig,
|
getCustomConfig,
|
||||||
killallServers,
|
killallServers, parallelTests,
|
||||||
registerUser,
|
registerUser,
|
||||||
reRunServer,
|
reRunServer, ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
updateCustomConfig
|
updateCustomConfig
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
|
@ -21,7 +21,7 @@ import { ServerConfig } from '../../../../shared/models'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
function checkInitialConfig (data: CustomConfig) {
|
function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
|
||||||
expect(data.instance.name).to.equal('PeerTube')
|
expect(data.instance.name).to.equal('PeerTube')
|
||||||
expect(data.instance.shortDescription).to.equal(
|
expect(data.instance.shortDescription).to.equal(
|
||||||
'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
|
'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
|
||||||
|
@ -45,7 +45,7 @@ function checkInitialConfig (data: CustomConfig) {
|
||||||
expect(data.signup.limit).to.equal(4)
|
expect(data.signup.limit).to.equal(4)
|
||||||
expect(data.signup.requiresEmailVerification).to.be.false
|
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.contactForm.enabled).to.be.true
|
||||||
|
|
||||||
expect(data.user.videoQuota).to.equal(5242880)
|
expect(data.user.videoQuota).to.equal(5242880)
|
||||||
|
@ -89,7 +89,11 @@ function checkUpdatedConfig (data: CustomConfig) {
|
||||||
expect(data.signup.limit).to.equal(5)
|
expect(data.signup.limit).to.equal(5)
|
||||||
expect(data.signup.requiresEmailVerification).to.be.false
|
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.contactForm.enabled).to.be.false
|
||||||
|
|
||||||
expect(data.user.videoQuota).to.equal(5242881)
|
expect(data.user.videoQuota).to.equal(5242881)
|
||||||
|
@ -118,6 +122,7 @@ describe('Test config', function () {
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
server = await flushAndRunServer(1)
|
server = await flushAndRunServer(1)
|
||||||
await setAccessTokensToServers([ server ])
|
await setAccessTokensToServers([ server ])
|
||||||
})
|
})
|
||||||
|
@ -160,7 +165,7 @@ describe('Test config', function () {
|
||||||
const res = await getCustomConfig(server.url, server.accessToken)
|
const res = await getCustomConfig(server.url, server.accessToken)
|
||||||
const data = res.body as CustomConfig
|
const data = res.body as CustomConfig
|
||||||
|
|
||||||
checkInitialConfig(data)
|
checkInitialConfig(server, data)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should update the customized configuration', async function () {
|
it('Should update the customized configuration', async function () {
|
||||||
|
@ -297,7 +302,7 @@ describe('Test config', function () {
|
||||||
const res = await getCustomConfig(server.url, server.accessToken)
|
const res = await getCustomConfig(server.url, server.accessToken)
|
||||||
const data = res.body
|
const data = res.body
|
||||||
|
|
||||||
checkInitialConfig(data)
|
checkInitialConfig(server, data)
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
|
|
@ -54,7 +54,7 @@ describe('Test contact form', function () {
|
||||||
|
|
||||||
expect(email['from'][0]['address']).equal('test-admin@localhost')
|
expect(email['from'][0]['address']).equal('test-admin@localhost')
|
||||||
expect(email['from'][0]['name']).equal('toto@example.com')
|
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['subject']).contains('Contact form')
|
||||||
expect(email['text']).contains('my super message')
|
expect(email['text']).contains('my super message')
|
||||||
})
|
})
|
||||||
|
|
|
@ -37,15 +37,17 @@ describe('Test emails', function () {
|
||||||
username: 'user_1',
|
username: 'user_1',
|
||||||
password: 'super_password'
|
password: 'super_password'
|
||||||
}
|
}
|
||||||
|
let emailPort: number
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
await MockSmtpServer.Instance.collectEmails(emails)
|
emailPort = await MockSmtpServer.Instance.collectEmails(emails)
|
||||||
|
|
||||||
const overrideConfig = {
|
const overrideConfig = {
|
||||||
smtp: {
|
smtp: {
|
||||||
hostname: 'localhost'
|
hostname: 'localhost',
|
||||||
|
port: emailPort
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
server = await flushAndRunServer(1, overrideConfig)
|
server = await flushAndRunServer(1, overrideConfig)
|
||||||
|
@ -134,7 +136,7 @@ describe('Test emails', function () {
|
||||||
|
|
||||||
expect(email['from'][0]['name']).equal('localhost:' + server.port)
|
expect(email['from'][0]['name']).equal('localhost:' + server.port)
|
||||||
expect(email['from'][0]['address']).equal('test-admin@localhost')
|
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['subject']).contains('abuse')
|
||||||
expect(email['text']).contains(videoUUID)
|
expect(email['text']).contains(videoUUID)
|
||||||
})
|
})
|
||||||
|
|
|
@ -29,7 +29,7 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
|
||||||
|
|
||||||
const follow = res.body.data[0] as ActorFollow
|
const follow = res.body.data[0] as ActorFollow
|
||||||
expect(follow.state).to.equal(state)
|
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')
|
expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
|
||||||
|
|
||||||
const follow = res.body.data[0] as ActorFollow
|
const follow = res.body.data[0] as ActorFollow
|
||||||
expect(follow.state).to.equal(state)
|
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')
|
expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ describe('Test follows', function () {
|
||||||
|
|
||||||
it('Should search followers on server 2', async function () {
|
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
|
const follows = res.body.data
|
||||||
|
|
||||||
expect(res.body.total).to.equal(1)
|
expect(res.body.total).to.equal(1)
|
||||||
|
|
|
@ -60,48 +60,50 @@ describe('Test handle downs', function () {
|
||||||
privacy: VideoPrivacy.UNLISTED
|
privacy: VideoPrivacy.UNLISTED
|
||||||
})
|
})
|
||||||
|
|
||||||
const checkAttributes = {
|
let checkAttributes: any
|
||||||
name: 'my super name for server 1',
|
let unlistedCheckAttributes: any
|
||||||
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
|
|
||||||
})
|
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
servers = await flushAndRunMultipleServers(3)
|
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
|
// Get the access tokens
|
||||||
await setAccessTokensToServers(servers)
|
await setAccessTokensToServers(servers)
|
||||||
})
|
})
|
||||||
|
|
|
@ -45,7 +45,7 @@ describe('Test logs', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should get logs with an end date', async function () {
|
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 uploadVideo(server.url, server.accessToken, { name: 'video 3' })
|
||||||
await waitJobs([ server ])
|
await waitJobs([ server ])
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
set -eu
|
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)
|
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)
|
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
|
$notificationsFiles $searchFiles $checkParamFiles
|
||||||
|
|
9
server/tests/api/travis-2.sh
Normal file
9
server/tests/api/travis-2.sh
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/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
|
8
server/tests/api/travis-3.sh
Normal file
8
server/tests/api/travis-3.sh
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/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
|
9
server/tests/api/travis-4.sh
Normal file
9
server/tests/api/travis-4.sh
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/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
|
|
@ -71,8 +71,8 @@ describe('Test users subscriptions', function () {
|
||||||
it('User of server 1 should follow user of server 3 and root of server 1', async function () {
|
it('User of server 1 should follow user of server 3 and root of server 1', async function () {
|
||||||
this.timeout(60000)
|
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 addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001')
|
await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -116,22 +116,22 @@ describe('Test users subscriptions', function () {
|
||||||
|
|
||||||
it('Should get subscription', async function () {
|
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
|
const videoChannel: VideoChannel = res.body
|
||||||
|
|
||||||
expect(videoChannel.name).to.equal('user3_channel')
|
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.displayName).to.equal('Main user3 channel')
|
||||||
expect(videoChannel.followingCount).to.equal(0)
|
expect(videoChannel.followingCount).to.equal(0)
|
||||||
expect(videoChannel.followersCount).to.equal(1)
|
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
|
const videoChannel: VideoChannel = res.body
|
||||||
|
|
||||||
expect(videoChannel.name).to.equal('root_channel')
|
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.displayName).to.equal('Main root channel')
|
||||||
expect(videoChannel.followingCount).to.equal(0)
|
expect(videoChannel.followingCount).to.equal(0)
|
||||||
expect(videoChannel.followersCount).to.equal(1)
|
expect(videoChannel.followersCount).to.equal(1)
|
||||||
|
@ -140,19 +140,19 @@ describe('Test users subscriptions', function () {
|
||||||
|
|
||||||
it('Should return the existing subscriptions', async function () {
|
it('Should return the existing subscriptions', async function () {
|
||||||
const uris = [
|
const uris = [
|
||||||
'user3_channel@localhost:9003',
|
'user3_channel@localhost:' + servers[2].port,
|
||||||
'root2_channel@localhost:9001',
|
'root2_channel@localhost:' + servers[0].port,
|
||||||
'root_channel@localhost:9001',
|
'root_channel@localhost:' + servers[0].port,
|
||||||
'user3_channel@localhost:9001'
|
'user3_channel@localhost:' + servers[0].port
|
||||||
]
|
]
|
||||||
|
|
||||||
const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris)
|
const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris)
|
||||||
const body = res.body
|
const body = res.body
|
||||||
|
|
||||||
expect(body['user3_channel@localhost:9003']).to.be.true
|
expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true
|
||||||
expect(body['root2_channel@localhost:9001']).to.be.false
|
expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false
|
||||||
expect(body['root_channel@localhost:9001']).to.be.true
|
expect(body['root_channel@localhost:' + servers[0].port]).to.be.true
|
||||||
expect(body['user3_channel@localhost:9001']).to.be.false
|
expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should list subscription videos', async function () {
|
it('Should list subscription videos', async function () {
|
||||||
|
@ -291,7 +291,7 @@ describe('Test users subscriptions', function () {
|
||||||
it('Should remove user of server 3 subscription', async function () {
|
it('Should remove user of server 3 subscription', async function () {
|
||||||
this.timeout(30000)
|
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)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
@ -312,7 +312,7 @@ describe('Test users subscriptions', function () {
|
||||||
it('Should remove the root subscription and not display the videos anymore', async function () {
|
it('Should remove the root subscription and not display the videos anymore', async function () {
|
||||||
this.timeout(30000)
|
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)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ describe('Test users subscriptions', function () {
|
||||||
it('Should follow user of server 3 again', async function () {
|
it('Should follow user of server 3 again', async function () {
|
||||||
this.timeout(60000)
|
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)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
|
|
@ -151,13 +151,13 @@ describe('Test users with multiple servers', function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const resAccounts = await getAccountsList(server.url, '-createdAt')
|
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
|
expect(rootServer1List).not.to.be.undefined
|
||||||
|
|
||||||
const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host)
|
const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host)
|
||||||
const rootServer1Get = resAccount.body as Account
|
const rootServer1Get = resAccount.body as Account
|
||||||
expect(rootServer1Get.name).to.equal('root')
|
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.displayName).to.equal('my super display name')
|
||||||
expect(rootServer1Get.description).to.equal('my super description updated')
|
expect(rootServer1Get.description).to.equal('my super description updated')
|
||||||
|
|
||||||
|
@ -188,12 +188,12 @@ describe('Test users with multiple servers', function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const resAccounts = await getAccountsList(server.url, '-createdAt')
|
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
|
expect(accountDeleted).not.to.be.undefined
|
||||||
|
|
||||||
const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
|
const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
|
||||||
const videoChannelDeleted = resVideoChannels.body.data.find(a => {
|
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
|
}) as VideoChannel
|
||||||
expect(videoChannelDeleted).not.to.be.undefined
|
expect(videoChannelDeleted).not.to.be.undefined
|
||||||
}
|
}
|
||||||
|
@ -205,12 +205,12 @@ describe('Test users with multiple servers', function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const resAccounts = await getAccountsList(server.url, '-createdAt')
|
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
|
expect(accountDeleted).to.be.undefined
|
||||||
|
|
||||||
const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
|
const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
|
||||||
const videoChannelDeleted = resVideoChannels.body.data.find(a => {
|
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
|
}) as VideoChannel
|
||||||
expect(videoChannelDeleted).to.be.undefined
|
expect(videoChannelDeleted).to.be.undefined
|
||||||
}
|
}
|
||||||
|
@ -218,14 +218,14 @@ describe('Test users with multiple servers', function () {
|
||||||
|
|
||||||
it('Should not have actor files', async () => {
|
it('Should not have actor files', async () => {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber)
|
await checkActorFilesWereRemoved(userAccountUUID, server.internalServerNumber)
|
||||||
await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber)
|
await checkActorFilesWereRemoved(userVideoChannelUUID, server.internalServerNumber)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
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.serverNumber)
|
await checkVideoFilesWereRemoved(videoUUID, server.internalServerNumber)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,7 @@ describe('Test users', function () {
|
||||||
|
|
||||||
const rootUser = users[ 1 ]
|
const rootUser = users[ 1 ]
|
||||||
expect(rootUser.username).to.equal('root')
|
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')
|
expect(user.nsfwPolicy).to.equal('display')
|
||||||
|
|
||||||
userId = user.id
|
userId = user.id
|
||||||
|
@ -334,7 +334,7 @@ describe('Test users', function () {
|
||||||
|
|
||||||
const user = users[ 0 ]
|
const user = users[ 0 ]
|
||||||
expect(user.username).to.equal('root')
|
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.roleLabel).to.equal('Administrator')
|
||||||
expect(user.nsfwPolicy).to.equal('display')
|
expect(user.nsfwPolicy).to.equal('display')
|
||||||
})
|
})
|
||||||
|
@ -379,7 +379,7 @@ describe('Test users', function () {
|
||||||
expect(users.length).to.equal(2)
|
expect(users.length).to.equal(2)
|
||||||
|
|
||||||
expect(users[ 0 ].username).to.equal('root')
|
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[ 0 ].nsfwPolicy).to.equal('display')
|
||||||
|
|
||||||
expect(users[ 1 ].username).to.equal('user_1')
|
expect(users[ 1 ].username).to.equal('user_1')
|
||||||
|
|
|
@ -109,7 +109,7 @@ describe('Test multiple servers', function () {
|
||||||
// All servers should have this video
|
// All servers should have this video
|
||||||
let publishedAt: string = null
|
let publishedAt: string = null
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const isLocal = server.url === 'http://localhost:' + servers[0].port
|
const isLocal = server.port === servers[0].port
|
||||||
const checkAttributes = {
|
const checkAttributes = {
|
||||||
name: 'my super name for server 1',
|
name: 'my super name for server 1',
|
||||||
category: 5,
|
category: 5,
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe('Test a single server', function () {
|
||||||
let videoUUID = ''
|
let videoUUID = ''
|
||||||
let videosListBase: any[] = null
|
let videosListBase: any[] = null
|
||||||
|
|
||||||
const getCheckAttributes = {
|
const getCheckAttributes = () => ({
|
||||||
name: 'my super name',
|
name: 'my super name',
|
||||||
category: 2,
|
category: 2,
|
||||||
licence: 6,
|
licence: 6,
|
||||||
|
@ -68,9 +68,9 @@ describe('Test a single server', function () {
|
||||||
size: 218910
|
size: 218910
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
})
|
||||||
|
|
||||||
const updateCheckAttributes = {
|
const updateCheckAttributes = () => ({
|
||||||
name: 'my super video updated',
|
name: 'my super video updated',
|
||||||
category: 4,
|
category: 4,
|
||||||
licence: 2,
|
licence: 2,
|
||||||
|
@ -101,7 +101,7 @@ describe('Test a single server', function () {
|
||||||
size: 292677
|
size: 292677
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
})
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
@ -182,7 +182,7 @@ describe('Test a single server', function () {
|
||||||
expect(res.body.data.length).to.equal(1)
|
expect(res.body.data.length).to.equal(1)
|
||||||
|
|
||||||
const video = res.body.data[0]
|
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 () {
|
it('Should get the video by UUID', async function () {
|
||||||
|
@ -191,7 +191,7 @@ describe('Test a single server', function () {
|
||||||
const res = await getVideo(server.url, videoUUID)
|
const res = await getVideo(server.url, videoUUID)
|
||||||
|
|
||||||
const video = res.body
|
const video = res.body
|
||||||
await completeVideoCheck(server.url, video, getCheckAttributes)
|
await completeVideoCheck(server.url, video, getCheckAttributes())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have the views updated', async function () {
|
it('Should have the views updated', async function () {
|
||||||
|
@ -376,7 +376,7 @@ describe('Test a single server', function () {
|
||||||
const res = await getVideo(server.url, videoId)
|
const res = await getVideo(server.url, videoId)
|
||||||
const video = res.body
|
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 () {
|
it('Should update only the tags of a video', async function () {
|
||||||
|
@ -388,7 +388,7 @@ describe('Test a single server', function () {
|
||||||
const res = await getVideo(server.url, videoId)
|
const res = await getVideo(server.url, videoId)
|
||||||
const video = res.body
|
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 () {
|
it('Should update only the description of a video', async function () {
|
||||||
|
@ -400,7 +400,8 @@ describe('Test a single server', function () {
|
||||||
const res = await getVideo(server.url, videoId)
|
const res = await getVideo(server.url, videoId)
|
||||||
const video = res.body
|
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 () {
|
it('Should like a video', async function () {
|
||||||
|
|
|
@ -4,7 +4,8 @@ import * as chai from 'chai'
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import {
|
import {
|
||||||
acceptChangeOwnership,
|
acceptChangeOwnership,
|
||||||
changeVideoOwnership, cleanupTests,
|
changeVideoOwnership,
|
||||||
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
|
@ -13,7 +14,6 @@ import {
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideoChangeOwnershipList,
|
getVideoChangeOwnershipList,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
killallServers,
|
|
||||||
refuseChangeOwnership,
|
refuseChangeOwnership,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
|
@ -203,8 +203,8 @@ describe('Test video change ownership - nominal', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
after(function () {
|
after(async function () {
|
||||||
killallServers(servers)
|
await cleanupTests(servers)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ describe('Test video channels', function () {
|
||||||
let videoUUID: string
|
let videoUUID: string
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(30000)
|
this.timeout(60000)
|
||||||
|
|
||||||
servers = await flushAndRunMultipleServers(2)
|
servers = await flushAndRunMultipleServers(2)
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ describe('Test video channels', function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
for (const server of servers) {
|
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)
|
const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
|
||||||
expect(res1.body.total).to.equal(1)
|
expect(res1.body.total).to.equal(1)
|
||||||
expect(res1.body.data).to.be.an('array')
|
expect(res1.body.data).to.be.an('array')
|
||||||
|
@ -234,11 +234,11 @@ describe('Test video channels', function () {
|
||||||
this.timeout(10000)
|
this.timeout(10000)
|
||||||
|
|
||||||
for (const server of servers) {
|
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)
|
const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5)
|
||||||
expect(res1.body.total).to.equal(0)
|
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)
|
const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
|
||||||
expect(res2.body.total).to.equal(1)
|
expect(res2.body.total).to.equal(1)
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {
|
||||||
|
|
||||||
{
|
{
|
||||||
for (const resolution of resolutions) {
|
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
|
const subPlaylist = res2.text
|
||||||
expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`)
|
expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`)
|
||||||
|
@ -58,7 +58,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
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) {
|
for (const resolution of resolutions) {
|
||||||
await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist)
|
await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist)
|
||||||
|
|
|
@ -358,7 +358,7 @@ describe('Test video playlists', function () {
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const results = [
|
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')
|
await getVideoPlaylistsList(server.url, 0, 2, '-createdAt')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -757,7 +757,7 @@ describe('Test video playlists', function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber)
|
await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests
|
uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests, closeAllSequelize
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
|
import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
|
||||||
import { VideosOverview } from '../../../../shared/models/overviews'
|
import { VideosOverview } from '../../../../shared/models/overviews'
|
||||||
|
@ -58,14 +58,14 @@ describe('Test video views cleaner', function () {
|
||||||
|
|
||||||
{
|
{
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const total = await countVideoViewsOf(server.serverNumber, videoIdServer1)
|
const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)
|
||||||
expect(total).to.equal(2)
|
expect(total).to.equal(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const total = await countVideoViewsOf(server.serverNumber, videoIdServer2)
|
const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2)
|
||||||
expect(total).to.equal(2)
|
expect(total).to.equal(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,6 @@ describe('Test video views cleaner', function () {
|
||||||
it('Should clean old video views', async function () {
|
it('Should clean old video views', async function () {
|
||||||
this.timeout(50000)
|
this.timeout(50000)
|
||||||
|
|
||||||
this.timeout(50000)
|
|
||||||
|
|
||||||
killallServers([ servers[0] ])
|
killallServers([ servers[0] ])
|
||||||
|
|
||||||
await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } })
|
await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } })
|
||||||
|
@ -86,21 +84,23 @@ describe('Test video views cleaner', function () {
|
||||||
|
|
||||||
{
|
{
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const total = await countVideoViewsOf(server.serverNumber, videoIdServer1)
|
const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)
|
||||||
expect(total).to.equal(2)
|
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)
|
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)
|
expect(totalServer2).to.equal(2)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
await closeAllSequelize(servers)
|
||||||
|
|
||||||
await cleanupTests(servers)
|
await cleanupTests(servers)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { QueryTypes, Sequelize } from 'sequelize'
|
import { QueryTypes, Sequelize } from 'sequelize'
|
||||||
|
import { ServerInfo } from '../server/servers'
|
||||||
|
|
||||||
let sequelizes: { [ id: number ]: Sequelize } = {}
|
let sequelizes: { [ id: number ]: Sequelize } = {}
|
||||||
|
|
||||||
function getSequelize (serverNumber: number) {
|
function getSequelize (internalServerNumber: number) {
|
||||||
if (sequelizes[serverNumber]) return sequelizes[serverNumber]
|
if (sequelizes[internalServerNumber]) return sequelizes[internalServerNumber]
|
||||||
|
|
||||||
const dbname = 'peertube_test' + serverNumber
|
const dbname = 'peertube_test' + internalServerNumber
|
||||||
const username = 'peertube'
|
const username = 'peertube'
|
||||||
const password = 'peertube'
|
const password = 'peertube'
|
||||||
const host = 'localhost'
|
const host = 'localhost'
|
||||||
|
@ -18,37 +19,37 @@ function getSequelize (serverNumber: number) {
|
||||||
logging: false
|
logging: false
|
||||||
})
|
})
|
||||||
|
|
||||||
sequelizes[serverNumber] = seq
|
sequelizes[internalServerNumber] = seq
|
||||||
|
|
||||||
return seq
|
return seq
|
||||||
}
|
}
|
||||||
|
|
||||||
function setActorField (serverNumber: number, to: string, field: string, value: string) {
|
function setActorField (internalServerNumber: number, to: string, field: string, value: string) {
|
||||||
const seq = getSequelize(serverNumber)
|
const seq = getSequelize(internalServerNumber)
|
||||||
|
|
||||||
const options = { type: QueryTypes.UPDATE }
|
const options = { type: QueryTypes.UPDATE }
|
||||||
|
|
||||||
return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options)
|
return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVideoField (serverNumber: number, uuid: string, field: string, value: string) {
|
function setVideoField (internalServerNumber: number, uuid: string, field: string, value: string) {
|
||||||
const seq = getSequelize(serverNumber)
|
const seq = getSequelize(internalServerNumber)
|
||||||
|
|
||||||
const options = { type: QueryTypes.UPDATE }
|
const options = { type: QueryTypes.UPDATE }
|
||||||
|
|
||||||
return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
|
return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPlaylistField (serverNumber: number, uuid: string, field: string, value: string) {
|
function setPlaylistField (internalServerNumber: number, uuid: string, field: string, value: string) {
|
||||||
const seq = getSequelize(serverNumber)
|
const seq = getSequelize(internalServerNumber)
|
||||||
|
|
||||||
const options = { type: QueryTypes.UPDATE }
|
const options = { type: QueryTypes.UPDATE }
|
||||||
|
|
||||||
return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
|
return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function countVideoViewsOf (serverNumber: number, uuid: string) {
|
async function countVideoViewsOf (internalServerNumber: number, uuid: string) {
|
||||||
const seq = getSequelize(serverNumber)
|
const seq = getSequelize(internalServerNumber)
|
||||||
|
|
||||||
// tslint:disable
|
// tslint:disable
|
||||||
const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'`
|
const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'`
|
||||||
|
@ -62,11 +63,11 @@ async function countVideoViewsOf (serverNumber: number, uuid: string) {
|
||||||
return parseInt(total + '', 10)
|
return parseInt(total + '', 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function closeAllSequelize (servers: any[]) {
|
async function closeAllSequelize (servers: ServerInfo[]) {
|
||||||
for (let i = 1; i <= servers.length; i++) {
|
for (const server of servers) {
|
||||||
if (sequelizes[ i ]) {
|
if (sequelizes[ server.internalServerNumber ]) {
|
||||||
await sequelizes[ i ].close()
|
await sequelizes[ server.internalServerNumber ].close()
|
||||||
delete sequelizes[ i ]
|
delete sequelizes[ server.internalServerNumber ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ async function checkTmpIsEmpty (server: ServerInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) {
|
async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) {
|
||||||
const testDirectory = 'test' + server.serverNumber
|
const testDirectory = 'test' + server.internalServerNumber
|
||||||
|
|
||||||
const directoryPath = join(root(), testDirectory, directory)
|
const directoryPath = join(root(), testDirectory, directory)
|
||||||
|
|
||||||
|
|
|
@ -252,10 +252,10 @@ function reorderVideosPlaylist (options: {
|
||||||
|
|
||||||
async function checkPlaylistFilesWereRemoved (
|
async function checkPlaylistFilesWereRemoved (
|
||||||
playlistUUID: string,
|
playlistUUID: string,
|
||||||
serverNumber: number,
|
internalServerNumber: number,
|
||||||
directories = [ 'thumbnails' ]
|
directories = [ 'thumbnails' ]
|
||||||
) {
|
) {
|
||||||
const testDirectory = 'test' + serverNumber
|
const testDirectory = 'test' + internalServerNumber
|
||||||
|
|
||||||
for (const directory of directories) {
|
for (const directory of directories) {
|
||||||
const directoryPath = join(root(), testDirectory, directory)
|
const directoryPath = join(root(), testDirectory, directory)
|
||||||
|
|
|
@ -568,8 +568,8 @@ async function completeVideoCheck (
|
||||||
expect(file).not.to.be.undefined
|
expect(file).not.to.be.undefined
|
||||||
|
|
||||||
let extension = extname(attributes.fixture)
|
let extension = extname(attributes.fixture)
|
||||||
// Transcoding enabled on server 2, extension will always be .mp4
|
// Transcoding enabled: extension will always be .mp4
|
||||||
if (attributes.account.host === 'localhost:9002') extension = '.mp4'
|
if (attributes.files.length > 1) extension = '.mp4'
|
||||||
|
|
||||||
const magnetUri = file.magnetUri
|
const magnetUri = file.magnetUri
|
||||||
expect(file.magnetUri).to.have.lengthOf.above(2)
|
expect(file.magnetUri).to.have.lengthOf.above(2)
|
||||||
|
|
Loading…
Add table
Reference in a new issue