aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-12-09 11:14:47 +0100
committerChocobozzz <me@florianbigard.com>2022-12-12 13:36:23 +0100
commit2732eeff9e6994582293b5aaa0cb158b7e272e9e (patch)
tree417d30cf470cd1db84e06c5dbd1b5429d4b99bc1 /server/tests/api/activitypub
parentc7c5f8d0f17b0ab598fbe237f11639c6de28110c (diff)
downloadPeerTube-2732eeff9e6994582293b5aaa0cb158b7e272e9e.tar.gz
PeerTube-2732eeff9e6994582293b5aaa0cb158b7e272e9e.tar.zst
PeerTube-2732eeff9e6994582293b5aaa0cb158b7e272e9e.zip
Fix CI using 127.0.0.1 for tests
Diffstat (limited to 'server/tests/api/activitypub')
-rw-r--r--server/tests/api/activitypub/client.ts10
-rw-r--r--server/tests/api/activitypub/fetch.ts6
-rw-r--r--server/tests/api/activitypub/refresher.ts10
-rw-r--r--server/tests/api/activitypub/security.ts32
4 files changed, 29 insertions, 29 deletions
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts
index 90c89138c..572a358a0 100644
--- a/server/tests/api/activitypub/client.ts
+++ b/server/tests/api/activitypub/client.ts
@@ -23,7 +23,7 @@ describe('Test activitypub', function () {
23 const object = res.body 23 const object = res.body
24 24
25 expect(object.type).to.equal('Person') 25 expect(object.type).to.equal('Person')
26 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root') 26 expect(object.id).to.equal(servers[0].url + '/accounts/root')
27 expect(object.name).to.equal('root') 27 expect(object.name).to.equal('root')
28 expect(object.preferredUsername).to.equal('root') 28 expect(object.preferredUsername).to.equal('root')
29 } 29 }
@@ -33,7 +33,7 @@ describe('Test activitypub', function () {
33 const object = res.body 33 const object = res.body
34 34
35 expect(object.type).to.equal('Group') 35 expect(object.type).to.equal('Group')
36 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-channels/root_channel') 36 expect(object.id).to.equal(servers[0].url + '/video-channels/root_channel')
37 expect(object.name).to.equal('Main root channel') 37 expect(object.name).to.equal('Main root channel')
38 expect(object.preferredUsername).to.equal('root_channel') 38 expect(object.preferredUsername).to.equal('root_channel')
39 } 39 }
@@ -43,7 +43,7 @@ describe('Test activitypub', function () {
43 const object = res.body 43 const object = res.body
44 44
45 expect(object.type).to.equal('Video') 45 expect(object.type).to.equal('Video')
46 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid) 46 expect(object.id).to.equal(servers[0].url + '/videos/watch/' + video.uuid)
47 expect(object.name).to.equal('video') 47 expect(object.name).to.equal('video')
48 } 48 }
49 49
@@ -52,7 +52,7 @@ describe('Test activitypub', function () {
52 const object = res.body 52 const object = res.body
53 53
54 expect(object.type).to.equal('Playlist') 54 expect(object.type).to.equal('Playlist')
55 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-playlists/' + playlist.uuid) 55 expect(object.id).to.equal(servers[0].url + '/video-playlists/' + playlist.uuid)
56 expect(object.name).to.equal('playlist') 56 expect(object.name).to.equal('playlist')
57 } 57 }
58 58
@@ -110,7 +110,7 @@ describe('Test activitypub', function () {
110 it('Should redirect to the origin video object', async function () { 110 it('Should redirect to the origin video object', async function () {
111 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + video.uuid, HttpStatusCode.FOUND_302) 111 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + video.uuid, HttpStatusCode.FOUND_302)
112 112
113 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid) 113 expect(res.header.location).to.equal(servers[0].url + '/videos/watch/' + video.uuid)
114 }) 114 })
115 115
116 it('Should return the watch action', async function () { 116 it('Should return the watch action', async function () {
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts
index 4edabd1d9..f0caea507 100644
--- a/server/tests/api/activitypub/fetch.ts
+++ b/server/tests/api/activitypub/fetch.ts
@@ -35,13 +35,13 @@ describe('Test ActivityPub fetcher', function () {
35 await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } }) 35 await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } })
36 36
37 { 37 {
38 const to = 'http://localhost:' + servers[0].port + '/accounts/user1' 38 const to = servers[0].url + '/accounts/user1'
39 const value = 'http://localhost:' + servers[1].port + '/accounts/user1' 39 const value = servers[1].url + '/accounts/user1'
40 await servers[0].sql.setActorField(to, 'url', value) 40 await servers[0].sql.setActorField(to, 'url', value)
41 } 41 }
42 42
43 { 43 {
44 const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid 44 const value = servers[2].url + '/videos/watch/' + uuid
45 await servers[0].sql.setVideoField(uuid, 'url', value) 45 await servers[0].sql.setVideoField(uuid, 'url', value)
46 } 46 }
47 }) 47 })
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
index 401a09090..4fb22f512 100644
--- a/server/tests/api/activitypub/refresher.ts
+++ b/server/tests/api/activitypub/refresher.ts
@@ -112,16 +112,16 @@ describe('Test AP refresher', function () {
112 await wait(10000) 112 await wait(10000)
113 113
114 // Change actor name so the remote server returns a 404 114 // Change actor name so the remote server returns a 404
115 const to = 'http://localhost:' + servers[1].port + '/accounts/user2' 115 const to = servers[1].url + '/accounts/user2'
116 await servers[1].sql.setActorField(to, 'preferredUsername', 'toto') 116 await servers[1].sql.setActorField(to, 'preferredUsername', 'toto')
117 117
118 await command.get({ accountName: 'user1@localhost:' + servers[1].port }) 118 await command.get({ accountName: 'user1@' + servers[1].host })
119 await command.get({ accountName: 'user2@localhost:' + servers[1].port }) 119 await command.get({ accountName: 'user2@' + servers[1].host })
120 120
121 await waitJobs(servers) 121 await waitJobs(servers)
122 122
123 await command.get({ accountName: 'user1@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.OK_200 }) 123 await command.get({ accountName: 'user1@' + servers[1].host, expectedStatus: HttpStatusCode.OK_200 })
124 await command.get({ accountName: 'user2@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 124 await command.get({ accountName: 'user2@' + servers[1].host, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
125 }) 125 })
126 }) 126 })
127 127
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)