diff options
Diffstat (limited to 'server/tests/api/activitypub')
-rw-r--r-- | server/tests/api/activitypub/client.ts | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index 5ca8bdfd3..ea0682634 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts | |||
@@ -2,25 +2,42 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { flushTests, killallServers, makeActivityPubGetRequest, runServer, ServerInfo, setAccessTokensToServers } from '../../utils' | 5 | import { |
6 | doubleFollow, | ||
7 | flushAndRunMultipleServers, | ||
8 | flushTests, | ||
9 | killallServers, | ||
10 | makeActivityPubGetRequest, | ||
11 | runServer, | ||
12 | ServerInfo, | ||
13 | setAccessTokensToServers, uploadVideo | ||
14 | } from '../../utils' | ||
6 | 15 | ||
7 | const expect = chai.expect | 16 | const expect = chai.expect |
8 | 17 | ||
9 | describe('Test activitypub', function () { | 18 | describe('Test activitypub', function () { |
10 | let server: ServerInfo = null | 19 | let servers: ServerInfo[] = [] |
20 | let videoUUID: string | ||
11 | 21 | ||
12 | before(async function () { | 22 | before(async function () { |
13 | this.timeout(30000) | 23 | this.timeout(30000) |
14 | 24 | ||
15 | await flushTests() | 25 | await flushTests() |
16 | 26 | ||
17 | server = await runServer(1) | 27 | servers = await flushAndRunMultipleServers(2) |
18 | 28 | ||
19 | await setAccessTokensToServers([ server ]) | 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]) | ||
20 | }) | 37 | }) |
21 | 38 | ||
22 | it('Should return the account object', async function () { | 39 | it('Should return the account object', async function () { |
23 | const res = await makeActivityPubGetRequest(server.url, '/accounts/root') | 40 | const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root') |
24 | const object = res.body | 41 | const object = res.body |
25 | 42 | ||
26 | expect(object.type).to.equal('Person') | 43 | expect(object.type).to.equal('Person') |
@@ -29,7 +46,22 @@ describe('Test activitypub', function () { | |||
29 | expect(object.preferredUsername).to.equal('root') | 46 | expect(object.preferredUsername).to.equal('root') |
30 | }) | 47 | }) |
31 | 48 | ||
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 | |||
32 | after(async function () { | 64 | after(async function () { |
33 | killallServers([ server ]) | 65 | killallServers(servers) |
34 | }) | 66 | }) |
35 | }) | 67 | }) |