This commit is contained in:
Chocobozzz 2020-08-06 16:14:58 +02:00 committed by Chocobozzz
parent d88c9eb9db
commit a02b93ce75
13 changed files with 37 additions and 25 deletions

View file

@ -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()

View file

@ -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()

View file

@ -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 () {