From c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/tests/plugins/external-auth.ts | 20 ++++++++++---------- server/tests/plugins/filter-hooks.ts | 10 +++++----- server/tests/plugins/id-and-pass-auth.ts | 2 +- server/tests/plugins/plugin-helpers.ts | 20 ++++++++++---------- server/tests/plugins/plugin-router.ts | 14 +++++++------- server/tests/plugins/plugin-storage.ts | 4 ++-- server/tests/plugins/plugin-unloading.ts | 10 +++++----- server/tests/plugins/video-constants.ts | 2 +- 8 files changed, 41 insertions(+), 41 deletions(-) (limited to 'server/tests/plugins') diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index c0834a14c..a2828603a 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, decodeQueryString, @@ -20,15 +20,15 @@ async function loginExternal (options: { authName: string username: string query?: any - statusCodeExpected?: HttpStatusCode - statusCodeExpectedStep2?: HttpStatusCode + expectedStatus?: HttpStatusCode + expectedStatusStep2?: HttpStatusCode }) { const res = await options.server.plugins.getExternalAuth({ npmName: options.npmName, npmVersion: '0.0.1', authName: options.authName, query: options.query, - expectedStatus: options.statusCodeExpected || HttpStatusCode.FOUND_302 + expectedStatus: options.expectedStatus || HttpStatusCode.FOUND_302 }) if (res.status !== HttpStatusCode.FOUND_302) return @@ -39,7 +39,7 @@ async function loginExternal (options: { const resLogin = await options.server.login.loginUsingExternalToken({ username: options.username, externalAuthToken: externalAuthToken as string, - expectedStatus: options.statusCodeExpectedStep2 + expectedStatus: options.expectedStatusStep2 }) return resLogin.body @@ -268,7 +268,7 @@ describe('Test external auth plugins', function () { username: 'kefka' }, username: 'kefka', - statusCodeExpected: HttpStatusCode.NOT_FOUND_404 + expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) @@ -293,7 +293,7 @@ describe('Test external auth plugins', function () { username: 'cyan' }, username: 'cyan', - statusCodeExpected: HttpStatusCode.NOT_FOUND_404 + expectedStatus: HttpStatusCode.NOT_FOUND_404 }) await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) @@ -307,7 +307,7 @@ describe('Test external auth plugins', function () { npmName: 'test-external-auth-two', authName: 'external-auth-4', username: 'kefka2', - statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 + expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400 }) await loginExternal({ @@ -315,7 +315,7 @@ describe('Test external auth plugins', function () { npmName: 'test-external-auth-two', authName: 'external-auth-4', username: 'kefka', - statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 + expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400 }) }) @@ -327,7 +327,7 @@ describe('Test external auth plugins', function () { npmName: 'test-external-auth-two', authName: 'external-auth-6', username: 'existing_user', - statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 + expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400 }) }) diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index df52bb3b5..ba84dd27a 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, createMultipleServers, @@ -71,28 +71,28 @@ describe('Test plugin filter hooks', function () { }) it('Should run filter:api.accounts.videos.list.params', async function () { - const { data } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 }) + const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) // 1 plugin do +1 to the count parameter expect(data).to.have.lengthOf(3) }) it('Should run filter:api.accounts.videos.list.result', async function () { - const { total } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 }) + const { total } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) // Plugin do +2 to the total result expect(total).to.equal(12) }) it('Should run filter:api.video-channels.videos.list.params', async function () { - const { data } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) + const { data } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }) // 1 plugin do +3 to the count parameter expect(data).to.have.lengthOf(5) }) it('Should run filter:api.video-channels.videos.list.result', async function () { - const { total } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) + const { total } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }) // Plugin do +3 to the total result expect(total).to.equal(13) diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index 981bcad91..a73d76caa 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' import { UserRole } from '@shared/models' diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index 1d87b84ae..5cb664bda 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { checkVideoFilesWereRemoved, cleanupTests, @@ -24,7 +24,7 @@ function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) url: server.url, path: '/plugins/test-four/router/commander', fields: body, - statusCodeExpected: HttpStatusCode.NO_CONTENT_204 + expectedStatus: HttpStatusCode.NO_CONTENT_204 }) } @@ -67,7 +67,7 @@ describe('Test plugin helpers', function () { const res = await makeGetRequest({ url: servers[0].url, path: '/plugins/test-four/router/server-config', - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.serverConfig).to.exist @@ -88,7 +88,7 @@ describe('Test plugin helpers', function () { const res = await makeGetRequest({ url: servers[0].url, path: '/plugins/test-four/router/static-route', - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/') @@ -100,7 +100,7 @@ describe('Test plugin helpers', function () { const res = await makeGetRequest({ url: servers[0].url, path: baseRouter + 'router-route', - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.routerRoute).to.equal(baseRouter) @@ -113,7 +113,7 @@ describe('Test plugin helpers', function () { await makeGetRequest({ url: servers[0].url, path: '/plugins/test-four/router/user', - statusCodeExpected: HttpStatusCode.NOT_FOUND_404 + expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) @@ -122,7 +122,7 @@ describe('Test plugin helpers', function () { url: servers[0].url, token: servers[0].accessToken, path: '/plugins/test-four/router/user', - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.username).to.equal('root') @@ -140,12 +140,12 @@ describe('Test plugin helpers', function () { this.timeout(60000) { - const res = await await servers[0].videos.quickUpload({ name: 'video server 1' }) + const res = await servers[0].videos.quickUpload({ name: 'video server 1' }) videoUUIDServer1 = res.uuid } { - await await servers[1].videos.quickUpload({ name: 'video server 2' }) + await servers[1].videos.quickUpload({ name: 'video server 2' }) } await waitJobs(servers) @@ -224,7 +224,7 @@ describe('Test plugin helpers', function () { let videoUUID: string before(async () => { - const res = await await servers[0].videos.quickUpload({ name: 'video1' }) + const res = await servers[0].videos.quickUpload({ name: 'video1' }) videoUUID = res.uuid }) diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts index dec8ca4bb..becb7c47b 100644 --- a/server/tests/plugins/plugin-router.ts +++ b/server/tests/plugins/plugin-router.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, createSingleServer, @@ -34,7 +34,7 @@ describe('Test plugin helpers', function () { const res = await makeGetRequest({ url: server.url, path: path + 'ping', - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.message).to.equal('pong') @@ -47,7 +47,7 @@ describe('Test plugin helpers', function () { url: server.url, path: path + 'is-authenticated', token: server.accessToken, - statusCodeExpected: 200 + expectedStatus: 200 }) expect(res.body.isAuthenticated).to.equal(true) @@ -55,7 +55,7 @@ describe('Test plugin helpers', function () { const secRes = await makeGetRequest({ url: server.url, path: path + 'is-authenticated', - statusCodeExpected: 200 + expectedStatus: 200 }) expect(secRes.body.isAuthenticated).to.equal(false) @@ -74,7 +74,7 @@ describe('Test plugin helpers', function () { url: server.url, path: path + 'form/post/mirror', fields: body, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body).to.deep.equal(body) @@ -88,14 +88,14 @@ describe('Test plugin helpers', function () { await makeGetRequest({ url: server.url, path: path + 'ping', - statusCodeExpected: HttpStatusCode.NOT_FOUND_404 + expectedStatus: HttpStatusCode.NOT_FOUND_404 }) await makePostBodyRequest({ url: server.url, path: path + 'ping', fields: {}, - statusCodeExpected: HttpStatusCode.NOT_FOUND_404 + expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } }) diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts index 5745914a5..90dafa3e1 100644 --- a/server/tests/plugins/plugin-storage.ts +++ b/server/tests/plugins/plugin-storage.ts @@ -4,7 +4,7 @@ import 'mocha' import { expect } from 'chai' import { pathExists, readdir, readFile } from 'fs-extra' import { join } from 'path' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, createSingleServer, @@ -63,7 +63,7 @@ describe('Test plugin storage', function () { url: server.url, token: server.accessToken, path: '/plugins/test-six/router/create-file', - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) const content = await getFileContent() diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index 6c405b7f5..faf9cc599 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, createSingleServer, @@ -30,7 +30,7 @@ describe('Test plugins module unloading', function () { const res = await makeGetRequest({ url: server.url, path: requestPath, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.message).to.match(/^\d+$/) @@ -41,7 +41,7 @@ describe('Test plugins module unloading', function () { const res = await makeGetRequest({ url: server.url, path: requestPath, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.message).to.be.equal(value) @@ -53,7 +53,7 @@ describe('Test plugins module unloading', function () { await makeGetRequest({ url: server.url, path: requestPath, - statusCodeExpected: HttpStatusCode.NOT_FOUND_404 + expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) @@ -63,7 +63,7 @@ describe('Test plugins module unloading', function () { const res = await makeGetRequest({ url: server.url, path: requestPath, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) expect(res.body.message).to.match(/^\d+$/) diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts index 953916e8e..dd3b40225 100644 --- a/server/tests/plugins/video-constants.ts +++ b/server/tests/plugins/video-constants.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' import { VideoPlaylistPrivacy } from '@shared/models' -- cgit v1.2.3