]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
6cbdbdef C |
2 | |
3 | import * as chai from 'chai' | |
4 | import 'mocha' | |
1a8dd4da | 5 | import { |
48f07b4a | 6 | cleanupTests, |
1a8dd4da C |
7 | doubleFollow, |
8 | flushAndRunMultipleServers, | |
1a8dd4da | 9 | makeActivityPubGetRequest, |
1a8dd4da | 10 | ServerInfo, |
2a8c5d0a C |
11 | setAccessTokensToServers, |
12 | uploadVideo | |
94565d52 | 13 | } from '../../../../shared/extra-utils' |
6cbdbdef C |
14 | |
15 | const expect = chai.expect | |
16 | ||
17 | describe('Test activitypub', function () { | |
1a8dd4da C |
18 | let servers: ServerInfo[] = [] |
19 | let videoUUID: string | |
6cbdbdef C |
20 | |
21 | before(async function () { | |
e212f887 | 22 | this.timeout(30000) |
6cbdbdef | 23 | |
1a8dd4da | 24 | servers = await flushAndRunMultipleServers(2) |
6cbdbdef | 25 | |
1a8dd4da C |
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]) | |
6cbdbdef C |
34 | }) |
35 | ||
36 | it('Should return the account object', async function () { | |
1a8dd4da | 37 | const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root') |
6cbdbdef C |
38 | const object = res.body |
39 | ||
40 | expect(object.type).to.equal('Person') | |
48f07b4a | 41 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root') |
6cbdbdef C |
42 | expect(object.name).to.equal('root') |
43 | expect(object.preferredUsername).to.equal('root') | |
44 | }) | |
45 | ||
1a8dd4da C |
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') | |
48f07b4a | 51 | expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) |
1a8dd4da C |
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 | ||
48f07b4a | 58 | expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) |
1a8dd4da C |
59 | }) |
60 | ||
48f07b4a C |
61 | after(async function () { |
62 | await cleanupTests(servers) | |
6cbdbdef C |
63 | }) |
64 | }) |