From 2732eeff9e6994582293b5aaa0cb158b7e272e9e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Dec 2022 11:14:47 +0100 Subject: Fix CI using 127.0.0.1 for tests --- server/tests/api/activitypub/client.ts | 10 +++++----- server/tests/api/activitypub/fetch.ts | 6 +++--- server/tests/api/activitypub/refresher.ts | 10 +++++----- server/tests/api/activitypub/security.ts | 32 +++++++++++++++---------------- 4 files changed, 29 insertions(+), 29 deletions(-) (limited to 'server/tests/api/activitypub') 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 () { const object = res.body expect(object.type).to.equal('Person') - expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root') + expect(object.id).to.equal(servers[0].url + '/accounts/root') expect(object.name).to.equal('root') expect(object.preferredUsername).to.equal('root') } @@ -33,7 +33,7 @@ describe('Test activitypub', function () { const object = res.body expect(object.type).to.equal('Group') - expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-channels/root_channel') + expect(object.id).to.equal(servers[0].url + '/video-channels/root_channel') expect(object.name).to.equal('Main root channel') expect(object.preferredUsername).to.equal('root_channel') } @@ -43,7 +43,7 @@ describe('Test activitypub', function () { const object = res.body expect(object.type).to.equal('Video') - expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid) + expect(object.id).to.equal(servers[0].url + '/videos/watch/' + video.uuid) expect(object.name).to.equal('video') } @@ -52,7 +52,7 @@ describe('Test activitypub', function () { const object = res.body expect(object.type).to.equal('Playlist') - expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-playlists/' + playlist.uuid) + expect(object.id).to.equal(servers[0].url + '/video-playlists/' + playlist.uuid) expect(object.name).to.equal('playlist') } @@ -110,7 +110,7 @@ describe('Test activitypub', function () { it('Should redirect to the origin video object', async function () { const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + video.uuid, HttpStatusCode.FOUND_302) - expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid) + expect(res.header.location).to.equal(servers[0].url + '/videos/watch/' + video.uuid) }) 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 () { await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } }) { - const to = 'http://localhost:' + servers[0].port + '/accounts/user1' - const value = 'http://localhost:' + servers[1].port + '/accounts/user1' + const to = servers[0].url + '/accounts/user1' + const value = servers[1].url + '/accounts/user1' await servers[0].sql.setActorField(to, 'url', value) } { - const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid + const value = servers[2].url + '/videos/watch/' + uuid await servers[0].sql.setVideoField(uuid, 'url', value) } }) 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 () { await wait(10000) // Change actor name so the remote server returns a 404 - const to = 'http://localhost:' + servers[1].port + '/accounts/user2' + const to = servers[1].url + '/accounts/user2' await servers[1].sql.setActorField(to, 'preferredUsername', 'toto') - await command.get({ accountName: 'user1@localhost:' + servers[1].port }) - await command.get({ accountName: 'user2@localhost:' + servers[1].port }) + await command.get({ accountName: 'user1@' + servers[1].host }) + await command.get({ accountName: 'user2@' + servers[1].host }) await waitJobs(servers) - await command.get({ accountName: 'user1@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.OK_200 }) - await command.get({ accountName: 'user2@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await command.get({ accountName: 'user1@' + servers[1].host, expectedStatus: HttpStatusCode.OK_200 }) + await command.get({ accountName: 'user2@' + servers[1].host, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) }) 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' import { cleanupTests, createMultipleServers, killallServers, PeerTubeServer } from '@shared/server-commands' function setKeysOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, publicKey: string, privateKey: string) { - const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' + const url = ofServer.url + '/accounts/peertube' return Promise.all([ onServer.sql.setActorField(url, 'publicKey', publicKey), @@ -20,7 +20,7 @@ function setKeysOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, pu } function setUpdatedAtOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, updatedAt: string) { - const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' + const url = ofServer.url + '/accounts/peertube' return Promise.all([ onServer.sql.setActorField(url, 'createdAt', updatedAt), @@ -52,7 +52,7 @@ describe('Test ActivityPub security', function () { const baseHttpSignature = () => ({ algorithm: HTTP_SIGNATURE.ALGORITHM, authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME, - keyId: 'acct:peertube@localhost:' + servers[1].port, + keyId: 'acct:peertube@' + servers[1].host, key: keys.privateKey, headers: HTTP_SIGNATURE.HEADERS_TO_SIGN }) @@ -69,8 +69,8 @@ describe('Test ActivityPub security', function () { await setKeysOfServer(servers[0], servers[1], keys.publicKey, null) await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey) - const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' } - const by = { url: 'http://localhost:' + servers[1].port + '/accounts/peertube', privateKey: keys.privateKey } + const to = { url: servers[0].url + '/accounts/peertube' } + const by = { url: servers[1].url + '/accounts/peertube', privateKey: keys.privateKey } await makeFollowRequest(to, by) }) @@ -196,8 +196,8 @@ describe('Test ActivityPub security', function () { await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey) await setKeysOfServer(servers[2], servers[2], keys.publicKey, keys.privateKey) - const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' } - const by = { url: 'http://localhost:' + servers[2].port + '/accounts/peertube', privateKey: keys.privateKey } + const to = { url: servers[0].url + '/accounts/peertube' } + const by = { url: servers[2].url + '/accounts/peertube', privateKey: keys.privateKey } await makeFollowRequest(to, by) }) @@ -208,9 +208,9 @@ describe('Test ActivityPub security', function () { await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey) const body = getAnnounceWithoutContext(servers[1]) - body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' + body.actor = servers[2].url + '/accounts/peertube' - const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } + const signer: any = { privateKey: invalidKeys.privateKey, url: servers[2].url + '/accounts/peertube' } const signedBody = await signAndContextify(signer, body, 'Announce') const headers = buildGlobalHeaders(signedBody) @@ -230,12 +230,12 @@ describe('Test ActivityPub security', function () { await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey) const body = getAnnounceWithoutContext(servers[1]) - body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' + body.actor = servers[2].url + '/accounts/peertube' - const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } + const signer: any = { privateKey: keys.privateKey, url: servers[2].url + '/accounts/peertube' } const signedBody = await signAndContextify(signer, body, 'Announce') - signedBody.actor = 'http://localhost:' + servers[2].port + '/account/peertube' + signedBody.actor = servers[2].url + '/account/peertube' const headers = buildGlobalHeaders(signedBody) @@ -251,9 +251,9 @@ describe('Test ActivityPub security', function () { this.timeout(10000) const body = getAnnounceWithoutContext(servers[1]) - body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' + body.actor = servers[2].url + '/accounts/peertube' - const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } + const signer: any = { privateKey: keys.privateKey, url: servers[2].url + '/accounts/peertube' } const signedBody = await signAndContextify(signer, body, 'Announce') const headers = buildGlobalHeaders(signedBody) @@ -273,9 +273,9 @@ describe('Test ActivityPub security', function () { await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey) const body = getAnnounceWithoutContext(servers[1]) - body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube' + body.actor = servers[2].url + '/accounts/peertube' - const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' } + const signer: any = { privateKey: keys.privateKey, url: servers[2].url + '/accounts/peertube' } const signedBody = await signAndContextify(signer, body, 'Announce') const headers = buildGlobalHeaders(signedBody) -- cgit v1.2.3