X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fblocklist.ts;h=0661676ce6091bb7d36250767f79e02184d31023;hb=592c735c19b25e9b38f82d90d15a81307902ed62;hp=c20453c160e0a1cb9046f13704fdc3ab2887edd5;hpb=b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts index c20453c16..0661676ce 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/server/tests/api/check-params/blocklist.ts @@ -3,22 +3,22 @@ import 'mocha' import { + cleanupTests, createUser, doubleFollow, flushAndRunMultipleServers, - flushTests, - killallServers, makeDeleteRequest, makeGetRequest, makePostBodyRequest, ServerInfo, - setAccessTokensToServers, userLogin -} from '../../../../shared/utils' + setAccessTokensToServers, + userLogin +} from '../../../../shared/extra-utils' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination -} from '../../../../shared/utils/requests/check-api-params' +} from '../../../../shared/extra-utils/requests/check-api-params' describe('Test blocklist API validators', function () { let servers: ServerInfo[] @@ -28,15 +28,13 @@ describe('Test blocklist API validators', function () { before(async function () { this.timeout(60000) - await flushTests() - servers = await flushAndRunMultipleServers(2) await setAccessTokensToServers(servers) server = servers[0] const user = { username: 'user1', password: 'password' } - await createUser(server.url, server.accessToken, user.username, user.password) + await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) userAccessToken = await userLogin(server, user) @@ -192,7 +190,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:9001' }, + fields: { host: 'localhost:' + server.port }, statusCodeExpected: 409 }) }) @@ -202,7 +200,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:9002' }, + fields: { host: 'localhost:' + servers[1].port }, statusCodeExpected: 204 }) }) @@ -212,7 +210,7 @@ describe('Test blocklist API validators', function () { it('Should fail with an unauthenticated user', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:9002', + path: path + '/localhost:' + servers[1].port, statusCodeExpected: 401 }) }) @@ -229,7 +227,7 @@ describe('Test blocklist API validators', function () { it('Should succeed with the correct params', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:9002', + path: path + '/localhost:' + servers[1].port, token: server.accessToken, statusCodeExpected: 204 }) @@ -402,7 +400,7 @@ describe('Test blocklist API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { host: 'localhost:9002' }, + fields: { host: 'localhost:' + servers[1].port }, statusCodeExpected: 401 }) }) @@ -412,7 +410,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: userAccessToken, path, - fields: { host: 'localhost:9002' }, + fields: { host: 'localhost:' + servers[1].port }, statusCodeExpected: 403 }) }) @@ -432,7 +430,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:9001' }, + fields: { host: 'localhost:' + server.port }, statusCodeExpected: 409 }) }) @@ -442,7 +440,7 @@ describe('Test blocklist API validators', function () { url: server.url, token: server.accessToken, path, - fields: { host: 'localhost:9002' }, + fields: { host: 'localhost:' + servers[1].port }, statusCodeExpected: 204 }) }) @@ -452,7 +450,7 @@ describe('Test blocklist API validators', function () { it('Should fail with an unauthenticated user', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:9002', + path: path + '/localhost:' + servers[1].port, statusCodeExpected: 401 }) }) @@ -460,7 +458,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:9002', + path: path + '/localhost:' + servers[1].port, token: userAccessToken, statusCodeExpected: 403 }) @@ -478,7 +476,7 @@ describe('Test blocklist API validators', function () { it('Should succeed with the correct params', async function () { await makeDeleteRequest({ url: server.url, - path: path + '/localhost:9002', + path: path + '/localhost:' + servers[1].port, token: server.accessToken, statusCodeExpected: 204 }) @@ -488,11 +486,6 @@ describe('Test blocklist API validators', function () { }) after(async function () { - killallServers(servers) - - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + await cleanupTests(servers) }) })