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/api/check-params/config.ts | 19 ++++++++++++++++++- server/tests/api/check-params/users.ts | 6 +++--- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'server/tests/api/check-params') diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 3fe517fad..58b780f38 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts @@ -6,7 +6,7 @@ import { CustomConfig } from '../../../../shared/models/server/custom-config.mod import { createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, runServer, ServerInfo, - setAccessTokensToServers, userLogin + setAccessTokensToServers, userLogin, immutableAssign } from '../../utils' describe('Test config API validators', function () { @@ -20,6 +20,7 @@ describe('Test config API validators', function () { description: 'my super description', terms: 'my super terms', defaultClientRoute: '/videos/recently-added', + defaultNSFWPolicy: 'blur', customizations: { javascript: 'alert("coucou")', css: 'body { background-color: red; }' @@ -122,6 +123,22 @@ describe('Test config API validators', function () { }) }) + it('Should fail with a bad default NSFW policy', async function () { + const newUpdateParams = immutableAssign(updateParams, { + instance: { + defaultNSFWPolicy: 'hello' + } + }) + + await makePutBodyRequest({ + url: server.url, + path, + fields: newUpdateParams, + token: server.accessToken, + statusCodeExpected: 400 + }) + }) + it('Should success with the correct parameters', async function () { await makePutBodyRequest({ url: server.url, diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index a3e415b94..e8a6ffd19 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -231,9 +231,9 @@ describe('Test users API validators', function () { await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) }) - it('Should fail with an invalid display NSFW attribute', async function () { + it('Should fail with an invalid NSFW policy attribute', async function () { const fields = { - displayNSFW: -1 + nsfwPolicy: 'hello' } await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) @@ -266,7 +266,7 @@ describe('Test users API validators', function () { it('Should succeed with the correct params', async function () { const fields = { password: 'my super password', - displayNSFW: true, + nsfwPolicy: 'blur', autoPlayVideo: false, email: 'super_email@example.com' } -- cgit v1.2.3