]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/activitypub/client.ts
Correctly fix octet stream fallback for video ext
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / client.ts
CommitLineData
6cbdbdef
C
1/* tslint:disable:no-unused-expression */
2
3import * as chai from 'chai'
4import 'mocha'
1a8dd4da 5import {
48f07b4a 6 cleanupTests,
1a8dd4da
C
7 doubleFollow,
8 flushAndRunMultipleServers,
9 flushTests,
10 killallServers,
11 makeActivityPubGetRequest,
1a8dd4da 12 ServerInfo,
2a8c5d0a
C
13 setAccessTokensToServers,
14 uploadVideo
94565d52 15} from '../../../../shared/extra-utils'
6cbdbdef
C
16
17const expect = chai.expect
18
19describe('Test activitypub', function () {
1a8dd4da
C
20 let servers: ServerInfo[] = []
21 let videoUUID: string
6cbdbdef
C
22
23 before(async function () {
e212f887 24 this.timeout(30000)
6cbdbdef 25
1a8dd4da 26 servers = await flushAndRunMultipleServers(2)
6cbdbdef 27
1a8dd4da
C
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])
6cbdbdef
C
36 })
37
38 it('Should return the account object', async function () {
1a8dd4da 39 const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root')
6cbdbdef
C
40 const object = res.body
41
42 expect(object.type).to.equal('Person')
48f07b4a 43 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root')
6cbdbdef
C
44 expect(object.name).to.equal('root')
45 expect(object.preferredUsername).to.equal('root')
46 })
47
1a8dd4da
C
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')
48f07b4a 53 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
1a8dd4da
C
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
48f07b4a 60 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
1a8dd4da
C
61 })
62
48f07b4a
C
63 after(async function () {
64 await cleanupTests(servers)
6cbdbdef
C
65 })
66})