aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/activitypub/security.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 09:47:51 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit254d3579f5338f5fd775c17d15cdfc37078bcfb4 (patch)
treeeaeb13fda16c16e98cd6991d202b0ca6a4cbdb63 /server/tests/api/activitypub/security.ts
parent89d241a79c262b9775c233b73cff080043ebb5e6 (diff)
downloadPeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.tar.gz
PeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.tar.zst
PeerTube-254d3579f5338f5fd775c17d15cdfc37078bcfb4.zip
Use an object to represent a server
Diffstat (limited to 'server/tests/api/activitypub/security.ts')
-rw-r--r--server/tests/api/activitypub/security.ts17
1 files changed, 8 insertions, 9 deletions
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index ab0eb256e..c173648b3 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -7,10 +7,9 @@ import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-c
7import { 7import {
8 buildAbsoluteFixturePath, 8 buildAbsoluteFixturePath,
9 cleanupTests, 9 cleanupTests,
10 flushAndRunMultipleServers, 10 createMultipleServers,
11 killallServers, 11 killallServers,
12 reRunServer, 12 PeerTubeServer,
13 ServerInfo,
14 wait 13 wait
15} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
16import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-utils/requests/activitypub' 15import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-utils/requests/activitypub'
@@ -20,7 +19,7 @@ import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activi
20 19
21const expect = chai.expect 20const expect = chai.expect
22 21
23function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey: string, privateKey: string) { 22function setKeysOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, publicKey: string, privateKey: string) {
24 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' 23 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube'
25 24
26 return Promise.all([ 25 return Promise.all([
@@ -29,7 +28,7 @@ function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey:
29 ]) 28 ])
30} 29}
31 30
32function setUpdatedAtOfServer (onServer: ServerInfo, ofServer: ServerInfo, updatedAt: string) { 31function setUpdatedAtOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, updatedAt: string) {
33 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' 32 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube'
34 33
35 return Promise.all([ 34 return Promise.all([
@@ -38,7 +37,7 @@ function setUpdatedAtOfServer (onServer: ServerInfo, ofServer: ServerInfo, updat
38 ]) 37 ])
39} 38}
40 39
41function getAnnounceWithoutContext (server: ServerInfo) { 40function getAnnounceWithoutContext (server: PeerTubeServer) {
42 const json = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) 41 const json = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json'))
43 const result: typeof json = {} 42 const result: typeof json = {}
44 43
@@ -54,7 +53,7 @@ function getAnnounceWithoutContext (server: ServerInfo) {
54} 53}
55 54
56describe('Test ActivityPub security', function () { 55describe('Test ActivityPub security', function () {
57 let servers: ServerInfo[] 56 let servers: PeerTubeServer[]
58 let url: string 57 let url: string
59 58
60 const keys = require(buildAbsoluteFixturePath('./ap-json/peertube/keys.json')) 59 const keys = require(buildAbsoluteFixturePath('./ap-json/peertube/keys.json'))
@@ -72,7 +71,7 @@ describe('Test ActivityPub security', function () {
72 before(async function () { 71 before(async function () {
73 this.timeout(60000) 72 this.timeout(60000)
74 73
75 servers = await flushAndRunMultipleServers(3) 74 servers = await createMultipleServers(3)
76 75
77 url = servers[0].url + '/inbox' 76 url = servers[0].url + '/inbox'
78 77
@@ -172,7 +171,7 @@ describe('Test ActivityPub security', function () {
172 171
173 // Invalid peertube actor cache 172 // Invalid peertube actor cache
174 await killallServers([ servers[1] ]) 173 await killallServers([ servers[1] ])
175 await reRunServer(servers[1]) 174 await servers[1].run()
176 175
177 const body = activityPubContextify(getAnnounceWithoutContext(servers[1])) 176 const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
178 const headers = buildGlobalHeaders(body) 177 const headers = buildGlobalHeaders(body)