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