diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-06 16:14:58 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-08-07 08:28:14 +0200 |
commit | a02b93ce756d646a59cef57b5e4ff53c2bb30bec (patch) | |
tree | 02c70651eed0a4c414e04239aa853b2377228ce9 /server | |
parent | d88c9eb9db19965d0075d5835b8837649b2728fd (diff) | |
download | PeerTube-a02b93ce756d646a59cef57b5e4ff53c2bb30bec.tar.gz PeerTube-a02b93ce756d646a59cef57b5e4ff53c2bb30bec.tar.zst PeerTube-a02b93ce756d646a59cef57b5e4ff53c2bb30bec.zip |
Fix lint
Diffstat (limited to 'server')
-rw-r--r-- | server/middlewares/validators/plugins.ts | 4 | ||||
-rw-r--r-- | server/middlewares/validators/videos/video-blacklist.ts | 9 | ||||
-rw-r--r-- | server/tests/api/check-params/abuses.ts | 4 |
3 files changed, 12 insertions, 5 deletions
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' | |||
4 | import { areValidationErrors } from './utils' | 4 | import { areValidationErrors } from './utils' |
5 | import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' | 5 | import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' |
6 | import { PluginManager } from '../../lib/plugins/plugin-manager' | 6 | import { PluginManager } from '../../lib/plugins/plugin-manager' |
7 | import { isBooleanValid, isSafePath, toBooleanOrNull, exists } from '../../helpers/custom-validators/misc' | 7 | import { isBooleanValid, isSafePath, toBooleanOrNull, exists, toIntOrNull } from '../../helpers/custom-validators/misc' |
8 | import { PluginModel } from '../../models/server/plugin' | 8 | import { PluginModel } from '../../models/server/plugin' |
9 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' | 9 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' |
10 | import { PluginType } from '../../../shared/models/plugins/plugin.type' | 10 | import { PluginType } from '../../../shared/models/plugins/plugin.type' |
@@ -75,6 +75,7 @@ const pluginStaticDirectoryValidator = [ | |||
75 | const listPluginsValidator = [ | 75 | const listPluginsValidator = [ |
76 | query('pluginType') | 76 | query('pluginType') |
77 | .optional() | 77 | .optional() |
78 | .customSanitizer(toIntOrNull) | ||
78 | .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), | 79 | .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), |
79 | query('uninstalled') | 80 | query('uninstalled') |
80 | .optional() | 81 | .optional() |
@@ -165,6 +166,7 @@ const listAvailablePluginsValidator = [ | |||
165 | .exists().withMessage('Should have a valid search'), | 166 | .exists().withMessage('Should have a valid search'), |
166 | query('pluginType') | 167 | query('pluginType') |
167 | .optional() | 168 | .optional() |
169 | .customSanitizer(toIntOrNull) | ||
168 | .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), | 170 | .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), |
169 | query('currentPeerTubeEngine') | 171 | query('currentPeerTubeEngine') |
170 | .optional() | 172 | .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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' | 3 | import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' |
4 | import { logger } from '../../../helpers/logger' | ||
5 | import { areValidationErrors } from '../utils' | ||
6 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' | 4 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' |
5 | import { logger } from '../../../helpers/logger' | ||
7 | import { doesVideoBlacklistExist, doesVideoExist } from '../../../helpers/middlewares' | 6 | import { doesVideoBlacklistExist, doesVideoExist } from '../../../helpers/middlewares' |
7 | import { areValidationErrors } from '../utils' | ||
8 | 8 | ||
9 | const videosBlacklistRemoveValidator = [ | 9 | const videosBlacklistRemoveValidator = [ |
10 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), | 10 | param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), |
@@ -67,7 +67,8 @@ const videosBlacklistUpdateValidator = [ | |||
67 | 67 | ||
68 | const videosBlacklistFiltersValidator = [ | 68 | const videosBlacklistFiltersValidator = [ |
69 | query('type') | 69 | query('type') |
70 | .optional() | 70 | .optional() |
71 | .customSanitizer(toIntOrNull) | ||
71 | .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'), | 72 | .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'), |
72 | query('search') | 73 | query('search') |
73 | .optional() | 74 | .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 () { | |||
421 | it('Should fail when creating abuse message of a remote abuse', async function () { | 421 | it('Should fail when creating abuse message of a remote abuse', async function () { |
422 | await addAbuseMessage(server.url, server.accessToken, remoteAbuseId, 'message', 400) | 422 | await addAbuseMessage(server.url, server.accessToken, remoteAbuseId, 'message', 400) |
423 | }) | 423 | }) |
424 | |||
425 | after(async function () { | ||
426 | await cleanupTests([ anotherServer ]) | ||
427 | }) | ||
424 | }) | 428 | }) |
425 | 429 | ||
426 | after(async function () { | 430 | after(async function () { |