X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideos-common-filters.ts;h=6b3ec917ecdee6e761b0f86633f46b662f9a6bee;hb=bf54587a3e2ad9c2c186828f2a5682b91ee2cc00;hp=afe42b0d5226143627a034b8ecd67eba28885fe4;hpb=2760b454a761f6af3138b2fb5f34340772ab0d1e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/videos-common-filters.ts b/server/tests/api/check-params/videos-common-filters.ts index afe42b0d5..6b3ec917e 100644 --- a/server/tests/api/check-params/videos-common-filters.ts +++ b/server/tests/api/check-params/videos-common-filters.ts @@ -8,8 +8,8 @@ import { PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel -} from '@shared/extra-utils' -import { HttpStatusCode, UserRole, VideoInclude } from '@shared/models' +} from '@shared/server-commands' +import { HttpStatusCode, UserRole, VideoInclude, VideoPrivacy } from '@shared/models' describe('Test video filters validators', function () { let server: PeerTubeServer @@ -112,7 +112,7 @@ describe('Test video filters validators', function () { const validIncludes = [ VideoInclude.NONE, - VideoInclude.HIDDEN_PRIVACY, + VideoInclude.BLOCKED_OWNER, VideoInclude.NOT_PUBLISHED_STATE | VideoInclude.BLACKLISTED ] @@ -120,6 +120,7 @@ describe('Test video filters validators', function () { token?: string isLocal?: boolean include?: VideoInclude + privacyOneOf?: VideoPrivacy[] expectedStatus: HttpStatusCode }) { const paths = [ @@ -136,6 +137,7 @@ describe('Test video filters validators', function () { token: options.token || server.accessToken, query: { isLocal: options.isLocal, + privacyOneOf: options.privacyOneOf, include: options.include }, expectedStatus: options.expectedStatus @@ -143,6 +145,22 @@ describe('Test video filters validators', function () { } } + it('Should fail with a bad privacyOneOf', async function () { + await testEndpoints({ privacyOneOf: [ 'toto' ] as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) + }) + + it('Should succeed with a good privacyOneOf', async function () { + await testEndpoints({ privacyOneOf: [ VideoPrivacy.INTERNAL ], expectedStatus: HttpStatusCode.OK_200 }) + }) + + it('Should fail to use privacyOneOf with a simple user', async function () { + await testEndpoints({ + privacyOneOf: [ VideoPrivacy.INTERNAL ], + token: userAccessToken, + expectedStatus: HttpStatusCode.UNAUTHORIZED_401 + }) + }) + it('Should fail with a bad include', async function () { await testEndpoints({ include: 'toto' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) })