1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import * as chai from 'chai'
import 'mocha'
import {
cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
makeActivityPubGetRequest,
ServerInfo,
setAccessTokensToServers,
uploadVideo
} from '../../../../shared/extra-utils'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const expect = chai.expect
describe('Test activitypub', function () {
let servers: ServerInfo[] = []
let videoUUID: string
before(async function () {
this.timeout(30000)
servers = await flushAndRunMultipleServers(2)
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])
})
it('Should return the account object', async function () {
const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root')
const object = res.body
expect(object.type).to.equal('Person')
expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root')
expect(object.name).to.equal('root')
expect(object.preferredUsername).to.equal('root')
})
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')
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, HttpStatusCode.FOUND_302)
expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
})
after(async function () {
await cleanupTests(servers)
})
})
|