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