2020-01-31 09:56:52 -06:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2017-11-30 05:00:40 -06:00
|
|
|
|
|
|
|
import * as chai from 'chai'
|
|
|
|
import 'mocha'
|
2018-11-30 08:06:06 -06:00
|
|
|
import {
|
2019-04-26 01:50:52 -05:00
|
|
|
cleanupTests,
|
2018-11-30 08:06:06 -06:00
|
|
|
doubleFollow,
|
|
|
|
flushAndRunMultipleServers,
|
|
|
|
makeActivityPubGetRequest,
|
|
|
|
ServerInfo,
|
2018-12-07 09:09:57 -06:00
|
|
|
setAccessTokensToServers,
|
|
|
|
uploadVideo
|
2019-04-15 08:26:15 -05:00
|
|
|
} from '../../../../shared/extra-utils'
|
2020-12-08 14:16:10 -06:00
|
|
|
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
2017-11-30 05:00:40 -06:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
|
|
|
describe('Test activitypub', function () {
|
2018-11-30 08:06:06 -06:00
|
|
|
let servers: ServerInfo[] = []
|
|
|
|
let videoUUID: string
|
2017-11-30 05:00:40 -06:00
|
|
|
|
|
|
|
before(async function () {
|
2018-01-18 11:10:45 -06:00
|
|
|
this.timeout(30000)
|
2017-11-30 05:00:40 -06:00
|
|
|
|
2018-11-30 08:06:06 -06:00
|
|
|
servers = await flushAndRunMultipleServers(2)
|
2017-11-30 05:00:40 -06:00
|
|
|
|
2018-11-30 08:06:06 -06:00
|
|
|
await setAccessTokensToServers(servers)
|
|
|
|
|
|
|
|
{
|
|
|
|
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
|
|
|
|
videoUUID = res.body.video.uuid
|
|
|
|
}
|
|
|
|
|
|
|
|
await doubleFollow(servers[0], servers[1])
|
2017-11-30 05:00:40 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should return the account object', async function () {
|
2018-11-30 08:06:06 -06:00
|
|
|
const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root')
|
2017-11-30 05:00:40 -06:00
|
|
|
const object = res.body
|
|
|
|
|
|
|
|
expect(object.type).to.equal('Person')
|
2019-04-26 01:50:52 -05:00
|
|
|
expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root')
|
2017-11-30 05:00:40 -06:00
|
|
|
expect(object.name).to.equal('root')
|
|
|
|
expect(object.preferredUsername).to.equal('root')
|
|
|
|
})
|
|
|
|
|
2018-11-30 08:06:06 -06:00
|
|
|
it('Should return the video object', async function () {
|
|
|
|
const res = await makeActivityPubGetRequest(servers[0].url, '/videos/watch/' + videoUUID)
|
|
|
|
const object = res.body
|
|
|
|
|
|
|
|
expect(object.type).to.equal('Video')
|
2019-04-26 01:50:52 -05:00
|
|
|
expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
|
2018-11-30 08:06:06 -06:00
|
|
|
expect(object.name).to.equal('video')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should redirect to the origin video object', async function () {
|
2020-12-08 14:16:10 -06:00
|
|
|
const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, HttpStatusCode.FOUND_302)
|
2018-11-30 08:06:06 -06:00
|
|
|
|
2019-04-26 01:50:52 -05:00
|
|
|
expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
|
2018-11-30 08:06:06 -06:00
|
|
|
})
|
|
|
|
|
2019-04-26 01:50:52 -05:00
|
|
|
after(async function () {
|
|
|
|
await cleanupTests(servers)
|
2017-11-30 05:00:40 -06:00
|
|
|
})
|
|
|
|
})
|