From a02b93ce756d646a59cef57b5e4ff53c2bb30bec Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 6 Aug 2020 16:14:58 +0200 Subject: Fix lint --- server/middlewares/validators/plugins.ts | 4 +++- server/middlewares/validators/videos/video-blacklist.ts | 9 +++++---- server/tests/api/check-params/abuses.ts | 4 ++++ 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'server') diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts index 2cb49ec43..cba261dc0 100644 --- a/server/middlewares/validators/plugins.ts +++ b/server/middlewares/validators/plugins.ts @@ -4,7 +4,7 @@ import { logger } from '../../helpers/logger' import { areValidationErrors } from './utils' import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' import { PluginManager } from '../../lib/plugins/plugin-manager' -import { isBooleanValid, isSafePath, toBooleanOrNull, exists } from '../../helpers/custom-validators/misc' +import { isBooleanValid, isSafePath, toBooleanOrNull, exists, toIntOrNull } from '../../helpers/custom-validators/misc' import { PluginModel } from '../../models/server/plugin' import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' import { PluginType } from '../../../shared/models/plugins/plugin.type' @@ -75,6 +75,7 @@ const pluginStaticDirectoryValidator = [ const listPluginsValidator = [ query('pluginType') .optional() + .customSanitizer(toIntOrNull) .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), query('uninstalled') .optional() @@ -165,6 +166,7 @@ const listAvailablePluginsValidator = [ .exists().withMessage('Should have a valid search'), query('pluginType') .optional() + .customSanitizer(toIntOrNull) .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), query('currentPeerTubeEngine') .optional() diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts index 4bd6a8333..808fefc25 100644 --- a/server/middlewares/validators/videos/video-blacklist.ts +++ b/server/middlewares/validators/videos/video-blacklist.ts @@ -1,10 +1,10 @@ import * as express from 'express' import { body, param, query } from 'express-validator' -import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' -import { logger } from '../../../helpers/logger' -import { areValidationErrors } from '../utils' +import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' +import { logger } from '../../../helpers/logger' import { doesVideoBlacklistExist, doesVideoExist } from '../../../helpers/middlewares' +import { areValidationErrors } from '../utils' const videosBlacklistRemoveValidator = [ param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), @@ -67,7 +67,8 @@ const videosBlacklistUpdateValidator = [ const videosBlacklistFiltersValidator = [ query('type') - .optional() + .optional() + .customSanitizer(toIntOrNull) .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'), query('search') .optional() diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts index 1f040bbcf..8dadd9922 100644 --- a/server/tests/api/check-params/abuses.ts +++ b/server/tests/api/check-params/abuses.ts @@ -421,6 +421,10 @@ describe('Test abuses API validators', function () { it('Should fail when creating abuse message of a remote abuse', async function () { await addAbuseMessage(server.url, server.accessToken, remoteAbuseId, 'message', 400) }) + + after(async function () { + await cleanupTests([ anotherServer ]) + }) }) after(async function () { -- cgit v1.2.3