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 ++++++++-------- server/tests/api/check-params/blocklist.ts | 32 ++++++++-------- server/tests/api/check-params/contact-form.ts | 4 +- server/tests/api/check-params/follows.ts | 34 ++++++++--------- server/tests/api/check-params/redundancy.ts | 8 ++-- server/tests/api/check-params/services.ts | 30 +++++++-------- .../tests/api/check-params/user-notifications.ts | 6 +-- .../tests/api/check-params/user-subscriptions.ts | 18 ++++----- server/tests/api/check-params/users-admin.ts | 2 +- server/tests/api/moderation/blocklist.ts | 44 +++++++++++----------- .../tests/api/notifications/admin-notifications.ts | 2 +- .../api/notifications/comments-notifications.ts | 4 +- .../api/notifications/moderation-notifications.ts | 14 +++---- .../tests/api/notifications/notifications-api.ts | 2 +- .../tests/api/notifications/user-notifications.ts | 16 ++++---- server/tests/api/object-storage/videos.ts | 2 +- server/tests/api/redundancy/redundancy.ts | 10 ++--- .../search/search-activitypub-video-channels.ts | 10 ++--- server/tests/api/search/search-index.ts | 2 +- server/tests/api/server/auto-follows.ts | 2 +- server/tests/api/server/bulk.ts | 4 +- server/tests/api/server/contact-form.ts | 4 +- server/tests/api/server/email.ts | 20 +++++----- server/tests/api/server/follow-constraints.ts | 32 ++++++++-------- server/tests/api/server/follows.ts | 2 +- server/tests/api/server/handle-down.ts | 4 +- server/tests/api/server/open-telemetry.ts | 4 +- server/tests/api/server/proxy.ts | 4 +- server/tests/api/users/user-subscriptions.ts | 38 +++++++++---------- server/tests/api/users/users-multiple-servers.ts | 16 ++++---- server/tests/api/users/users-verification.ts | 2 +- server/tests/api/videos/multiple-servers.ts | 34 ++++++++--------- server/tests/api/videos/single-server.ts | 4 +- server/tests/api/videos/video-channels.ts | 6 +-- server/tests/api/videos/video-comments.ts | 6 +-- server/tests/api/videos/video-playlists.ts | 18 ++++----- server/tests/cli/peertube.ts | 2 +- server/tests/cli/prune-storage.ts | 4 +- server/tests/cli/update-host.ts | 16 ++++---- server/tests/client.ts | 14 +++---- server/tests/external-plugins/auth-ldap.ts | 4 +- server/tests/external-plugins/auto-block-videos.ts | 2 +- server/tests/external-plugins/auto-mute.ts | 20 +++++----- .../ap-json/peertube/announce-without-context.json | 12 +++--- server/tests/helpers/request.ts | 2 +- server/tests/misc-endpoints.ts | 14 +++---- server/tests/plugins/plugin-helpers.ts | 12 +++--- server/tests/shared/notifications.ts | 4 +- 51 files changed, 299 insertions(+), 305 deletions(-) (limited to 'server') 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) diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts index f745b9088..169b591a3 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/server/tests/api/check-params/blocklist.ts @@ -163,7 +163,7 @@ describe('Test blocklist API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { host: 'localhost:9002' }, + fields: { host: '127.0.0.1:9002' }, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -173,7 +173,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:9003' }, + fields: { host: '127.0.0.1:9003' }, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) @@ -183,7 +183,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:' + server.port }, + fields: { host: server.host }, expectedStatus: HttpStatusCode.CONFLICT_409 }) }) @@ -193,7 +193,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:' + servers[1].port }, + fields: { host: servers[1].host }, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) @@ -203,7 +203,7 @@ describe('Test blocklist API validators', function () { it('Should fail with an unauthenticated user', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:' + servers[1].port, + path: path + '/' + servers[1].host, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -211,7 +211,7 @@ describe('Test blocklist API validators', function () { it('Should fail with an unknown server block', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:9004', + path: path + '/127.0.0.1:9004', token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) @@ -220,7 +220,7 @@ describe('Test blocklist API validators', function () { it('Should succeed with the correct params', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:' + servers[1].port, + path: path + '/' + servers[1].host, token: server.accessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) @@ -393,7 +393,7 @@ describe('Test blocklist API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { host: 'localhost:' + servers[1].port }, + fields: { host: servers[1].host }, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -403,7 +403,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: userAccessToken, path, - fields: { host: 'localhost:' + servers[1].port }, + fields: { host: servers[1].host }, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) }) @@ -413,7 +413,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:9003' }, + fields: { host: '127.0.0.1:9003' }, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) @@ -423,7 +423,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:' + server.port }, + fields: { host: server.host }, expectedStatus: HttpStatusCode.CONFLICT_409 }) }) @@ -433,7 +433,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:' + servers[1].port }, + fields: { host: servers[1].host }, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) }) @@ -443,7 +443,7 @@ describe('Test blocklist API validators', function () { it('Should fail with an unauthenticated user', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:' + servers[1].port, + path: path + '/' + servers[1].host, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -451,7 +451,7 @@ describe('Test blocklist API validators', function () { it('Should fail with a user without the appropriate rights', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:' + servers[1].port, + path: path + '/' + servers[1].host, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) @@ -460,7 +460,7 @@ describe('Test blocklist API validators', function () { it('Should fail with an unknown server block', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:9004', + path: path + '/127.0.0.1:9004', token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) @@ -469,7 +469,7 @@ describe('Test blocklist API validators', function () { it('Should succeed with the correct params', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:' + servers[1].port, + path: path + '/' + servers[1].host, token: server.accessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts index e82688356..7968ef802 100644 --- a/server/tests/api/check-params/contact-form.ts +++ b/server/tests/api/check-params/contact-form.ts @@ -38,7 +38,7 @@ describe('Test contact form API validators', function () { await killallServers([ server ]) // Contact form is disabled - await server.run({ smtp: { hostname: 'localhost', port: emailPort }, contact_form: { enabled: false } }) + await server.run({ smtp: { hostname: '127.0.0.1', port: emailPort }, contact_form: { enabled: false } }) await command.send({ ...defaultBody, expectedStatus: HttpStatusCode.CONFLICT_409 }) }) @@ -48,7 +48,7 @@ describe('Test contact form API validators', function () { await killallServers([ server ]) // Email & contact form enabled - await server.run({ smtp: { hostname: 'localhost', port: emailPort } }) + await server.run({ smtp: { hostname: '127.0.0.1', port: emailPort } }) await command.send({ ...defaultBody, fromEmail: 'badEmail', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) await command.send({ ...defaultBody, fromEmail: 'badEmail@', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index 56e9f8d96..3c911dcee 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts @@ -48,7 +48,7 @@ describe('Test server follows API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, + fields: { hosts: [ '127.0.0.1:9002', '127.0.0.1:coucou' ] }, token: server.accessToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) @@ -58,7 +58,7 @@ describe('Test server follows API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, + fields: { hosts: [ '127.0.0.1:9002', 'http://127.0.0.1:9003' ] }, token: server.accessToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) @@ -68,7 +68,7 @@ describe('Test server follows API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, + fields: { urls: [ '127.0.0.1:9002', '127.0.0.1:9002' ] }, token: server.accessToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) @@ -78,7 +78,7 @@ describe('Test server follows API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { handles: [ 'hello@example.com', 'localhost:9001' ] }, + fields: { handles: [ 'hello@example.com', '127.0.0.1:9001' ] }, token: server.accessToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) @@ -98,7 +98,7 @@ describe('Test server follows API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { hosts: [ 'localhost:9002' ] }, + fields: { hosts: [ '127.0.0.1:9002' ] }, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) @@ -108,7 +108,7 @@ describe('Test server follows API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { hosts: [ 'localhost:9002' ] }, + fields: { hosts: [ '127.0.0.1:9002' ] }, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) @@ -217,7 +217,7 @@ describe('Test server follows API validators', function () { it('Should fail with an invalid token', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/toto@localhost:9002', + path: path + '/toto@127.0.0.1:9002', token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) @@ -226,7 +226,7 @@ describe('Test server follows API validators', function () { it('Should fail if the user is not an administrator', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/toto@localhost:9002', + path: path + '/toto@127.0.0.1:9002', token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) @@ -244,7 +244,7 @@ describe('Test server follows API validators', function () { it('Should fail with an unknown follower', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/toto@localhost:9003', + path: path + '/toto@127.0.0.1:9003', token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) @@ -257,7 +257,7 @@ describe('Test server follows API validators', function () { it('Should fail with an invalid token', async function () { await makePostBodyRequest({ url: server.url, - path: path + '/toto@localhost:9002/accept', + path: path + '/toto@127.0.0.1:9002/accept', token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) @@ -266,7 +266,7 @@ describe('Test server follows API validators', function () { it('Should fail if the user is not an administrator', async function () { await makePostBodyRequest({ url: server.url, - path: path + '/toto@localhost:9002/accept', + path: path + '/toto@127.0.0.1:9002/accept', token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) @@ -284,7 +284,7 @@ describe('Test server follows API validators', function () { it('Should fail with an unknown follower', async function () { await makePostBodyRequest({ url: server.url, - path: path + '/toto@localhost:9003/accept', + path: path + '/toto@127.0.0.1:9003/accept', token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) @@ -297,7 +297,7 @@ describe('Test server follows API validators', function () { it('Should fail with an invalid token', async function () { await makePostBodyRequest({ url: server.url, - path: path + '/toto@localhost:9002/reject', + path: path + '/toto@127.0.0.1:9002/reject', token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) @@ -306,7 +306,7 @@ describe('Test server follows API validators', function () { it('Should fail if the user is not an administrator', async function () { await makePostBodyRequest({ url: server.url, - path: path + '/toto@localhost:9002/reject', + path: path + '/toto@127.0.0.1:9002/reject', token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) @@ -324,7 +324,7 @@ describe('Test server follows API validators', function () { it('Should fail with an unknown follower', async function () { await makePostBodyRequest({ url: server.url, - path: path + '/toto@localhost:9003/reject', + path: path + '/toto@127.0.0.1:9003/reject', token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) @@ -337,7 +337,7 @@ describe('Test server follows API validators', function () { it('Should fail with an invalid token', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:9002', + path: path + '/127.0.0.1:9002', token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) @@ -346,7 +346,7 @@ describe('Test server follows API validators', function () { it('Should fail if the user is not an administrator', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:9002', + path: path + '/127.0.0.1:9002', token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts index f45860e02..908407b9a 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/server/tests/api/check-params/redundancy.ts @@ -186,7 +186,7 @@ describe('Test server redundancy API validators', function () { it('Should fail with an invalid token', async function () { await makePutBodyRequest({ url: servers[0].url, - path: path + '/localhost:' + servers[1].port, + path: path + '/' + servers[1].host, fields: { redundancyAllowed: true }, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 @@ -196,7 +196,7 @@ describe('Test server redundancy API validators', function () { it('Should fail if the user is not an administrator', async function () { await makePutBodyRequest({ url: servers[0].url, - path: path + '/localhost:' + servers[1].port, + path: path + '/' + servers[1].host, fields: { redundancyAllowed: true }, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 @@ -216,7 +216,7 @@ describe('Test server redundancy API validators', function () { it('Should fail without de redundancyAllowed param', async function () { await makePutBodyRequest({ url: servers[0].url, - path: path + '/localhost:' + servers[1].port, + path: path + '/' + servers[1].host, fields: { blabla: true }, token: servers[0].accessToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 @@ -226,7 +226,7 @@ describe('Test server redundancy API validators', function () { it('Should succeed with the correct parameters', async function () { await makePutBodyRequest({ url: servers[0].url, - path: path + '/localhost:' + servers[1].port, + path: path + '/' + servers[1].host, fields: { redundancyAllowed: true }, token: servers[0].accessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts index 0da675902..d45868f36 100644 --- a/server/tests/api/check-params/services.ts +++ b/server/tests/api/check-params/services.ts @@ -76,87 +76,87 @@ describe('Test services API validators', function () { }) it('Should fail with an invalid element id', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/blabla` + const embedUrl = `${server.url}/videos/watch/blabla` await checkParamEmbed(server, embedUrl) }) it('Should fail with an unknown element', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c` + const embedUrl = `${server.url}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c` await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_FOUND_404) }) it('Should fail with an invalid path', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.store.videoCreated.uuid}` + const embedUrl = `${server.url}/videos/watchs/${server.store.videoCreated.uuid}` await checkParamEmbed(server, embedUrl) }) it('Should fail with an invalid max height', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}` + const embedUrl = `${server.url}/videos/watch/${server.store.videoCreated.uuid}` await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' }) }) it('Should fail with an invalid max width', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}` + const embedUrl = `${server.url}/videos/watch/${server.store.videoCreated.uuid}` await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' }) }) it('Should fail with an invalid format', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}` + const embedUrl = `${server.url}/videos/watch/${server.store.videoCreated.uuid}` await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' }) }) it('Should fail with a non supported format', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}` + const embedUrl = `${server.url}/videos/watch/${server.store.videoCreated.uuid}` await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' }) }) it('Should fail with a private video', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/${privateVideo.uuid}` + const embedUrl = `${server.url}/videos/watch/${privateVideo.uuid}` await checkParamEmbed(server, embedUrl, HttpStatusCode.FORBIDDEN_403) }) it('Should fail with an unlisted video with the int id', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/${unlistedVideo.id}` + const embedUrl = `${server.url}/videos/watch/${unlistedVideo.id}` await checkParamEmbed(server, embedUrl, HttpStatusCode.FORBIDDEN_403) }) it('Should succeed with an unlisted video using the uuid id', async function () { for (const uuid of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) { - const embedUrl = `http://localhost:${server.port}/videos/watch/${uuid}` + const embedUrl = `${server.url}/videos/watch/${uuid}` await checkParamEmbed(server, embedUrl, HttpStatusCode.OK_200) } }) it('Should fail with a private playlist', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${privatePlaylist.uuid}` + const embedUrl = `${server.url}/videos/watch/playlist/${privatePlaylist.uuid}` await checkParamEmbed(server, embedUrl, HttpStatusCode.FORBIDDEN_403) }) it('Should fail with an unlisted playlist using the int id', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${unlistedPlaylist.id}` + const embedUrl = `${server.url}/videos/watch/playlist/${unlistedPlaylist.id}` await checkParamEmbed(server, embedUrl, HttpStatusCode.FORBIDDEN_403) }) it('Should succeed with an unlisted playlist using the uuid id', async function () { for (const uuid of [ unlistedPlaylist.uuid, unlistedPlaylist.shortUUID ]) { - const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${uuid}` + const embedUrl = `${server.url}/videos/watch/playlist/${uuid}` await checkParamEmbed(server, embedUrl, HttpStatusCode.OK_200) } }) it('Should succeed with the correct params with a video', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.videoCreated.uuid}` + const embedUrl = `${server.url}/videos/watch/${server.store.videoCreated.uuid}` const query = { format: 'json', maxheight: 400, @@ -167,7 +167,7 @@ describe('Test services API validators', function () { }) it('Should succeed with the correct params with a playlist', async function () { - const embedUrl = `http://localhost:${server.port}/videos/watch/playlist/${playlistUUID}` + const embedUrl = `${server.url}/videos/watch/playlist/${playlistUUID}` const query = { format: 'json', maxheight: 400, diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 7de2fda79..6a588e446 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts @@ -233,7 +233,7 @@ describe('Test user notifications API validators', function () { describe('When connecting to my notification socket', function () { it('Should fail with no token', function (next) { - const socket = io(`http://localhost:${server.port}/user-notifications`, { reconnection: false }) + const socket = io(`${server.url}/user-notifications`, { reconnection: false }) socket.once('connect_error', function () { socket.disconnect() @@ -247,7 +247,7 @@ describe('Test user notifications API validators', function () { }) it('Should fail with an invalid token', function (next) { - const socket = io(`http://localhost:${server.port}/user-notifications`, { + const socket = io(`${server.url}/user-notifications`, { query: { accessToken: 'bad_access_token' }, reconnection: false }) @@ -264,7 +264,7 @@ describe('Test user notifications API validators', function () { }) it('Should success with the correct token', function (next) { - const socket = io(`http://localhost:${server.port}/user-notifications`, { + const socket = io(`${server.url}/user-notifications`, { query: { accessToken: server.accessToken }, reconnection: false }) diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index a0e663e25..c4922c7a2 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts @@ -104,7 +104,7 @@ describe('Test user subscriptions API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { uri: 'user1_channel@localhost:' + server.port }, + fields: { uri: 'user1_channel@' + server.host }, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -142,7 +142,7 @@ describe('Test user subscriptions API validators', function () { url: server.url, path, token: server.accessToken, - fields: { uri: 'user1_channel@localhost:' + server.port }, + fields: { uri: 'user1_channel@' + server.host }, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) @@ -154,7 +154,7 @@ describe('Test user subscriptions API validators', function () { it('Should fail with a non authenticated user', async function () { await makeGetRequest({ url: server.url, - path: path + '/user1_channel@localhost:' + server.port, + path: path + '/user1_channel@' + server.host, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -185,7 +185,7 @@ describe('Test user subscriptions API validators', function () { it('Should fail with an unknown subscription', async function () { await makeGetRequest({ url: server.url, - path: path + '/root1@localhost:' + server.port, + path: path + '/root1@' + server.host, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) @@ -194,7 +194,7 @@ describe('Test user subscriptions API validators', function () { it('Should succeed with the correct parameters', async function () { await makeGetRequest({ url: server.url, - path: path + '/user1_channel@localhost:' + server.port, + path: path + '/user1_channel@' + server.host, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) @@ -234,7 +234,7 @@ describe('Test user subscriptions API validators', function () { await makeGetRequest({ url: server.url, path: existPath, - query: { 'uris[]': 'coucou@localhost:' + server.port }, + query: { 'uris[]': 'coucou@' + server.host }, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) @@ -245,7 +245,7 @@ describe('Test user subscriptions API validators', function () { it('Should fail with a non authenticated user', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/user1_channel@localhost:' + server.port, + path: path + '/user1_channel@' + server.host, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) @@ -276,7 +276,7 @@ describe('Test user subscriptions API validators', function () { it('Should fail with an unknown subscription', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/root1@localhost:' + server.port, + path: path + '/root1@' + server.host, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) @@ -285,7 +285,7 @@ describe('Test user subscriptions API validators', function () { it('Should succeed with the correct parameters', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/user1_channel@localhost:' + server.port, + path: path + '/user1_channel@' + server.host, token: server.accessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) diff --git a/server/tests/api/check-params/users-admin.ts b/server/tests/api/check-params/users-admin.ts index d941ca024..7ba709c4a 100644 --- a/server/tests/api/check-params/users-admin.ts +++ b/server/tests/api/check-params/users-admin.ts @@ -158,7 +158,7 @@ describe('Test users admin API validators', function () { const config = { smtp: { - hostname: 'localhost', + hostname: '127.0.0.1', port: emailPort } } diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index 27592e8c5..47d29e7f8 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts @@ -154,7 +154,7 @@ describe('Test blocklist', function () { }) it('Should block a remote account', async function () { - await command.addToMyBlocklist({ account: 'user2@localhost:' + servers[1].port }) + await command.addToMyBlocklist({ account: 'user2@' + servers[1].host }) }) it('Should hide its videos', async function () { @@ -217,7 +217,7 @@ describe('Test blocklist', function () { server: servers[0], token: userToken1, videoUUID: videoUUID2, - text: 'hello @root@localhost:' + servers[0].port + text: 'hello @root@' + servers[0].host } await checkCommentNotification(servers[0], comment, 'absence') } @@ -237,7 +237,7 @@ describe('Test blocklist', function () { expect(block.byAccount.name).to.equal('root') expect(block.blockedAccount.displayName).to.equal('user2') expect(block.blockedAccount.name).to.equal('user2') - expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port) + expect(block.blockedAccount.host).to.equal('' + servers[1].host) } { @@ -249,7 +249,7 @@ describe('Test blocklist', function () { expect(block.byAccount.name).to.equal('root') expect(block.blockedAccount.displayName).to.equal('user1') expect(block.blockedAccount.name).to.equal('user1') - expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port) + expect(block.blockedAccount.host).to.equal('' + servers[0].host) } }) @@ -347,7 +347,7 @@ describe('Test blocklist', function () { }) it('Should unblock the remote account', async function () { - await command.removeFromMyBlocklist({ account: 'user2@localhost:' + servers[1].port }) + await command.removeFromMyBlocklist({ account: 'user2@' + servers[1].host }) }) it('Should display its videos', async function () { @@ -401,7 +401,7 @@ describe('Test blocklist', function () { server: servers[0], token: userToken1, videoUUID: videoUUID2, - text: 'hello @root@localhost:' + servers[0].port + text: 'hello @root@' + servers[0].host } await checkCommentNotification(servers[0], comment, 'presence') } @@ -419,7 +419,7 @@ describe('Test blocklist', function () { }) it('Should block a remote server', async function () { - await command.addToMyBlocklist({ server: 'localhost:' + servers[1].port }) + await command.addToMyBlocklist({ server: '' + servers[1].host }) }) it('Should hide its videos', async function () { @@ -463,7 +463,7 @@ describe('Test blocklist', function () { server: servers[1], token: userToken2, videoUUID: videoUUID1, - text: 'hello @root@localhost:' + servers[0].port + text: 'hello @root@' + servers[0].host } await checkCommentNotification(servers[0], comment, 'absence') } @@ -476,7 +476,7 @@ describe('Test blocklist', function () { const block = body.data[0] expect(block.byAccount.displayName).to.equal('root') expect(block.byAccount.name).to.equal('root') - expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) + expect(block.blockedServer.host).to.equal('' + servers[1].host) }) it('Should search blocked servers', async function () { @@ -516,7 +516,7 @@ describe('Test blocklist', function () { }) it('Should unblock the remote server', async function () { - await command.removeFromMyBlocklist({ server: 'localhost:' + servers[1].port }) + await command.removeFromMyBlocklist({ server: '' + servers[1].host }) }) it('Should display its videos', function () { @@ -540,7 +540,7 @@ describe('Test blocklist', function () { server: servers[1], token: userToken2, videoUUID: videoUUID1, - text: 'hello @root@localhost:' + servers[0].port + text: 'hello @root@' + servers[0].host } await checkCommentNotification(servers[0], comment, 'presence') } @@ -564,7 +564,7 @@ describe('Test blocklist', function () { }) it('Should block a remote account', async function () { - await command.addToServerBlocklist({ account: 'user2@localhost:' + servers[1].port }) + await command.addToServerBlocklist({ account: 'user2@' + servers[1].host }) }) it('Should hide its videos', async function () { @@ -624,7 +624,7 @@ describe('Test blocklist', function () { server: servers[1], token: userToken2, videoUUID: videoUUID1, - text: 'hello @root@localhost:' + servers[0].port + text: 'hello @root@' + servers[0].host } await checkCommentNotification(servers[0], comment, 'absence') } @@ -640,7 +640,7 @@ describe('Test blocklist', function () { expect(block.byAccount.name).to.equal('peertube') expect(block.blockedAccount.displayName).to.equal('user2') expect(block.blockedAccount.name).to.equal('user2') - expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port) + expect(block.blockedAccount.host).to.equal('' + servers[1].host) } { @@ -652,7 +652,7 @@ describe('Test blocklist', function () { expect(block.byAccount.name).to.equal('peertube') expect(block.blockedAccount.displayName).to.equal('user1') expect(block.blockedAccount.name).to.equal('user1') - expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port) + expect(block.blockedAccount.host).to.equal('' + servers[0].host) } }) @@ -685,7 +685,7 @@ describe('Test blocklist', function () { }) it('Should unblock the remote account', async function () { - await command.removeFromServerBlocklist({ account: 'user2@localhost:' + servers[1].port }) + await command.removeFromServerBlocklist({ account: 'user2@' + servers[1].host }) }) it('Should display its videos', async function () { @@ -721,7 +721,7 @@ describe('Test blocklist', function () { server: servers[1], token: userToken2, videoUUID: videoUUID1, - text: 'hello @root@localhost:' + servers[0].port + text: 'hello @root@' + servers[0].host } await checkCommentNotification(servers[0], comment, 'presence') } @@ -743,7 +743,7 @@ describe('Test blocklist', function () { }) it('Should block a remote server', async function () { - await command.addToServerBlocklist({ server: 'localhost:' + servers[1].port }) + await command.addToServerBlocklist({ server: '' + servers[1].host }) }) it('Should hide its videos', async function () { @@ -791,7 +791,7 @@ describe('Test blocklist', function () { server: servers[1], token: userToken2, videoUUID: videoUUID1, - text: 'hello @root@localhost:' + servers[0].port + text: 'hello @root@' + servers[0].host } await checkCommentNotification(servers[0], comment, 'absence') } @@ -820,7 +820,7 @@ describe('Test blocklist', function () { const block = body.data[0] expect(block.byAccount.displayName).to.equal('peertube') expect(block.byAccount.name).to.equal('peertube') - expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) + expect(block.blockedServer.host).to.equal('' + servers[1].host) }) it('Should search blocked servers', async function () { @@ -848,7 +848,7 @@ describe('Test blocklist', function () { }) it('Should unblock the remote server', async function () { - await command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }) + await command.removeFromServerBlocklist({ server: '' + servers[1].host }) }) it('Should list all videos', async function () { @@ -876,7 +876,7 @@ describe('Test blocklist', function () { server: servers[1], token: userToken2, videoUUID: videoUUID1, - text: 'hello @root@localhost:' + servers[0].port + text: 'hello @root@' + servers[0].host } await checkCommentNotification(servers[0], comment, 'presence') } diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index 07c981a37..6f059f622 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts @@ -31,7 +31,7 @@ describe('Test admin notifications', function () { peertube: { check_latest_version: { enabled: true, - url: `http://localhost:${port}/versions.json` + url: `http://127.0.0.1:${port}/versions.json` } }, plugins: { diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index 8b8c5712a..5a50af040 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts @@ -257,7 +257,7 @@ describe('Test comments notifications', function () { await waitJobs(servers) - const text1 = `hello @user_1@localhost:${servers[0].port} 1` + const text1 = `hello @user_1@${servers[0].host} 1` const { id: server2ThreadId } = await servers[1].comments.createThread({ videoId: uuid, text: text1 }) await waitJobs(servers) @@ -269,7 +269,7 @@ describe('Test comments notifications', function () { const threadId = data[0].id await checkCommentMention({ ...baseParams, shortUUID, commentId: threadId, threadId, byAccountDisplayName, checkType: 'presence' }) - const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}` + const text2 = `@user_1@${servers[0].host} hello 2 @root@${servers[0].host}` await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 }) await waitJobs(servers) diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 5a632fb22..b127a7a31 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -373,7 +373,7 @@ describe('Test moderation notifications', function () { followings: { instance: { autoFollowIndex: { - indexUrl: `http://localhost:${port}/api/v1/instances/hosts`, + indexUrl: `http://127.0.0.1:${port}/api/v1/instances/hosts`, enabled: true } } @@ -388,10 +388,10 @@ describe('Test moderation notifications', function () { await waitJobs(servers) - await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' }) + await checkNewInstanceFollower({ ...baseParams, followerHost: servers[2].host, checkType: 'presence' }) const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } } - await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' }) + await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: servers[2].host, checkType: 'absence' }) }) it('Should send a notification on auto follow back', async function () { @@ -495,8 +495,8 @@ describe('Test moderation notifications', function () { autoBlacklistTestsCustomConfig.transcoding.enabled = true await servers[0].config.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig }) - await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) - await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) + await servers[0].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host }) + await servers[1].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host }) }) it('Should send notification to moderators on new video with auto-blacklist', async function () { @@ -615,8 +615,8 @@ describe('Test moderation notifications', function () { after(async () => { await servers[0].config.updateCustomConfig({ newCustomConfig: currentCustomConfig }) - await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) - await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) + await servers[0].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host }) + await servers[1].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host }) }) }) diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index f194656c9..1fc861160 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -26,7 +26,7 @@ describe('Test notifications API', function () { userNotifications = res.userNotifications server = res.servers[0] - await server.subscriptions.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port }) + await server.subscriptions.add({ token: userToken, targetUri: 'root_channel@' + server.host }) for (let i = 0; i < 10; i++) { await server.videos.randomUpload({ wait: false }) diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index ceadc21ff..c6087b1eb 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -69,7 +69,7 @@ describe('Test user notifications', function () { it('Should send a new video notification if the user follows the local video publisher', async function () { this.timeout(15000) - await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) + await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@' + servers[0].host }) await waitJobs(servers) const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1) @@ -79,7 +79,7 @@ describe('Test user notifications', function () { it('Should send a new video notification from a remote account', async function () { this.timeout(150000) // Server 2 has transcoding enabled - await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port }) + await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@' + servers[1].host }) await waitJobs(servers) const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2) @@ -509,7 +509,7 @@ describe('Test user notifications', function () { it('Should notify when a local channel is following one of our channel', async function () { this.timeout(50000) - await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) + await servers[0].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host }) await waitJobs(servers) await checkNewActorFollow({ @@ -521,13 +521,13 @@ describe('Test user notifications', function () { checkType: 'presence' }) - await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) + await servers[0].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host }) }) it('Should notify when a remote channel is following one of our channel', async function () { this.timeout(50000) - await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) + await servers[1].subscriptions.add({ targetUri: 'user_1_channel@' + servers[0].host }) await waitJobs(servers) await checkNewActorFollow({ @@ -539,14 +539,14 @@ describe('Test user notifications', function () { checkType: 'presence' }) - await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) + await servers[1].subscriptions.remove({ uri: 'user_1_channel@' + servers[0].host }) }) // PeerTube does not support account -> account follows // it('Should notify when a local account is following one of our channel', async function () { // this.timeout(50000) // - // await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:' + servers[0].port) + // await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@' + servers[0].host) // // await waitJobs(servers) // @@ -556,7 +556,7 @@ describe('Test user notifications', function () { // it('Should notify when a remote account is following one of our channel', async function () { // this.timeout(50000) // - // await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:' + servers[0].port) + // await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@' + servers[0].host) // // await waitJobs(servers) // diff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.ts index d1875febb..1b3c389d7 100644 --- a/server/tests/api/object-storage/videos.ts +++ b/server/tests/api/object-storage/videos.ts @@ -139,7 +139,7 @@ function runTestSuite (options: { this.timeout(120000) const port = await mockObjectStorage.initialize() - baseMockUrl = options.useMockBaseUrl ? `http://localhost:${port}` : undefined + baseMockUrl = options.useMockBaseUrl ? `http://127.0.0.1:${port}` : undefined await ObjectStorageCommand.createMockBucket(options.playlistBucket) await ObjectStorageCommand.createMockBucket(options.webtorrentBucket) diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index fb2e6e91c..57939775e 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts @@ -265,8 +265,8 @@ async function checkStatsWithoutRedundancy (strategy: VideoRedundancyStrategyWit async function findServerFollows () { const body = await servers[0].follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' }) const follows = body.data - const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`) - const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`) + const server2 = follows.find(f => f.following.host === `${servers[1].host}`) + const server3 = follows.find(f => f.following.host === `${servers[2].host}`) return { server2, server3 } } @@ -639,12 +639,12 @@ describe('Test videos redundancy', function () { await wait(10000) try { - await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port) + await checkContains(servers, 'http%3A%2F%2F' + servers[0].hostname + '%3A' + servers[0].port) } catch { // Maybe a server deleted a redundancy in the scheduler await wait(2000) - await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port) + await checkContains(servers, 'http%3A%2F%2F' + servers[0].hostname + '%3A' + servers[0].port) } }) @@ -655,7 +655,7 @@ describe('Test videos redundancy', function () { await wait(15000) - await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A' + servers[0].port) + await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2F' + servers[0].port + '%3A' + servers[0].port) }) after(async function () { diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index 8173c8b60..003bd34d0 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -87,7 +87,7 @@ describe('Test ActivityPub video channels search', function () { it('Should search a local video channel', async function () { const searches = [ servers[0].url + '/video-channels/channel1_server1', - 'channel1_server1@localhost:' + servers[0].port + 'channel1_server1@' + servers[0].host ] for (const search of searches) { @@ -139,7 +139,7 @@ describe('Test ActivityPub video channels search', function () { servers[1].url + '/video-channels/channel1_server2', servers[1].url + '/c/channel1_server2', servers[1].url + '/c/channel1_server2/videos', - 'channel1_server2@localhost:' + servers[1].port + 'channel1_server2@' + servers[1].host ] for (const search of searches) { @@ -169,7 +169,7 @@ describe('Test ActivityPub video channels search', function () { const { total, data } = await servers[0].videos.listByChannel({ token: null, - handle: 'channel1_server2@localhost:' + servers[1].port + handle: 'channel1_server2@' + servers[1].host }) expect(total).to.equal(0) expect(data).to.have.lengthOf(0) @@ -177,7 +177,7 @@ describe('Test ActivityPub video channels search', function () { it('Should list video channel videos of server 2 with token', async function () { const { total, data } = await servers[0].videos.listByChannel({ - handle: 'channel1_server2@localhost:' + servers[1].port + handle: 'channel1_server2@' + servers[1].host }) expect(total).to.equal(1) @@ -226,7 +226,7 @@ describe('Test ActivityPub video channels search', function () { await waitJobs(servers) - const handle = 'channel1_server2@localhost:' + servers[1].port + const handle = 'channel1_server2@' + servers[1].host const { total, data } = await servers[0].videos.listByChannel({ handle, sort: '-createdAt' }) expect(total).to.equal(2) diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts index eae4391ec..c8be762d2 100644 --- a/server/tests/api/search/search-index.ts +++ b/server/tests/api/search/search-index.ts @@ -57,7 +57,7 @@ describe('Test index search', function () { expect(body.total).to.equal(1) expect(body.data[0].name).to.equal('root_channel') - expect(body.data[0].host).to.equal('localhost:' + server.port) + expect(body.data[0].host).to.equal(server.host) }) it('Should make an index videos search by default', async function () { diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts index cdaadb3ad..99d5c3142 100644 --- a/server/tests/api/server/auto-follows.ts +++ b/server/tests/api/server/auto-follows.ts @@ -150,7 +150,7 @@ describe('Test auto follows', function () { followings: { instance: { autoFollowIndex: { - indexUrl: `http://localhost:${port}/api/v1/instances/hosts`, + indexUrl: `http://127.0.0.1:${port}/api/v1/instances/hosts`, enabled: true } } diff --git a/server/tests/api/server/bulk.ts b/server/tests/api/server/bulk.ts index 7c8b40cbe..1fe26bb26 100644 --- a/server/tests/api/server/bulk.ts +++ b/server/tests/api/server/bulk.ts @@ -77,7 +77,7 @@ describe('Test bulk actions', function () { const { data } = await servers[1].comments.listThreads({ videoId: video.id }) const comment = data.find(c => c.text === 'comment by user 3') - if (video.account.host === 'localhost:' + servers[0].port) { + if (video.account.host === servers[0].host) { expect(comment).to.not.exist } else { expect(comment).to.exist @@ -151,7 +151,7 @@ describe('Test bulk actions', function () { await bulkCommand.removeCommentsOf({ attributes: { - accountName: 'user3@localhost:' + servers[1].port, + accountName: 'user3@' + servers[1].host, scope: 'instance' } }) diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts index fcd7f3c4c..325218008 100644 --- a/server/tests/api/server/contact-form.ts +++ b/server/tests/api/server/contact-form.ts @@ -25,7 +25,7 @@ describe('Test contact form', function () { const overrideConfig = { smtp: { - hostname: 'localhost', + hostname: '127.0.0.1', port } } @@ -51,7 +51,7 @@ describe('Test contact form', function () { const email = emails[0] - expect(email['from'][0]['address']).equal('test-admin@localhost') + expect(email['from'][0]['address']).equal('test-admin@127.0.0.1') expect(email['replyTo'][0]['address']).equal('toto@example.com') expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com') expect(email['subject']).contains('my subject') diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index 1826c268a..4ab5463fe 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts @@ -33,7 +33,7 @@ describe('Test emails', function () { const overrideConfig = { smtp: { - hostname: 'localhost', + hostname: '127.0.0.1', port: emailPort } } @@ -66,8 +66,6 @@ describe('Test emails', function () { describe('When resetting user password', function () { it('Should ask to reset the password', async function () { - this.timeout(10000) - await server.users.askResetPassword({ email: 'user_1@example.com' }) await waitJobs(server) @@ -76,7 +74,7 @@ describe('Test emails', function () { const email = emails[0] expect(email['from'][0]['name']).equal('PeerTube') - expect(email['from'][0]['address']).equal('test-admin@localhost') + expect(email['from'][0]['address']).equal('test-admin@127.0.0.1') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains('password') @@ -135,7 +133,7 @@ describe('Test emails', function () { const email = emails[1] expect(email['from'][0]['name']).equal('PeerTube') - expect(email['from'][0]['address']).equal('test-admin@localhost') + expect(email['from'][0]['address']).equal('test-admin@127.0.0.1') expect(email['to'][0]['address']).equal('create_password@example.com') expect(email['subject']).contains('account') expect(email['subject']).contains('password') @@ -191,7 +189,7 @@ describe('Test emails', function () { const email = emails[2] expect(email['from'][0]['name']).equal('PeerTube') - expect(email['from'][0]['address']).equal('test-admin@localhost') + expect(email['from'][0]['address']).equal('test-admin@127.0.0.1') expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com') expect(email['subject']).contains('abuse') expect(email['text']).contains(videoShortUUID) @@ -212,7 +210,7 @@ describe('Test emails', function () { const email = emails[3] expect(email['from'][0]['name']).equal('PeerTube') - expect(email['from'][0]['address']).equal('test-admin@localhost') + expect(email['from'][0]['address']).equal('test-admin@127.0.0.1') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' blocked') expect(email['text']).contains(' blocked') @@ -230,7 +228,7 @@ describe('Test emails', function () { const email = emails[4] expect(email['from'][0]['name']).equal('PeerTube') - expect(email['from'][0]['address']).equal('test-admin@localhost') + expect(email['from'][0]['address']).equal('test-admin@127.0.0.1') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' unblocked') expect(email['text']).contains(' unblocked') @@ -250,7 +248,7 @@ describe('Test emails', function () { const email = emails[5] expect(email['from'][0]['name']).equal('PeerTube') - expect(email['from'][0]['address']).equal('test-admin@localhost') + expect(email['from'][0]['address']).equal('test-admin@127.0.0.1') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' blacklisted') expect(email['text']).contains('my super user video') @@ -268,7 +266,7 @@ describe('Test emails', function () { const email = emails[6] expect(email['from'][0]['name']).equal('PeerTube') - expect(email['from'][0]['address']).equal('test-admin@localhost') + expect(email['from'][0]['address']).equal('test-admin@127.0.0.1') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' unblacklisted') expect(email['text']).contains('my super user video') @@ -293,7 +291,7 @@ describe('Test emails', function () { const email = emails[7] expect(email['from'][0]['name']).equal('PeerTube') - expect(email['from'][0]['address']).equal('test-admin@localhost') + expect(email['from'][0]['address']).equal('test-admin@127.0.0.1') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains('Verify') diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts index e1ec2b069..ff5332858 100644 --- a/server/tests/api/server/follow-constraints.ts +++ b/server/tests/api/server/follow-constraints.ts @@ -57,21 +57,21 @@ describe('Test follow constraints', function () { }) it('Should list local account videos', async function () { - const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[0].port }) + const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@' + servers[0].host }) expect(total).to.equal(1) expect(data).to.have.lengthOf(1) }) it('Should list remote account videos', async function () { - const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[1].port }) + const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@' + servers[1].host }) expect(total).to.equal(1) expect(data).to.have.lengthOf(1) }) it('Should list local channel videos', async function () { - const handle = 'root_channel@localhost:' + servers[0].port + const handle = 'root_channel@' + servers[0].host const { total, data } = await servers[0].videos.listByChannel({ handle }) expect(total).to.equal(1) @@ -79,7 +79,7 @@ describe('Test follow constraints', function () { }) it('Should list remote channel videos', async function () { - const handle = 'root_channel@localhost:' + servers[1].port + const handle = 'root_channel@' + servers[1].host const { total, data } = await servers[0].videos.listByChannel({ handle }) expect(total).to.equal(1) @@ -97,21 +97,21 @@ describe('Test follow constraints', function () { }) it('Should list local account videos', async function () { - const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port }) + const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@' + servers[0].host }) expect(total).to.equal(1) expect(data).to.have.lengthOf(1) }) it('Should list remote account videos', async function () { - const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port }) + const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@' + servers[1].host }) expect(total).to.equal(1) expect(data).to.have.lengthOf(1) }) it('Should list local channel videos', async function () { - const handle = 'root_channel@localhost:' + servers[0].port + const handle = 'root_channel@' + servers[0].host const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle }) expect(total).to.equal(1) @@ -119,7 +119,7 @@ describe('Test follow constraints', function () { }) it('Should list remote channel videos', async function () { - const handle = 'root_channel@localhost:' + servers[1].port + const handle = 'root_channel@' + servers[1].host const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle }) expect(total).to.equal(1) @@ -161,7 +161,7 @@ describe('Test follow constraints', function () { it('Should list local account videos', async function () { const { total, data } = await servers[0].videos.listByAccount({ token: null, - handle: 'root@localhost:' + servers[0].port + handle: 'root@' + servers[0].host }) expect(total).to.equal(1) @@ -171,7 +171,7 @@ describe('Test follow constraints', function () { it('Should not list remote account videos', async function () { const { total, data } = await servers[0].videos.listByAccount({ token: null, - handle: 'root@localhost:' + servers[1].port + handle: 'root@' + servers[1].host }) expect(total).to.equal(0) @@ -179,7 +179,7 @@ describe('Test follow constraints', function () { }) it('Should list local channel videos', async function () { - const handle = 'root_channel@localhost:' + servers[0].port + const handle = 'root_channel@' + servers[0].host const { total, data } = await servers[0].videos.listByChannel({ token: null, handle }) expect(total).to.equal(1) @@ -187,7 +187,7 @@ describe('Test follow constraints', function () { }) it('Should not list remote channel videos', async function () { - const handle = 'root_channel@localhost:' + servers[1].port + const handle = 'root_channel@' + servers[1].host const { total, data } = await servers[0].videos.listByChannel({ token: null, handle }) expect(total).to.equal(0) @@ -206,21 +206,21 @@ describe('Test follow constraints', function () { }) it('Should list local account videos', async function () { - const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port }) + const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@' + servers[0].host }) expect(total).to.equal(1) expect(data).to.have.lengthOf(1) }) it('Should list remote account videos', async function () { - const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port }) + const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@' + servers[1].host }) expect(total).to.equal(1) expect(data).to.have.lengthOf(1) }) it('Should list local channel videos', async function () { - const handle = 'root_channel@localhost:' + servers[0].port + const handle = 'root_channel@' + servers[0].host const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle }) expect(total).to.equal(1) @@ -228,7 +228,7 @@ describe('Test follow constraints', function () { }) it('Should list remote channel videos', async function () { - const handle = 'root_channel@localhost:' + servers[1].port + const handle = 'root_channel@' + servers[1].host const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle }) expect(total).to.equal(1) diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index 96d39352b..6a2cc2c43 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts @@ -88,7 +88,7 @@ describe('Test follows', function () { const follows = body.data expect(follows).to.be.an('array') expect(follows).to.have.lengthOf(1) - expect(follows[0].follower.host).to.equal('localhost:' + servers[0].port) + expect(follows[0].follower.host).to.equal(servers[0].host) }) it('Should have 0 followers on server 1 and 2', async function () { diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index 9ace65ddf..1fb4d18f9 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts @@ -62,7 +62,7 @@ describe('Test handle downs', function () { support: 'my super support text for server 1', account: { name: 'root', - host: 'localhost:' + servers[0].port + host: servers[0].host }, isLocal: false, duration: 10, @@ -151,7 +151,7 @@ describe('Test handle downs', function () { const body = await servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' }) expect(body.data).to.be.an('array') expect(body.data).to.have.lengthOf(1) - expect(body.data[0].follower.host).to.equal('localhost:' + servers[2].port) + expect(body.data[0].follower.host).to.equal(servers[2].host) }) it('Should not have pending/processing jobs anymore', async function () { diff --git a/server/tests/api/server/open-telemetry.ts b/server/tests/api/server/open-telemetry.ts index 7a294be82..db76a3d7f 100644 --- a/server/tests/api/server/open-telemetry.ts +++ b/server/tests/api/server/open-telemetry.ts @@ -9,7 +9,7 @@ describe('Open Telemetry', function () { let server: PeerTubeServer describe('Metrics', function () { - const metricsUrl = 'http://localhost:9092/metrics' + const metricsUrl = 'http://127.0.0.1:9092/metrics' it('Should not enable open telemetry metrics', async function () { this.timeout(60000) @@ -92,7 +92,7 @@ describe('Open Telemetry', function () { tracing: { enabled: true, jaeger_exporter: { - endpoint: 'http://localhost:' + mockPort + endpoint: 'http://127.0.0.1:' + mockPort } } } diff --git a/server/tests/api/server/proxy.ts b/server/tests/api/server/proxy.ts index 71c444efd..de8872d74 100644 --- a/server/tests/api/server/proxy.ts +++ b/server/tests/api/server/proxy.ts @@ -20,7 +20,7 @@ describe('Test proxy', function () { let proxy: MockProxy const goodEnv = { HTTP_PROXY: '' } - const badEnv = { HTTP_PROXY: 'http://localhost:9000' } + const badEnv = { HTTP_PROXY: 'http://127.0.0.1:9000' } before(async function () { this.timeout(120000) @@ -30,7 +30,7 @@ describe('Test proxy', function () { const proxyPort = await proxy.initialize() servers = await createMultipleServers(2) - goodEnv.HTTP_PROXY = 'http://localhost:' + proxyPort + goodEnv.HTTP_PROXY = 'http://127.0.0.1:' + proxyPort await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index fbeca7d67..b45cfe67e 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -63,8 +63,8 @@ describe('Test users subscriptions', function () { it('User of server 1 should follow user of server 3 and root of server 1', async function () { this.timeout(60000) - await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) - await command.add({ token: users[0].accessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) + await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@' + servers[2].host }) + await command.add({ token: users[0].accessToken, targetUri: 'root_channel@' + servers[0].host }) await waitJobs(servers) @@ -112,20 +112,20 @@ describe('Test users subscriptions', function () { it('Should get subscription', async function () { { - const videoChannel = await command.get({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) + const videoChannel = await command.get({ token: users[0].accessToken, uri: 'user3_channel@' + servers[2].host }) expect(videoChannel.name).to.equal('user3_channel') - expect(videoChannel.host).to.equal('localhost:' + servers[2].port) + expect(videoChannel.host).to.equal(servers[2].host) expect(videoChannel.displayName).to.equal('Main user3 channel') expect(videoChannel.followingCount).to.equal(0) expect(videoChannel.followersCount).to.equal(1) } { - const videoChannel = await command.get({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) + const videoChannel = await command.get({ token: users[0].accessToken, uri: 'root_channel@' + servers[0].host }) expect(videoChannel.name).to.equal('root_channel') - expect(videoChannel.host).to.equal('localhost:' + servers[0].port) + expect(videoChannel.host).to.equal(servers[0].host) expect(videoChannel.displayName).to.equal('Main root channel') expect(videoChannel.followingCount).to.equal(0) expect(videoChannel.followersCount).to.equal(1) @@ -134,18 +134,18 @@ describe('Test users subscriptions', function () { it('Should return the existing subscriptions', async function () { const uris = [ - 'user3_channel@localhost:' + servers[2].port, - 'root2_channel@localhost:' + servers[0].port, - 'root_channel@localhost:' + servers[0].port, - 'user3_channel@localhost:' + servers[0].port + 'user3_channel@' + servers[2].host, + 'root2_channel@' + servers[0].host, + 'root_channel@' + servers[0].host, + 'user3_channel@' + servers[0].host ] const body = await command.exist({ token: users[0].accessToken, uris }) - expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true - expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false - expect(body['root_channel@localhost:' + servers[0].port]).to.be.true - expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false + expect(body['user3_channel@' + servers[2].host]).to.be.true + expect(body['root2_channel@' + servers[0].host]).to.be.false + expect(body['root_channel@' + servers[0].host]).to.be.true + expect(body['user3_channel@' + servers[0].host]).to.be.false }) it('Should search among subscriptions', async function () { @@ -305,7 +305,7 @@ describe('Test users subscriptions', function () { it('Should remove user of server 3 subscription', async function () { this.timeout(30000) - await command.remove({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) + await command.remove({ token: users[0].accessToken, uri: 'user3_channel@' + servers[2].host }) await waitJobs(servers) }) @@ -324,7 +324,7 @@ describe('Test users subscriptions', function () { it('Should remove the root subscription and not display the videos anymore', async function () { this.timeout(30000) - await command.remove({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) + await command.remove({ token: users[0].accessToken, uri: 'root_channel@' + servers[0].host }) await waitJobs(servers) @@ -355,7 +355,7 @@ describe('Test users subscriptions', function () { it('Should follow user of server 3 again', async function () { this.timeout(60000) - await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) + await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@' + servers[2].host }) await waitJobs(servers) @@ -389,8 +389,8 @@ describe('Test users subscriptions', function () { await servers[2].channels.create({ token: users[2].accessToken, attributes: { name: 'user3_channel2' } }) - await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) - await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel2@localhost:' + servers[2].port }) + await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel@' + servers[2].host }) + await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel2@' + servers[2].host }) await waitJobs(servers) }) diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 188e6f137..f94191b04 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts @@ -111,7 +111,7 @@ describe('Test users with multiple servers', function () { for (const server of servers) { const body = await server.accounts.list({ sort: '-createdAt' }) - const resList = body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port) + const resList = body.data.find(a => a.name === 'root' && a.host === servers[0].host) expect(resList).not.to.be.undefined const account = await server.accounts.get({ accountName: resList.name + '@' + resList.host }) @@ -119,7 +119,7 @@ describe('Test users with multiple servers', function () { if (!createdAt) createdAt = account.createdAt expect(account.name).to.equal('root') - expect(account.host).to.equal('localhost:' + servers[0].port) + expect(account.host).to.equal(servers[0].host) expect(account.displayName).to.equal('my super display name') expect(account.description).to.equal('my super description updated') expect(createdAt).to.equal(account.createdAt) @@ -138,7 +138,7 @@ describe('Test users with multiple servers', function () { it('Should list account videos', async function () { for (const server of servers) { - const { total, data } = await server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port }) + const { total, data } = await server.videos.listByAccount({ handle: 'user1@' + servers[0].host }) expect(total).to.equal(1) expect(data).to.be.an('array') @@ -155,7 +155,7 @@ describe('Test users with multiple servers', function () { await waitJobs(servers) for (const server of servers) { - const { total, data } = await server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port, search: 'Kami' }) + const { total, data } = await server.videos.listByAccount({ handle: 'user1@' + servers[0].host, search: 'Kami' }) expect(total).to.equal(1) expect(data).to.be.an('array') @@ -170,11 +170,11 @@ describe('Test users with multiple servers', function () { for (const server of servers) { const body = await server.accounts.list({ sort: '-createdAt' }) - const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) + const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === servers[0].host) expect(accountDeleted).not.to.be.undefined const { data } = await server.channels.list() - const videoChannelDeleted = data.find(a => a.displayName === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port) + const videoChannelDeleted = data.find(a => a.displayName === 'Main user1 channel' && a.host === servers[0].host) expect(videoChannelDeleted).not.to.be.undefined } @@ -185,11 +185,11 @@ describe('Test users with multiple servers', function () { for (const server of servers) { const body = await server.accounts.list({ sort: '-createdAt' }) - const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) + const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === servers[0].host) expect(accountDeleted).to.be.undefined const { data } = await server.channels.list() - const videoChannelDeleted = data.find(a => a.name === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port) + const videoChannelDeleted = data.find(a => a.name === 'Main user1 channel' && a.host === servers[0].host) expect(videoChannelDeleted).to.be.undefined } }) diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts index fc082383a..19a8df9e1 100644 --- a/server/tests/api/users/users-verification.ts +++ b/server/tests/api/users/users-verification.ts @@ -28,7 +28,7 @@ describe('Test users account verification', function () { const overrideConfig = { smtp: { - hostname: 'localhost', + hostname: '127.0.0.1', port } } diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 2ad749fd4..ff730287a 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -105,7 +105,7 @@ describe('Test multiple servers', function () { originallyPublishedAt: '2019-02-10T13:38:14.449Z', account: { name: 'root', - host: 'localhost:' + servers[0].port + host: servers[0].host }, isLocal, publishedAt, @@ -185,7 +185,7 @@ describe('Test multiple servers', function () { // All servers should have this video for (const server of servers) { - const isLocal = server.url === 'http://localhost:' + servers[1].port + const isLocal = server.url === servers[1].url const checkAttributes = { name: 'my super name for server 2', category: 4, @@ -196,7 +196,7 @@ describe('Test multiple servers', function () { support: 'my super support text for server 2', account: { name: 'user1', - host: 'localhost:' + servers[1].port + host: servers[1].host }, isLocal, commentsEnabled: true, @@ -279,7 +279,7 @@ describe('Test multiple servers', function () { // All servers should have this video for (const server of servers) { - const isLocal = server.url === 'http://localhost:' + servers[2].port + const isLocal = server.url === servers[2].url const { data } = await server.videos.list() expect(data).to.be.an('array') @@ -306,7 +306,7 @@ describe('Test multiple servers', function () { support: 'my super support text for server 3', account: { name: 'root', - host: 'localhost:' + servers[2].port + host: servers[2].host }, isLocal, duration: 5, @@ -340,7 +340,7 @@ describe('Test multiple servers', function () { support: 'my super support text for server 3-2', account: { name: 'root', - host: 'localhost:' + servers[2].port + host: servers[2].host }, commentsEnabled: true, downloadEnabled: true, @@ -649,7 +649,7 @@ describe('Test multiple servers', function () { expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin) - const isLocal = server.url === 'http://localhost:' + servers[2].port + const isLocal = server.url === servers[2].url const checkAttributes = { name: 'my super video updated', category: 10, @@ -661,7 +661,7 @@ describe('Test multiple servers', function () { originallyPublishedAt: '2019-02-11T13:38:14.449Z', account: { name: 'root', - host: 'localhost:' + servers[2].port + host: servers[2].host }, isLocal, duration: 5, @@ -830,7 +830,7 @@ describe('Test multiple servers', function () { expect(comment).to.not.be.undefined expect(comment.inReplyToCommentId).to.be.null expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:' + servers[0].port) + expect(comment.account.host).to.equal(servers[0].host) expect(comment.totalReplies).to.equal(3) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -841,7 +841,7 @@ describe('Test multiple servers', function () { expect(comment).to.not.be.undefined expect(comment.inReplyToCommentId).to.be.null expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:' + servers[2].port) + expect(comment.account.host).to.equal(servers[2].host) expect(comment.totalReplies).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -858,25 +858,25 @@ describe('Test multiple servers', function () { expect(tree.comment.text).equal('my super first comment') expect(tree.comment.account.name).equal('root') - expect(tree.comment.account.host).equal('localhost:' + servers[0].port) + expect(tree.comment.account.host).equal(servers[0].host) expect(tree.children).to.have.lengthOf(2) const firstChild = tree.children[0] expect(firstChild.comment.text).to.equal('my super answer to thread 1') expect(firstChild.comment.account.name).equal('root') - expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port) + expect(firstChild.comment.account.host).equal(servers[1].host) expect(firstChild.children).to.have.lengthOf(1) childOfFirstChild = firstChild.children[0] expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') expect(childOfFirstChild.comment.account.name).equal('root') - expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port) + expect(childOfFirstChild.comment.account.host).equal(servers[2].host) expect(childOfFirstChild.children).to.have.lengthOf(0) const secondChild = tree.children[1] expect(secondChild.comment.text).to.equal('my second answer to thread 1') expect(secondChild.comment.account.name).equal('root') - expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port) + expect(secondChild.comment.account.host).equal(servers[2].host) expect(secondChild.children).to.have.lengthOf(0) } }) @@ -935,7 +935,7 @@ describe('Test multiple servers', function () { expect(comment).to.not.be.undefined expect(comment.inReplyToCommentId).to.be.null expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:' + servers[2].port) + expect(comment.account.host).to.equal(servers[2].host) expect(comment.totalReplies).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -1042,7 +1042,7 @@ describe('Test multiple servers', function () { const { data } = await server.videos.list() const video = data.find(v => v.name === 'minimum parameters') - const isLocal = server.url === 'http://localhost:' + servers[1].port + const isLocal = server.url === servers[1].url const checkAttributes = { name: 'minimum parameters', category: null, @@ -1053,7 +1053,7 @@ describe('Test multiple servers', function () { support: null, account: { name: 'root', - host: 'localhost:' + servers[1].port + host: servers[1].host }, isLocal, duration: 5, diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index da8bde07b..e8e981e55 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -33,7 +33,7 @@ describe('Test a single server', function () { support: 'my super support text', account: { name: 'root', - host: 'localhost:' + server.port + host: server.host }, isLocal: true, duration: 5, @@ -66,7 +66,7 @@ describe('Test a single server', function () { support: 'my super support text updated', account: { name: 'root', - host: 'localhost:' + server.port + host: server.host }, isLocal: true, tags: [ 'tagup1', 'tagup2' ], diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 86a8a038c..64bd4d9ae 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -373,7 +373,7 @@ describe('Test video channels', function () { this.timeout(10000) for (const server of servers) { - const channelURI = 'second_video_channel@localhost:' + servers[0].port + const channelURI = 'second_video_channel@' + servers[0].host const { total, data } = await server.videos.listByChannel({ handle: channelURI }) expect(total).to.equal(1) @@ -396,13 +396,13 @@ describe('Test video channels', function () { for (const server of servers) { { - const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port + const secondChannelURI = 'second_video_channel@' + servers[0].host const { total } = await server.videos.listByChannel({ handle: secondChannelURI }) expect(total).to.equal(0) } { - const channelURI = 'root_channel@localhost:' + servers[0].port + const channelURI = 'root_channel@' + servers[0].host const { total, data } = await server.videos.listByChannel({ handle: channelURI }) expect(total).to.equal(1) diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index 348b408e8..dc47f8a4a 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts @@ -63,8 +63,8 @@ describe('Test video comments', function () { expect(comment.videoId).to.equal(videoId) expect(comment.id).to.equal(comment.threadId) expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:' + server.port) - expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root') + expect(comment.account.host).to.equal(server.host) + expect(comment.account.url).to.equal(server.url + '/accounts/root') expect(comment.totalReplies).to.equal(0) expect(comment.totalRepliesFromVideoAuthor).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true @@ -85,7 +85,7 @@ describe('Test video comments', function () { expect(comment.videoId).to.equal(videoId) expect(comment.id).to.equal(comment.threadId) expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:' + server.port) + expect(comment.account.host).to.equal(server.host) for (const avatar of comment.account.avatars) { await testImage(server.url, `avatar-resized-${avatar.width}x${avatar.width}`, avatar.path, '.png') diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index a3de73ba5..6a18cf26a 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts @@ -404,7 +404,7 @@ describe('Test video playlists', function () { it('Should not list unlisted or private playlists', async function () { for (const server of servers) { const results = [ - await server.playlists.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }), + await server.playlists.listByAccount({ handle: 'root@' + servers[1].host, sort: '-createdAt' }), await server.playlists.list({ start: 0, count: 2, sort: '-createdAt' }) ] @@ -701,52 +701,52 @@ describe('Test video playlists', function () { const position = 2 { - await command.addToMyBlocklist({ token: userTokenServer1, account: 'root@localhost:' + servers[1].port }) + await command.addToMyBlocklist({ token: userTokenServer1, account: 'root@' + servers[1].host }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) - await command.removeFromMyBlocklist({ token: userTokenServer1, account: 'root@localhost:' + servers[1].port }) + await command.removeFromMyBlocklist({ token: userTokenServer1, account: 'root@' + servers[1].host }) await waitJobs(servers) await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) } { - await command.addToMyBlocklist({ token: userTokenServer1, server: 'localhost:' + servers[1].port }) + await command.addToMyBlocklist({ token: userTokenServer1, server: servers[1].host }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) - await command.removeFromMyBlocklist({ token: userTokenServer1, server: 'localhost:' + servers[1].port }) + await command.removeFromMyBlocklist({ token: userTokenServer1, server: servers[1].host }) await waitJobs(servers) await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) } { - await command.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port }) + await command.addToServerBlocklist({ account: 'root@' + servers[1].host }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) - await command.removeFromServerBlocklist({ account: 'root@localhost:' + servers[1].port }) + await command.removeFromServerBlocklist({ account: 'root@' + servers[1].host }) await waitJobs(servers) await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) } { - await command.addToServerBlocklist({ server: 'localhost:' + servers[1].port }) + await command.addToServerBlocklist({ server: servers[1].host }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.UNAVAILABLE, position, name, 3) await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) - await command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }) + await command.removeFromServerBlocklist({ server: servers[1].host }) await waitJobs(servers) await checkPlaylistElementType(group2, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index a39bcfebe..400d5867c 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -300,7 +300,7 @@ describe('Test CLI wrapper', function () { const stdout = await cliCommand.execWithEnv(`${cmd} redundancy ${params}`) expect(stdout).to.contain('super video') - expect(stdout).to.contain(`localhost:${server.port}`) + expect(stdout).to.contain(server.host) } }) diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index ba0fa1f86..8bdf2136d 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -94,7 +94,7 @@ describe('Test prune storage scripts', function () { // Lazy load the remote avatars { - const account = await servers[0].accounts.get({ accountName: 'root@localhost:' + servers[1].port }) + const account = await servers[0].accounts.get({ accountName: 'root@' + servers[1].host }) for (const avatar of account.avatars) { await makeGetRequest({ @@ -106,7 +106,7 @@ describe('Test prune storage scripts', function () { } { - const account = await servers[1].accounts.get({ accountName: 'root@localhost:' + servers[0].port }) + const account = await servers[1].accounts.get({ accountName: 'root@' + servers[0].host }) for (const avatar of account.avatars) { await makeGetRequest({ url: servers[1].url, diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index 97632450a..51257d3d3 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -67,7 +67,7 @@ describe('Test update host scripts', function () { for (const video of data) { const { body } = await makeActivityPubGetRequest(server.url, '/videos/watch/' + video.uuid) - expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid) + expect(body.id).to.equal('http://127.0.0.1:9002/videos/watch/' + video.uuid) const videoDetails = await server.videos.get({ id: video.uuid }) @@ -84,7 +84,7 @@ describe('Test update host scripts', function () { for (const channel of data) { const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.name) - expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.name) + expect(body.id).to.equal('http://127.0.0.1:9002/video-channels/' + channel.name) } }) @@ -96,7 +96,7 @@ describe('Test update host scripts', function () { const usernameWithDomain = account.name const { body } = await makeActivityPubGetRequest(server.url, '/accounts/' + usernameWithDomain) - expect(body.id).to.equal('http://localhost:9002/accounts/' + usernameWithDomain) + expect(body.id).to.equal('http://127.0.0.1:9002/accounts/' + usernameWithDomain) } }) @@ -113,17 +113,17 @@ describe('Test update host scripts', function () { expect(files).to.have.lengthOf(8) for (const file of files) { - expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') - expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2F') + expect(file.magnetUri).to.contain('127.0.0.1%3A9002%2Ftracker%2Fsocket') + expect(file.magnetUri).to.contain('127.0.0.1%3A9002%2Fstatic%2F') const torrent = await parseTorrentVideo(server, file) - const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket') + const announceWS = torrent.announce.find(a => a === 'ws://127.0.0.1:9002/tracker/socket') expect(announceWS).to.not.be.undefined - const announceHttp = torrent.announce.find(a => a === 'http://localhost:9002/tracker/announce') + const announceHttp = torrent.announce.find(a => a === 'http://127.0.0.1:9002/tracker/announce') expect(announceHttp).to.not.be.undefined - expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/') + expect(torrent.urlList[0]).to.contain('http://127.0.0.1:9002/static/') } } }) diff --git a/server/tests/client.ts b/server/tests/client.ts index 39ba5fdf6..e0dae2b5e 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts @@ -134,11 +134,9 @@ describe('Test a client controllers', function () { expectedStatus: HttpStatusCode.OK_200 }) - const port = servers[0].port - - const expectedLink = '` + const expectedLink = `` expect(res.text).to.contain(expectedLink) } @@ -155,10 +153,8 @@ describe('Test a client controllers', function () { expectedStatus: HttpStatusCode.OK_200 }) - const port = servers[0].port - - const expectedLink = '` expect(res.text).to.contain(expectedLink) diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts index 6f6a574a0..d51d337be 100644 --- a/server/tests/external-plugins/auth-ldap.ts +++ b/server/tests/external-plugins/auth-ldap.ts @@ -32,7 +32,7 @@ describe('Official plugin auth-ldap', function () { 'mail-property': 'mail', 'search-base': 'ou=people,dc=planetexpress,dc=com', 'search-filter': '(|(mail={{username}})(uid={{username}}))', - 'url': 'ldap://localhost:390', + 'url': 'ldap://127.0.0.1:390', 'username-property': 'uid' } }) @@ -50,7 +50,7 @@ describe('Official plugin auth-ldap', function () { 'mail-property': 'mail', 'search-base': 'ou=people,dc=planetexpress,dc=com', 'search-filter': '(|(mail={{username}})(uid={{username}}))', - 'url': 'ldap://localhost:10389', + 'url': 'ldap://127.0.0.1:10389', 'username-property': 'uid' } }) diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts index 7df0b3390..d14587c38 100644 --- a/server/tests/external-plugins/auto-block-videos.ts +++ b/server/tests/external-plugins/auto-block-videos.ts @@ -64,7 +64,7 @@ describe('Official plugin auto-block videos', function () { await servers[0].plugins.updateSettings({ npmName: 'peertube-plugin-auto-block-videos', settings: { - 'blocklist-urls': `http://localhost:${port}/blocklist`, + 'blocklist-urls': `http://127.0.0.1:${port}/blocklist`, 'check-seconds-interval': 1 } }) diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts index b4578cd90..440b58bfd 100644 --- a/server/tests/external-plugins/auto-mute.ts +++ b/server/tests/external-plugins/auto-mute.ts @@ -43,7 +43,7 @@ describe('Official plugin auto-mute', function () { await servers[0].plugins.updateSettings({ npmName: 'peertube-plugin-auto-mute', settings: { - 'blocklist-urls': `http://localhost:${port}/blocklist`, + 'blocklist-urls': `http://127.0.0.1:${port}/blocklist`, 'check-seconds-interval': 1 } }) @@ -55,7 +55,7 @@ describe('Official plugin auto-mute', function () { blocklistServer.replace({ data: [ { - value: 'localhost:' + servers[1].port + value: servers[1].host } ] }) @@ -72,7 +72,7 @@ describe('Official plugin auto-mute', function () { blocklistServer.replace({ data: [ { - value: 'localhost:' + servers[1].port, + value: servers[1].host, action: 'remove' } ] @@ -90,7 +90,7 @@ describe('Official plugin auto-mute', function () { blocklistServer.replace({ data: [ { - value: 'root@localhost:' + servers[1].port + value: 'root@' + servers[1].host } ] }) @@ -107,7 +107,7 @@ describe('Official plugin auto-mute', function () { blocklistServer.replace({ data: [ { - value: 'root@localhost:' + servers[1].port, + value: 'root@' + servers[1].host, action: 'remove' } ] @@ -122,7 +122,7 @@ describe('Official plugin auto-mute', function () { it('Should auto mute an account, manually unmute it and do not remute it automatically', async function () { this.timeout(20000) - const account = 'root@localhost:' + servers[1].port + const account = 'root@' + servers[1].host blocklistServer.replace({ data: [ @@ -188,14 +188,14 @@ describe('Official plugin auto-mute', function () { await servers[1].plugins.updateSettings({ npmName: 'peertube-plugin-auto-mute', settings: { - 'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath, + 'blocklist-urls': 'http://' + servers[0].host + autoMuteListPath, 'check-seconds-interval': 1, 'expose-mute-list': false } }) - await servers[0].blocklist.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port }) - await servers[0].blocklist.addToMyBlocklist({ server: 'localhost:' + servers[1].port }) + await servers[0].blocklist.addToServerBlocklist({ account: 'root@' + servers[1].host }) + await servers[0].blocklist.addToMyBlocklist({ server: servers[1].host }) const res = await makeGetRequest({ url: servers[0].url, @@ -206,7 +206,7 @@ describe('Official plugin auto-mute', function () { const data = res.body.data expect(data).to.have.lengthOf(1) expect(data[0].updatedAt).to.exist - expect(data[0].value).to.equal('root@localhost:' + servers[1].port) + expect(data[0].value).to.equal('root@' + servers[1].host) await wait(2000) diff --git a/server/tests/fixtures/ap-json/peertube/announce-without-context.json b/server/tests/fixtures/ap-json/peertube/announce-without-context.json index 5f2af0cde..cda1c514c 100644 --- a/server/tests/fixtures/ap-json/peertube/announce-without-context.json +++ b/server/tests/fixtures/ap-json/peertube/announce-without-context.json @@ -1,13 +1,13 @@ { "type": "Announce", - "id": "http://localhost:9002/videos/watch/997111d4-e8d8-4f45-99d3-857905785d05/announces/1", - "actor": "http://localhost:9002/accounts/peertube", - "object": "http://localhost:9002/videos/watch/997111d4-e8d8-4f45-99d3-857905785d05", + "id": "http://127.0.0.1:9002/videos/watch/997111d4-e8d8-4f45-99d3-857905785d05/announces/1", + "actor": "http://127.0.0.1:9002/accounts/peertube", + "object": "http://127.0.0.1:9002/videos/watch/997111d4-e8d8-4f45-99d3-857905785d05", "to": [ "https://www.w3.org/ns/activitystreams#Public", - "http://localhost:9002/accounts/peertube/followers", - "http://localhost:9002/video-channels/root_channel/followers", - "http://localhost:9002/accounts/root/followers" + "http://127.0.0.1:9002/accounts/peertube/followers", + "http://127.0.0.1:9002/video-channels/root_channel/followers", + "http://127.0.0.1:9002/accounts/root/followers" ], "cc": [] } diff --git a/server/tests/helpers/request.ts b/server/tests/helpers/request.ts index a85d80b88..363237df5 100644 --- a/server/tests/helpers/request.ts +++ b/server/tests/helpers/request.ts @@ -41,7 +41,7 @@ describe('Request helpers', function () { const port = await mock.initialize() const before = new Date().getTime() - await doRequest('http://localhost:' + port) + await doRequest('http://127.0.0.1:' + port) expect(new Date().getTime() - before).to.be.greaterThan(2000) diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts index d2072342e..f9cf2b717 100644 --- a/server/tests/misc-endpoints.ts +++ b/server/tests/misc-endpoints.ts @@ -166,7 +166,7 @@ describe('Test misc endpoints', function () { }) expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') - expect(res.text).to.contain('http://localhost:' + server.port + '/about/instance') + expect(res.text).to.contain('' + server.url + '/about/instance') }) it('Should get the empty cached sitemap', async function () { @@ -177,7 +177,7 @@ describe('Test misc endpoints', function () { }) expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') - expect(res.text).to.contain('http://localhost:' + server.port + '/about/instance') + expect(res.text).to.contain('' + server.url + '/about/instance') }) it('Should add videos, channel and accounts and get sitemap', async function () { @@ -200,17 +200,17 @@ describe('Test misc endpoints', function () { }) expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') - expect(res.text).to.contain('http://localhost:' + server.port + '/about/instance') + expect(res.text).to.contain('' + server.url + '/about/instance') expect(res.text).to.contain('video 1') expect(res.text).to.contain('video 2') expect(res.text).to.not.contain('video 3') - expect(res.text).to.contain('http://localhost:' + server.port + '/video-channels/channel1') - expect(res.text).to.contain('http://localhost:' + server.port + '/video-channels/channel2') + expect(res.text).to.contain('' + server.url + '/video-channels/channel1') + expect(res.text).to.contain('' + server.url + '/video-channels/channel2') - expect(res.text).to.contain('http://localhost:' + server.port + '/accounts/user1') - expect(res.text).to.contain('http://localhost:' + server.port + '/accounts/user2') + expect(res.text).to.contain('' + server.url + '/accounts/user1') + expect(res.text).to.contain('' + server.url + '/accounts/user2') }) it('Should not fail with big title/description videos', async function () { diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index f2bada4ee..038e3f0d6 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts @@ -46,7 +46,7 @@ describe('Test plugin helpers', function () { describe('Logger', function () { it('Should have logged things', async function () { - await servers[0].servers.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false) + await servers[0].servers.waitUntilLog(servers[0].host + ' peertube-plugin-test-four', 1, false) await servers[0].servers.waitUntilLog('Hello world from plugin four', 1) }) }) @@ -61,7 +61,7 @@ describe('Test plugin helpers', function () { describe('Config', function () { it('Should have the correct webserver url', async function () { - await servers[0].servers.waitUntilLog(`server url is http://localhost:${servers[0].port}`) + await servers[0].servers.waitUntilLog(`server url is ${servers[0].url}`) }) it('Should have the correct config', async function () { @@ -208,7 +208,7 @@ describe('Test plugin helpers', function () { it('Should mute server 2', async function () { this.timeout(10000) - await postCommand(servers[0], 'blockServer', { hostToBlock: `localhost:${servers[1].port}` }) + await postCommand(servers[0], 'blockServer', { hostToBlock: servers[1].host }) const { data } = await servers[0].videos.list() @@ -217,7 +217,7 @@ describe('Test plugin helpers', function () { }) it('Should unmute server 2', async function () { - await postCommand(servers[0], 'unblockServer', { hostToUnblock: `localhost:${servers[1].port}` }) + await postCommand(servers[0], 'unblockServer', { hostToUnblock: servers[1].host }) const { data } = await servers[0].videos.list() @@ -225,7 +225,7 @@ describe('Test plugin helpers', function () { }) it('Should mute account of server 2', async function () { - await postCommand(servers[0], 'blockAccount', { handleToBlock: `root@localhost:${servers[1].port}` }) + await postCommand(servers[0], 'blockAccount', { handleToBlock: `root@${servers[1].host}` }) const { data } = await servers[0].videos.list() @@ -234,7 +234,7 @@ describe('Test plugin helpers', function () { }) it('Should unmute account of server 2', async function () { - await postCommand(servers[0], 'unblockAccount', { handleToUnblock: `root@localhost:${servers[1].port}` }) + await postCommand(servers[0], 'unblockAccount', { handleToUnblock: `root@${servers[1].host}` }) const { data } = await servers[0].videos.list() diff --git a/server/tests/shared/notifications.ts b/server/tests/shared/notifications.ts index ee15e2b09..e600bd6b2 100644 --- a/server/tests/shared/notifications.ts +++ b/server/tests/shared/notifications.ts @@ -371,7 +371,7 @@ async function checkNewCommentOnMyVideo (options: CheckerBaseParams & { } } - const commentUrl = `http://localhost:${server.port}/w/${shortUUID};threadId=${threadId}` + const commentUrl = `${server.url}/w/${shortUUID};threadId=${threadId}` function emailNotificationFinder (email: object) { return email['text'].indexOf(commentUrl) !== -1 @@ -674,7 +674,7 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an const overrideConfig = { smtp: { - hostname: 'localhost', + hostname: '127.0.0.1', port }, signup: { -- cgit v1.2.3