diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-12 14:19:56 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-12 14:23:22 +0100 |
commit | 527a52ac4295a072927ff46761766a8b181a7603 (patch) | |
tree | 632f66b1691d8d72f04630671af8bdf1655d6b00 /server/tests/api | |
parent | 8f2608e9a9d54c87ace636f99cdb9d2a7730990f (diff) | |
download | PeerTube-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')
-rw-r--r-- | server/tests/api/check-params/videos-common-filters.ts | 22 | ||||
-rw-r--r-- | server/tests/api/videos/videos-common-filters.ts | 8 |
2 files changed, 25 insertions, 5 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' |
12 | import { HttpStatusCode, UserRole, VideoInclude } from '@shared/models' | 12 | import { HttpStatusCode, UserRole, VideoInclude, VideoPrivacy } from '@shared/models' |
13 | 13 | ||
14 | describe('Test video filters validators', function () { | 14 | describe('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 | }) |
diff --git a/server/tests/api/videos/videos-common-filters.ts b/server/tests/api/videos/videos-common-filters.ts index 4f22d4ac3..ca5f42173 100644 --- a/server/tests/api/videos/videos-common-filters.ts +++ b/server/tests/api/videos/videos-common-filters.ts | |||
@@ -138,6 +138,7 @@ describe('Test videos filter', function () { | |||
138 | hasWebtorrentFiles?: boolean | 138 | hasWebtorrentFiles?: boolean |
139 | hasHLSFiles?: boolean | 139 | hasHLSFiles?: boolean |
140 | include?: VideoInclude | 140 | include?: VideoInclude |
141 | privacyOneOf?: VideoPrivacy[] | ||
141 | category?: number | 142 | category?: number |
142 | tagsAllOf?: string[] | 143 | tagsAllOf?: string[] |
143 | token?: string | 144 | token?: string |
@@ -148,7 +149,7 @@ describe('Test videos filter', function () { | |||
148 | path: options.path, | 149 | path: options.path, |
149 | token: options.token ?? options.server.accessToken, | 150 | token: options.token ?? options.server.accessToken, |
150 | query: { | 151 | query: { |
151 | ...pick(options, [ 'isLocal', 'include', 'category', 'tagsAllOf', 'hasWebtorrentFiles', 'hasHLSFiles' ]), | 152 | ...pick(options, [ 'isLocal', 'include', 'category', 'tagsAllOf', 'hasWebtorrentFiles', 'hasHLSFiles', 'privacyOneOf' ]), |
152 | 153 | ||
153 | sort: 'createdAt' | 154 | sort: 'createdAt' |
154 | }, | 155 | }, |
@@ -162,6 +163,7 @@ describe('Test videos filter', function () { | |||
162 | server: PeerTubeServer | 163 | server: PeerTubeServer |
163 | isLocal?: boolean | 164 | isLocal?: boolean |
164 | include?: VideoInclude | 165 | include?: VideoInclude |
166 | privacyOneOf?: VideoPrivacy[] | ||
165 | token?: string | 167 | token?: string |
166 | expectedStatus?: HttpStatusCode | 168 | expectedStatus?: HttpStatusCode |
167 | }) { | 169 | }) { |
@@ -195,7 +197,7 @@ describe('Test videos filter', function () { | |||
195 | server, | 197 | server, |
196 | token, | 198 | token, |
197 | isLocal: true, | 199 | isLocal: true, |
198 | include: VideoInclude.HIDDEN_PRIVACY | 200 | privacyOneOf: [ VideoPrivacy.UNLISTED, VideoPrivacy.PUBLIC, VideoPrivacy.PRIVATE ] |
199 | }) | 201 | }) |
200 | 202 | ||
201 | for (const names of namesResults) { | 203 | for (const names of namesResults) { |
@@ -216,7 +218,7 @@ describe('Test videos filter', function () { | |||
216 | const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames({ | 218 | const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames({ |
217 | server, | 219 | server, |
218 | token, | 220 | token, |
219 | include: VideoInclude.HIDDEN_PRIVACY | 221 | privacyOneOf: [ VideoPrivacy.UNLISTED, VideoPrivacy.PUBLIC, VideoPrivacy.PRIVATE ] |
220 | }) | 222 | }) |
221 | 223 | ||
222 | expect(channelVideos).to.have.lengthOf(3) | 224 | expect(channelVideos).to.have.lengthOf(3) |