From 0883b3245bf0deb9106c4041e9afbd3521b79280 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Apr 2018 11:01:34 +0200 Subject: Add ability to choose what policy we have for NSFW videos There is a global instance setting and a per user setting --- server/tests/utils/users/users.ts | 5 +++-- server/tests/utils/videos/videos.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'server/tests/utils') 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' import { makePostBodyRequest, makeUploadRequest, makePutBodyRequest } from '../' import { UserRole } from '../../../../shared/index' +import { NSFWPolicyType } from '../../../../shared/models/videos/nsfw-policy.type' function createUser ( url: string, @@ -128,7 +129,7 @@ function updateMyUser (options: { url: string accessToken: string, newPassword?: string, - displayNSFW?: boolean, + nsfwPolicy?: NSFWPolicyType, email?: string, autoPlayVideo?: boolean description?: string @@ -137,7 +138,7 @@ function updateMyUser (options: { const toSend = {} if (options.newPassword !== undefined && options.newPassword !== null) toSend['password'] = options.newPassword - if (options.displayNSFW !== undefined && options.displayNSFW !== null) toSend['displayNSFW'] = options.displayNSFW + if (options.nsfwPolicy !== undefined && options.nsfwPolicy !== null) toSend['nsfwPolicy'] = options.nsfwPolicy if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo if (options.email !== undefined && options.email !== null) toSend['email'] = options.email 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) { .expect('Content-Type', /json/) } +function getVideosListWithToken (url: string, token: string) { + const path = '/api/v1/videos' + + return request(url) + .get(path) + .set('Authorization', 'Bearer ' + token) + .query({ sort: 'name' }) + .set('Accept', 'application/json') + .expect(200) + .expect('Content-Type', /json/) +} + function getLocalVideos (url: string) { const path = '/api/v1/videos' @@ -202,6 +214,18 @@ function searchVideo (url: string, search: string) { .expect('Content-Type', /json/) } +function searchVideoWithToken (url: string, search: string, token: string) { + const path = '/api/v1/videos' + const req = request(url) + .get(path + '/search') + .set('Authorization', 'Bearer ' + token) + .query({ search }) + .set('Accept', 'application/json') + + return req.expect(200) + .expect('Content-Type', /json/) +} + function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) { const path = '/api/v1/videos' @@ -490,6 +514,7 @@ export { getVideoPrivacies, getVideoLanguages, getMyVideos, + searchVideoWithToken, getVideo, getVideoWithToken, getVideosList, @@ -499,6 +524,7 @@ export { searchVideo, searchVideoWithPagination, searchVideoWithSort, + getVideosListWithToken, uploadVideo, updateVideo, rateVideo, -- cgit v1.2.3