X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fblocklist.ts;h=169b591a35670b2b14d7d36fdfd54db8aa850d53;hb=2732eeff9e6994582293b5aaa0cb158b7e272e9e;hp=f72a892e2dc7baec1e990f5277e460291b6e6df9;hpb=a554bc1a260a525cd635d62404b9fe76fdb9e36b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts index f72a892e2..169b591a3 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/server/tests/api/check-params/blocklist.ts @@ -1,10 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' +import { HttpStatusCode } from '@shared/models' import { - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination, cleanupTests, createMultipleServers, doubleFollow, @@ -13,8 +11,7 @@ import { makePostBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/extra-utils' -import { HttpStatusCode } from '@shared/models' +} from '@shared/server-commands' describe('Test blocklist API validators', function () { let servers: PeerTubeServer[] @@ -166,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 }) }) @@ -176,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 }) }) @@ -186,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 }) }) @@ -196,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 }) }) @@ -206,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 }) }) @@ -214,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 }) @@ -223,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 }) @@ -396,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 }) }) @@ -406,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 }) }) @@ -416,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 }) }) @@ -426,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 }) }) @@ -436,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 }) }) @@ -446,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 }) }) @@ -454,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 }) @@ -463,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 }) @@ -472,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 })