X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fuser-subscriptions.ts;h=1edba4d64af30dc2c06835bad7b781e198399bd5;hb=77e9f859c6ad75ba179dec74e5410cc651eaa49b;hp=6af7ed43b1fd3552f8e9fc17b766e5361d1912a2;hpb=8d1fa36ad22a21a9b0fb6bf51a27d09954220013;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index 6af7ed43b..1edba4d64 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts @@ -1,21 +1,25 @@ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' import { + cleanupTests, createUser, - flushTests, - killallServers, + flushAndRunServer, makeDeleteRequest, makeGetRequest, makePostBodyRequest, - runServer, ServerInfo, setAccessTokensToServers, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/extra-utils' + +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/extra-utils/requests/check-api-params' +import { waitJobs } from '../../../../shared/extra-utils/server/jobs' describe('Test user subscriptions API validators', function () { const path = '/api/v1/users/me/subscriptions' @@ -27,9 +31,7 @@ describe('Test user subscriptions API validators', function () { before(async function () { this.timeout(30000) - await flushTests() - - server = await runServer(1) + server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) @@ -37,7 +39,7 @@ describe('Test user subscriptions API validators', function () { username: 'user1', password: 'my super 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) }) @@ -110,7 +112,7 @@ describe('Test user subscriptions API validators', function () { await makePostBodyRequest({ url: server.url, path, - fields: { uri: 'user1_channel@localhost:9001' }, + fields: { uri: 'user1_channel@localhost:' + server.port }, statusCodeExpected: 401 }) }) @@ -148,7 +150,7 @@ describe('Test user subscriptions API validators', function () { url: server.url, path, token: server.accessToken, - fields: { uri: 'user1_channel@localhost:9001' }, + fields: { uri: 'user1_channel@localhost:' + server.port }, statusCodeExpected: 204 }) @@ -160,7 +162,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:9001', + path: path + '/user1_channel@localhost:' + server.port, statusCodeExpected: 401 }) }) @@ -191,7 +193,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:9001', + path: path + '/root1@localhost:' + server.port, token: server.accessToken, statusCodeExpected: 404 }) @@ -200,14 +202,14 @@ 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:9001', + path: path + '/user1_channel@localhost:' + server.port, token: server.accessToken, statusCodeExpected: 200 }) }) }) - describe('When checking if subscriptions exist', async function () { + describe('When checking if subscriptions exist', function () { const existPath = path + '/exist' it('Should fail with a non authenticated user', async function () { @@ -240,7 +242,7 @@ describe('Test user subscriptions API validators', function () { await makeGetRequest({ url: server.url, path: existPath, - query: { 'uris[]': 'coucou@localhost:9001' }, + query: { 'uris[]': 'coucou@localhost:' + server.port }, token: server.accessToken, statusCodeExpected: 200 }) @@ -251,7 +253,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:9001', + path: path + '/user1_channel@localhost:' + server.port, statusCodeExpected: 401 }) }) @@ -282,7 +284,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:9001', + path: path + '/root1@localhost:' + server.port, token: server.accessToken, statusCodeExpected: 404 }) @@ -291,7 +293,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:9001', + path: path + '/user1_channel@localhost:' + server.port, token: server.accessToken, statusCodeExpected: 204 }) @@ -299,11 +301,6 @@ describe('Test user subscriptions API validators', function () { }) after(async function () { - killallServers([ server ]) - - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + await cleanupTests([ server ]) }) })