]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/activitypub/client.ts
fix missing title attribute on <iframe> tag suggested for embedding (#3901)
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / client.ts
CommitLineData
a1587156 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
6cbdbdef
C
2
3import * as chai from 'chai'
4import 'mocha'
1a8dd4da 5import {
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'
f2eb23cd 14import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6cbdbdef
C
15
16const expect = chai.expect
17
18describe('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 24
1a8dd4da 25 servers = await flushAndRunMultipleServers(2)
6cbdbdef 26
1a8dd4da
C
27 await setAccessTokensToServers(servers)
28
29 {
30 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
31 videoUUID = res.body.video.uuid
32 }
33
34 await doubleFollow(servers[0], servers[1])
6cbdbdef
C
35 })
36
37 it('Should return the account object', async function () {
1a8dd4da 38 const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root')
6cbdbdef
C
39 const object = res.body
40
41 expect(object.type).to.equal('Person')
48f07b4a 42 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root')
6cbdbdef
C
43 expect(object.name).to.equal('root')
44 expect(object.preferredUsername).to.equal('root')
45 })
46
1a8dd4da
C
47 it('Should return the video object', async function () {
48 const res = await makeActivityPubGetRequest(servers[0].url, '/videos/watch/' + videoUUID)
49 const object = res.body
50
51 expect(object.type).to.equal('Video')
48f07b4a 52 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
1a8dd4da
C
53 expect(object.name).to.equal('video')
54 })
55
56 it('Should redirect to the origin video object', async function () {
f2eb23cd 57 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, HttpStatusCode.FOUND_302)
1a8dd4da 58
48f07b4a 59 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
1a8dd4da
C
60 })
61
48f07b4a
C
62 after(async function () {
63 await cleanupTests(servers)
6cbdbdef
C
64 })
65})