diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-19 11:01:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-19 11:01:34 +0200 |
commit | 0883b3245bf0deb9106c4041e9afbd3521b79280 (patch) | |
tree | fcb73005e0b31a3b763ee5d22d5fc39c2da89907 /server/tests/utils | |
parent | 04ed10b21e8e1339514faae0bb690e4d97c23b0a (diff) | |
download | PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.tar.gz PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.tar.zst PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.zip |
Add ability to choose what policy we have for NSFW videos
There is a global instance setting and a per user setting
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/users/users.ts | 5 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 26 |
2 files changed, 29 insertions, 2 deletions
diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts index daf731a14..fc6b26c50 100644 --- a/server/tests/utils/users/users.ts +++ b/server/tests/utils/users/users.ts | |||
@@ -3,6 +3,7 @@ import * as request from 'supertest' | |||
3 | import { makePostBodyRequest, makeUploadRequest, makePutBodyRequest } from '../' | 3 | import { makePostBodyRequest, makeUploadRequest, makePutBodyRequest } from '../' |
4 | 4 | ||
5 | import { UserRole } from '../../../../shared/index' | 5 | import { UserRole } from '../../../../shared/index' |
6 | import { NSFWPolicyType } from '../../../../shared/models/videos/nsfw-policy.type' | ||
6 | 7 | ||
7 | function createUser ( | 8 | function createUser ( |
8 | url: string, | 9 | url: string, |
@@ -128,7 +129,7 @@ function updateMyUser (options: { | |||
128 | url: string | 129 | url: string |
129 | accessToken: string, | 130 | accessToken: string, |
130 | newPassword?: string, | 131 | newPassword?: string, |
131 | displayNSFW?: boolean, | 132 | nsfwPolicy?: NSFWPolicyType, |
132 | email?: string, | 133 | email?: string, |
133 | autoPlayVideo?: boolean | 134 | autoPlayVideo?: boolean |
134 | description?: string | 135 | description?: string |
@@ -137,7 +138,7 @@ function updateMyUser (options: { | |||
137 | 138 | ||
138 | const toSend = {} | 139 | const toSend = {} |
139 | if (options.newPassword !== undefined && options.newPassword !== null) toSend['password'] = options.newPassword | 140 | if (options.newPassword !== undefined && options.newPassword !== null) toSend['password'] = options.newPassword |
140 | if (options.displayNSFW !== undefined && options.displayNSFW !== null) toSend['displayNSFW'] = options.displayNSFW | 141 | if (options.nsfwPolicy !== undefined && options.nsfwPolicy !== null) toSend['nsfwPolicy'] = options.nsfwPolicy |
141 | if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo | 142 | if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo |
142 | if (options.email !== undefined && options.email !== null) toSend['email'] = options.email | 143 | if (options.email !== undefined && options.email !== null) toSend['email'] = options.email |
143 | if (options.description !== undefined && options.description !== null) toSend['description'] = options.description | 144 | if (options.description !== undefined && options.description !== null) toSend['description'] = options.description |
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 01e7fa5a1..df9071c29 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -128,6 +128,18 @@ function getVideosList (url: string) { | |||
128 | .expect('Content-Type', /json/) | 128 | .expect('Content-Type', /json/) |
129 | } | 129 | } |
130 | 130 | ||
131 | function getVideosListWithToken (url: string, token: string) { | ||
132 | const path = '/api/v1/videos' | ||
133 | |||
134 | return request(url) | ||
135 | .get(path) | ||
136 | .set('Authorization', 'Bearer ' + token) | ||
137 | .query({ sort: 'name' }) | ||
138 | .set('Accept', 'application/json') | ||
139 | .expect(200) | ||
140 | .expect('Content-Type', /json/) | ||
141 | } | ||
142 | |||
131 | function getLocalVideos (url: string) { | 143 | function getLocalVideos (url: string) { |
132 | const path = '/api/v1/videos' | 144 | const path = '/api/v1/videos' |
133 | 145 | ||
@@ -202,6 +214,18 @@ function searchVideo (url: string, search: string) { | |||
202 | .expect('Content-Type', /json/) | 214 | .expect('Content-Type', /json/) |
203 | } | 215 | } |
204 | 216 | ||
217 | function searchVideoWithToken (url: string, search: string, token: string) { | ||
218 | const path = '/api/v1/videos' | ||
219 | const req = request(url) | ||
220 | .get(path + '/search') | ||
221 | .set('Authorization', 'Bearer ' + token) | ||
222 | .query({ search }) | ||
223 | .set('Accept', 'application/json') | ||
224 | |||
225 | return req.expect(200) | ||
226 | .expect('Content-Type', /json/) | ||
227 | } | ||
228 | |||
205 | function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) { | 229 | function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) { |
206 | const path = '/api/v1/videos' | 230 | const path = '/api/v1/videos' |
207 | 231 | ||
@@ -490,6 +514,7 @@ export { | |||
490 | getVideoPrivacies, | 514 | getVideoPrivacies, |
491 | getVideoLanguages, | 515 | getVideoLanguages, |
492 | getMyVideos, | 516 | getMyVideos, |
517 | searchVideoWithToken, | ||
493 | getVideo, | 518 | getVideo, |
494 | getVideoWithToken, | 519 | getVideoWithToken, |
495 | getVideosList, | 520 | getVideosList, |
@@ -499,6 +524,7 @@ export { | |||
499 | searchVideo, | 524 | searchVideo, |
500 | searchVideoWithPagination, | 525 | searchVideoWithPagination, |
501 | searchVideoWithSort, | 526 | searchVideoWithSort, |
527 | getVideosListWithToken, | ||
502 | uploadVideo, | 528 | uploadVideo, |
503 | updateVideo, | 529 | updateVideo, |
504 | rateVideo, | 530 | rateVideo, |