aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/activitypub/security.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/activitypub/security.ts')
-rw-r--r--server/tests/api/activitypub/security.ts32
1 files changed, 16 insertions, 16 deletions
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index 423fefb10..22fae8331 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -11,7 +11,7 @@ import { HttpStatusCode } from '@shared/models'
11import { cleanupTests, createMultipleServers, killallServers, PeerTubeServer } from '@shared/server-commands' 11import { cleanupTests, createMultipleServers, killallServers, PeerTubeServer } from '@shared/server-commands'
12 12
13function setKeysOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, publicKey: string, privateKey: string) { 13function setKeysOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, publicKey: string, privateKey: string) {
14 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' 14 const url = ofServer.url + '/accounts/peertube'
15 15
16 return Promise.all([ 16 return Promise.all([
17 onServer.sql.setActorField(url, 'publicKey', publicKey), 17 onServer.sql.setActorField(url, 'publicKey', publicKey),
@@ -20,7 +20,7 @@ function setKeysOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, pu
20} 20}
21 21
22function setUpdatedAtOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, updatedAt: string) { 22function setUpdatedAtOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, updatedAt: string) {
23 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' 23 const url = ofServer.url + '/accounts/peertube'
24 24
25 return Promise.all([ 25 return Promise.all([
26 onServer.sql.setActorField(url, 'createdAt', updatedAt), 26 onServer.sql.setActorField(url, 'createdAt', updatedAt),
@@ -52,7 +52,7 @@ describe('Test ActivityPub security', function () {
52 const baseHttpSignature = () => ({ 52 const baseHttpSignature = () => ({
53 algorithm: HTTP_SIGNATURE.ALGORITHM, 53 algorithm: HTTP_SIGNATURE.ALGORITHM,
54 authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME, 54 authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,
55 keyId: 'acct:peertube@localhost:' + servers[1].port, 55 keyId: 'acct:peertube@' + servers[1].host,
56 key: keys.privateKey, 56 key: keys.privateKey,
57 headers: HTTP_SIGNATURE.HEADERS_TO_SIGN 57 headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
58 }) 58 })
@@ -69,8 +69,8 @@ describe('Test ActivityPub security', function () {
69 await setKeysOfServer(servers[0], servers[1], keys.publicKey, null) 69 await setKeysOfServer(servers[0], servers[1], keys.publicKey, null)
70 await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey) 70 await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey)
71 71
72 const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' } 72 const to = { url: servers[0].url + '/accounts/peertube' }
73 const by = { url: 'http://localhost:' + servers[1].port + '/accounts/peertube', privateKey: keys.privateKey } 73 const by = { url: servers[1].url + '/accounts/peertube', privateKey: keys.privateKey }
74 await makeFollowRequest(to, by) 74 await makeFollowRequest(to, by)
75 }) 75 })
76 76
@@ -196,8 +196,8 @@ describe('Test ActivityPub security', function () {
196 await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey) 196 await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey)
197 await setKeysOfServer(servers[2], servers[2], keys.publicKey, keys.privateKey) 197 await setKeysOfServer(servers[2], servers[2], keys.publicKey, keys.privateKey)
198 198
199 const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' } 199 const to = { url: servers[0].url + '/accounts/peertube' }
200 const by = { url: 'http://localhost:' + servers[2].port + '/accounts/peertube', privateKey: keys.privateKey } 200 const by = { url: servers[2].url + '/accounts/peertube', privateKey: keys.privateKey }
201 await makeFollowRequest(to, by) 201 await makeFollowRequest(to, by)
202 }) 202 })
203 203
@@ -208,9 +208,9 @@ describe('Test ActivityPub security', function () {
208 await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey) 208 await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)
209 209
210 const body = getAnnounceWithoutContext(servers[1]) 210 const body = getAnnounceWithoutContext(servers[1])
211 body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' 211 body.actor = servers[2].url + '/accounts/peertube'
212 212
213 const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } 213 const signer: any = { privateKey: invalidKeys.privateKey, url: servers[2].url + '/accounts/peertube' }
214 const signedBody = await signAndContextify(signer, body, 'Announce') 214 const signedBody = await signAndContextify(signer, body, 'Announce')
215 215
216 const headers = buildGlobalHeaders(signedBody) 216 const headers = buildGlobalHeaders(signedBody)
@@ -230,12 +230,12 @@ describe('Test ActivityPub security', function () {
230 await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey) 230 await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey)
231 231
232 const body = getAnnounceWithoutContext(servers[1]) 232 const body = getAnnounceWithoutContext(servers[1])
233 body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' 233 body.actor = servers[2].url + '/accounts/peertube'
234 234
235 const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } 235 const signer: any = { privateKey: keys.privateKey, url: servers[2].url + '/accounts/peertube' }
236 const signedBody = await signAndContextify(signer, body, 'Announce') 236 const signedBody = await signAndContextify(signer, body, 'Announce')
237 237
238 signedBody.actor = 'http://localhost:' + servers[2].port + '/account/peertube' 238 signedBody.actor = servers[2].url + '/account/peertube'
239 239
240 const headers = buildGlobalHeaders(signedBody) 240 const headers = buildGlobalHeaders(signedBody)
241 241
@@ -251,9 +251,9 @@ describe('Test ActivityPub security', function () {
251 this.timeout(10000) 251 this.timeout(10000)
252 252
253 const body = getAnnounceWithoutContext(servers[1]) 253 const body = getAnnounceWithoutContext(servers[1])
254 body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' 254 body.actor = servers[2].url + '/accounts/peertube'
255 255
256 const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } 256 const signer: any = { privateKey: keys.privateKey, url: servers[2].url + '/accounts/peertube' }
257 const signedBody = await signAndContextify(signer, body, 'Announce') 257 const signedBody = await signAndContextify(signer, body, 'Announce')
258 258
259 const headers = buildGlobalHeaders(signedBody) 259 const headers = buildGlobalHeaders(signedBody)
@@ -273,9 +273,9 @@ describe('Test ActivityPub security', function () {
273 await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey) 273 await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)
274 274
275 const body = getAnnounceWithoutContext(servers[1]) 275 const body = getAnnounceWithoutContext(servers[1])
276 body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' 276 body.actor = servers[2].url + '/accounts/peertube'
277 277
278 const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } 278 const signer: any = { privateKey: keys.privateKey, url: servers[2].url + '/accounts/peertube' }
279 const signedBody = await signAndContextify(signer, body, 'Announce') 279 const signedBody = await signAndContextify(signer, body, 'Announce')
280 280
281 const headers = buildGlobalHeaders(signedBody) 281 const headers = buildGlobalHeaders(signedBody)