aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/plugins')
-rw-r--r--server/tests/plugins/filter-hooks.ts88
1 files changed, 83 insertions, 5 deletions
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index 6c1fd40ba..41242318e 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -1,8 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers' 4import * as chai from 'chai'
5import { ServerConfig } from '@shared/models'
6import { 6import {
7 addVideoCommentReply, 7 addVideoCommentReply,
8 addVideoCommentThread, 8 addVideoCommentThread,
@@ -23,10 +23,10 @@ import {
23 uploadVideo, 23 uploadVideo,
24 waitJobs 24 waitJobs
25} from '../../../shared/extra-utils' 25} from '../../../shared/extra-utils'
26import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers'
27import { getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports'
28import { VideoDetails, VideoImport, VideoImportState, VideoPrivacy } from '../../../shared/models/videos'
26import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' 29import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model'
27import { VideoDetails } from '../../../shared/models/videos'
28import { getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports'
29import { ServerConfig } from '@shared/models'
30 30
31const expect = chai.expect 31const expect = chai.expect
32 32
@@ -87,6 +87,84 @@ describe('Test plugin filter hooks', function () {
87 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video with bad word' }, 403) 87 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video with bad word' }, 403)
88 }) 88 })
89 89
90 it('Should run filter:api.video.pre-import-url.accept.result', async function () {
91 const baseAttributes = {
92 name: 'normal title',
93 privacy: VideoPrivacy.PUBLIC,
94 channelId: servers[0].videoChannel.id,
95 targetUrl: getYoutubeVideoUrl() + 'bad'
96 }
97 await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, 403)
98 })
99
100 it('Should run filter:api.video.pre-import-torrent.accept.result', async function () {
101 const baseAttributes = {
102 name: 'bad torrent',
103 privacy: VideoPrivacy.PUBLIC,
104 channelId: servers[0].videoChannel.id,
105 torrentfile: 'video-720p.torrent' as any
106 }
107 await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, 403)
108 })
109
110 it('Should run filter:api.video.post-import-url.accept.result', async function () {
111 this.timeout(60000)
112
113 let videoImportId: number
114
115 {
116 const baseAttributes = {
117 name: 'title with bad word',
118 privacy: VideoPrivacy.PUBLIC,
119 channelId: servers[0].videoChannel.id,
120 targetUrl: getYoutubeVideoUrl()
121 }
122 const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes)
123 videoImportId = res.body.id
124 }
125
126 await waitJobs(servers)
127
128 {
129 const res = await getMyVideoImports(servers[0].url, servers[0].accessToken)
130 const videoImports = res.body.data as VideoImport[]
131
132 const videoImport = videoImports.find(i => i.id === videoImportId)
133
134 expect(videoImport.state.id).to.equal(VideoImportState.REJECTED)
135 expect(videoImport.state.label).to.equal('Rejected')
136 }
137 })
138
139 it('Should run filter:api.video.post-import-torrent.accept.result', async function () {
140 this.timeout(60000)
141
142 let videoImportId: number
143
144 {
145 const baseAttributes = {
146 name: 'title with bad word',
147 privacy: VideoPrivacy.PUBLIC,
148 channelId: servers[0].videoChannel.id,
149 torrentfile: 'video-720p.torrent' as any
150 }
151 const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes)
152 videoImportId = res.body.id
153 }
154
155 await waitJobs(servers)
156
157 {
158 const res = await getMyVideoImports(servers[0].url, servers[0].accessToken)
159 const videoImports = res.body.data as VideoImport[]
160
161 const videoImport = videoImports.find(i => i.id === videoImportId)
162
163 expect(videoImport.state.id).to.equal(VideoImportState.REJECTED)
164 expect(videoImport.state.label).to.equal('Rejected')
165 }
166 })
167
90 it('Should run filter:api.video-thread.create.accept.result', async function () { 168 it('Should run filter:api.video-thread.create.accept.result', async function () {
91 await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'comment with bad word', 403) 169 await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'comment with bad word', 403)
92 }) 170 })