aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-12 14:19:56 +0100
committerChocobozzz <me@florianbigard.com>2021-11-12 14:23:22 +0100
commit527a52ac4295a072927ff46761766a8b181a7603 (patch)
tree632f66b1691d8d72f04630671af8bdf1655d6b00 /server/tests/api/check-params
parent8f2608e9a9d54c87ace636f99cdb9d2a7730990f (diff)
downloadPeerTube-527a52ac4295a072927ff46761766a8b181a7603.tar.gz
PeerTube-527a52ac4295a072927ff46761766a8b181a7603.tar.zst
PeerTube-527a52ac4295a072927ff46761766a8b181a7603.zip
Add ability to filter out public videos from admin
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/videos-common-filters.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/server/tests/api/check-params/videos-common-filters.ts b/server/tests/api/check-params/videos-common-filters.ts
index afe42b0d5..f2b5bee8e 100644
--- a/server/tests/api/check-params/videos-common-filters.ts
+++ b/server/tests/api/check-params/videos-common-filters.ts
@@ -9,7 +9,7 @@ import {
9 setAccessTokensToServers, 9 setAccessTokensToServers,
10 setDefaultVideoChannel 10 setDefaultVideoChannel
11} from '@shared/extra-utils' 11} from '@shared/extra-utils'
12import { HttpStatusCode, UserRole, VideoInclude } from '@shared/models' 12import { HttpStatusCode, UserRole, VideoInclude, VideoPrivacy } from '@shared/models'
13 13
14describe('Test video filters validators', function () { 14describe('Test video filters validators', function () {
15 let server: PeerTubeServer 15 let server: PeerTubeServer
@@ -112,7 +112,7 @@ describe('Test video filters validators', function () {
112 112
113 const validIncludes = [ 113 const validIncludes = [
114 VideoInclude.NONE, 114 VideoInclude.NONE,
115 VideoInclude.HIDDEN_PRIVACY, 115 VideoInclude.BLOCKED_OWNER,
116 VideoInclude.NOT_PUBLISHED_STATE | VideoInclude.BLACKLISTED 116 VideoInclude.NOT_PUBLISHED_STATE | VideoInclude.BLACKLISTED
117 ] 117 ]
118 118
@@ -120,6 +120,7 @@ describe('Test video filters validators', function () {
120 token?: string 120 token?: string
121 isLocal?: boolean 121 isLocal?: boolean
122 include?: VideoInclude 122 include?: VideoInclude
123 privacyOneOf?: VideoPrivacy[]
123 expectedStatus: HttpStatusCode 124 expectedStatus: HttpStatusCode
124 }) { 125 }) {
125 const paths = [ 126 const paths = [
@@ -136,6 +137,7 @@ describe('Test video filters validators', function () {
136 token: options.token || server.accessToken, 137 token: options.token || server.accessToken,
137 query: { 138 query: {
138 isLocal: options.isLocal, 139 isLocal: options.isLocal,
140 privacyOneOf: options.privacyOneOf,
139 include: options.include 141 include: options.include
140 }, 142 },
141 expectedStatus: options.expectedStatus 143 expectedStatus: options.expectedStatus
@@ -143,6 +145,22 @@ describe('Test video filters validators', function () {
143 } 145 }
144 } 146 }
145 147
148 it('Should fail with a bad privacyOneOf', async function () {
149 await testEndpoints({ privacyOneOf: [ 'toto' ] as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
150 })
151
152 it('Should succeed with a good privacyOneOf', async function () {
153 await testEndpoints({ privacyOneOf: [ VideoPrivacy.INTERNAL ], expectedStatus: HttpStatusCode.OK_200 })
154 })
155
156 it('Should fail to use privacyOneOf with a simple user', async function () {
157 await testEndpoints({
158 privacyOneOf: [ VideoPrivacy.INTERNAL ],
159 token: userAccessToken,
160 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
161 })
162 })
163
146 it('Should fail with a bad include', async function () { 164 it('Should fail with a bad include', async function () {
147 await testEndpoints({ include: 'toto' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 165 await testEndpoints({ include: 'toto' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
148 }) 166 })