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/api/check-params | |
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/api/check-params')
-rw-r--r-- | server/tests/api/check-params/config.ts | 19 | ||||
-rw-r--r-- | server/tests/api/check-params/users.ts | 6 |
2 files changed, 21 insertions, 4 deletions
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 | |||
6 | 6 | ||
7 | import { | 7 | import { |
8 | createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, runServer, ServerInfo, | 8 | createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, runServer, ServerInfo, |
9 | setAccessTokensToServers, userLogin | 9 | setAccessTokensToServers, userLogin, immutableAssign |
10 | } from '../../utils' | 10 | } from '../../utils' |
11 | 11 | ||
12 | describe('Test config API validators', function () { | 12 | describe('Test config API validators', function () { |
@@ -20,6 +20,7 @@ describe('Test config API validators', function () { | |||
20 | description: 'my super description', | 20 | description: 'my super description', |
21 | terms: 'my super terms', | 21 | terms: 'my super terms', |
22 | defaultClientRoute: '/videos/recently-added', | 22 | defaultClientRoute: '/videos/recently-added', |
23 | defaultNSFWPolicy: 'blur', | ||
23 | customizations: { | 24 | customizations: { |
24 | javascript: 'alert("coucou")', | 25 | javascript: 'alert("coucou")', |
25 | css: 'body { background-color: red; }' | 26 | css: 'body { background-color: red; }' |
@@ -122,6 +123,22 @@ describe('Test config API validators', function () { | |||
122 | }) | 123 | }) |
123 | }) | 124 | }) |
124 | 125 | ||
126 | it('Should fail with a bad default NSFW policy', async function () { | ||
127 | const newUpdateParams = immutableAssign(updateParams, { | ||
128 | instance: { | ||
129 | defaultNSFWPolicy: 'hello' | ||
130 | } | ||
131 | }) | ||
132 | |||
133 | await makePutBodyRequest({ | ||
134 | url: server.url, | ||
135 | path, | ||
136 | fields: newUpdateParams, | ||
137 | token: server.accessToken, | ||
138 | statusCodeExpected: 400 | ||
139 | }) | ||
140 | }) | ||
141 | |||
125 | it('Should success with the correct parameters', async function () { | 142 | it('Should success with the correct parameters', async function () { |
126 | await makePutBodyRequest({ | 143 | await makePutBodyRequest({ |
127 | url: server.url, | 144 | 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 () { | |||
231 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | 231 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) |
232 | }) | 232 | }) |
233 | 233 | ||
234 | it('Should fail with an invalid display NSFW attribute', async function () { | 234 | it('Should fail with an invalid NSFW policy attribute', async function () { |
235 | const fields = { | 235 | const fields = { |
236 | displayNSFW: -1 | 236 | nsfwPolicy: 'hello' |
237 | } | 237 | } |
238 | 238 | ||
239 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) | 239 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields }) |
@@ -266,7 +266,7 @@ describe('Test users API validators', function () { | |||
266 | it('Should succeed with the correct params', async function () { | 266 | it('Should succeed with the correct params', async function () { |
267 | const fields = { | 267 | const fields = { |
268 | password: 'my super password', | 268 | password: 'my super password', |
269 | displayNSFW: true, | 269 | nsfwPolicy: 'blur', |
270 | autoPlayVideo: false, | 270 | autoPlayVideo: false, |
271 | email: 'super_email@example.com' | 271 | email: 'super_email@example.com' |
272 | } | 272 | } |