diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-20 15:32:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-04-20 15:42:27 +0200 |
commit | b3af2601da92a6c0835cb2473b4c7a41a0d86e98 (patch) | |
tree | a20984ec2df1c22f235d03909177629892721c54 /server/tests | |
parent | 8c7725dc3c01a73bf56a48c8b192d144bfdc3ffe (diff) | |
download | PeerTube-b3af2601da92a6c0835cb2473b4c7a41a0d86e98.tar.gz PeerTube-b3af2601da92a6c0835cb2473b4c7a41a0d86e98.tar.zst PeerTube-b3af2601da92a6c0835cb2473b4c7a41a0d86e98.zip |
Add ability to remove privacies using plugins
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test-three/main.js | 7 | ||||
-rw-r--r-- | server/tests/plugins/video-constants.ts | 55 |
2 files changed, 58 insertions, 4 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test-three/main.js b/server/tests/fixtures/peertube-plugin-test-three/main.js index 4945feb55..f2b89bcf0 100644 --- a/server/tests/fixtures/peertube-plugin-test-three/main.js +++ b/server/tests/fixtures/peertube-plugin-test-three/main.js | |||
@@ -5,7 +5,9 @@ async function register ({ | |||
5 | storageManager, | 5 | storageManager, |
6 | videoCategoryManager, | 6 | videoCategoryManager, |
7 | videoLicenceManager, | 7 | videoLicenceManager, |
8 | videoLanguageManager | 8 | videoLanguageManager, |
9 | videoPrivacyManager, | ||
10 | playlistPrivacyManager | ||
9 | }) { | 11 | }) { |
10 | videoLanguageManager.addLanguage('al_bhed', 'Al Bhed') | 12 | videoLanguageManager.addLanguage('al_bhed', 'Al Bhed') |
11 | videoLanguageManager.addLanguage('al_bhed2', 'Al Bhed 2') | 13 | videoLanguageManager.addLanguage('al_bhed2', 'Al Bhed 2') |
@@ -21,6 +23,9 @@ async function register ({ | |||
21 | videoLicenceManager.addLicence(43, 'High best licence') | 23 | videoLicenceManager.addLicence(43, 'High best licence') |
22 | videoLicenceManager.deleteLicence(1) // Attribution | 24 | videoLicenceManager.deleteLicence(1) // Attribution |
23 | videoLicenceManager.deleteLicence(7) // Public domain | 25 | videoLicenceManager.deleteLicence(7) // Public domain |
26 | |||
27 | videoPrivacyManager.deletePrivacy(2) | ||
28 | playlistPrivacyManager.deletePlaylistPrivacy(3) | ||
24 | } | 29 | } |
25 | 30 | ||
26 | async function unregister () { | 31 | async function unregister () { |
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts index 5374b5ecc..fec9196e2 100644 --- a/server/tests/plugins/video-constants.ts +++ b/server/tests/plugins/video-constants.ts | |||
@@ -4,17 +4,18 @@ import * as chai from 'chai' | |||
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' | 5 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' |
6 | import { | 6 | import { |
7 | createVideoPlaylist, | ||
7 | getPluginTestPath, | 8 | getPluginTestPath, |
8 | getVideo, | 9 | getVideo, |
9 | getVideoCategories, | 10 | getVideoCategories, |
10 | getVideoLanguages, | 11 | getVideoLanguages, |
11 | getVideoLicences, | 12 | getVideoLicences, getVideoPlaylistPrivacies, getVideoPrivacies, |
12 | installPlugin, | 13 | installPlugin, |
13 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
14 | uninstallPlugin, | 15 | uninstallPlugin, |
15 | uploadVideo | 16 | uploadVideo |
16 | } from '../../../shared/extra-utils' | 17 | } from '../../../shared/extra-utils' |
17 | import { VideoDetails } from '../../../shared/models/videos' | 18 | import { VideoDetails, VideoPlaylistPrivacy } from '../../../shared/models/videos' |
18 | 19 | ||
19 | const expect = chai.expect | 20 | const expect = chai.expect |
20 | 21 | ||
@@ -67,6 +68,35 @@ describe('Test plugin altering video constants', function () { | |||
67 | expect(licences[43]).to.equal('High best licence') | 68 | expect(licences[43]).to.equal('High best licence') |
68 | }) | 69 | }) |
69 | 70 | ||
71 | it('Should have updated video privacies', async function () { | ||
72 | const res = await getVideoPrivacies(server.url) | ||
73 | const privacies = res.body | ||
74 | |||
75 | expect(privacies[1]).to.exist | ||
76 | expect(privacies[2]).to.not.exist | ||
77 | expect(privacies[3]).to.exist | ||
78 | expect(privacies[4]).to.exist | ||
79 | }) | ||
80 | |||
81 | it('Should have updated playlist privacies', async function () { | ||
82 | const res = await getVideoPlaylistPrivacies(server.url) | ||
83 | const playlistPrivacies = res.body | ||
84 | |||
85 | expect(playlistPrivacies[1]).to.exist | ||
86 | expect(playlistPrivacies[2]).to.exist | ||
87 | expect(playlistPrivacies[3]).to.not.exist | ||
88 | }) | ||
89 | |||
90 | it('Should not be able to create a video with this privacy', async function () { | ||
91 | const attrs = { name: 'video', privacy: 2 } | ||
92 | await uploadVideo(server.url, server.accessToken, attrs, 400) | ||
93 | }) | ||
94 | |||
95 | it('Should not be able to create a video with this privacy', async function () { | ||
96 | const attrs = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE } | ||
97 | await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attrs, expectedStatus: 400 }) | ||
98 | }) | ||
99 | |||
70 | it('Should be able to upload a video with these values', async function () { | 100 | it('Should be able to upload a video with these values', async function () { |
71 | const attrs = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' } | 101 | const attrs = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' } |
72 | const resUpload = await uploadVideo(server.url, server.accessToken, attrs) | 102 | const resUpload = await uploadVideo(server.url, server.accessToken, attrs) |
@@ -79,7 +109,7 @@ describe('Test plugin altering video constants', function () { | |||
79 | expect(video.category.label).to.equal('Best category') | 109 | expect(video.category.label).to.equal('Best category') |
80 | }) | 110 | }) |
81 | 111 | ||
82 | it('Should uninstall the plugin and reset languages, categories and licences', async function () { | 112 | it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () { |
83 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-three' }) | 113 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-test-three' }) |
84 | 114 | ||
85 | { | 115 | { |
@@ -114,6 +144,25 @@ describe('Test plugin altering video constants', function () { | |||
114 | expect(licences[42]).to.not.exist | 144 | expect(licences[42]).to.not.exist |
115 | expect(licences[43]).to.not.exist | 145 | expect(licences[43]).to.not.exist |
116 | } | 146 | } |
147 | |||
148 | { | ||
149 | const res = await getVideoPrivacies(server.url) | ||
150 | const privacies = res.body | ||
151 | |||
152 | expect(privacies[1]).to.exist | ||
153 | expect(privacies[2]).to.exist | ||
154 | expect(privacies[3]).to.exist | ||
155 | expect(privacies[4]).to.exist | ||
156 | } | ||
157 | |||
158 | { | ||
159 | const res = await getVideoPlaylistPrivacies(server.url) | ||
160 | const playlistPrivacies = res.body | ||
161 | |||
162 | expect(playlistPrivacies[1]).to.exist | ||
163 | expect(playlistPrivacies[2]).to.exist | ||
164 | expect(playlistPrivacies[3]).to.exist | ||
165 | } | ||
117 | }) | 166 | }) |
118 | 167 | ||
119 | after(async function () { | 168 | after(async function () { |