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