]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/filter-hooks.ts
Fix CLI build
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / filter-hooks.ts
index ec0679b04f3d1d8f607ea89610d4fa7f85e6e659..6c1fd40ba7d160afe74120dbc4c6970e98fd735a 100644 (file)
@@ -1,38 +1,32 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import * as chai from 'chai'
 import 'mocha'
-import {
-  cleanupTests,
-  flushAndRunMultipleServers,
-  flushAndRunServer, killallServers, reRunServer,
-  ServerInfo,
-  waitUntilLog
-} from '../../../shared/extra-utils/server/servers'
+import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers'
 import {
   addVideoCommentReply,
   addVideoCommentThread,
-  deleteVideoComment,
+  doubleFollow,
+  getConfig,
   getPluginTestPath,
-  getVideosList,
-  installPlugin,
-  removeVideo,
-  setAccessTokensToServers,
-  updateVideo,
-  uploadVideo,
-  viewVideo,
-  getVideosListPagination,
   getVideo,
   getVideoCommentThreads,
+  getVideosList,
+  getVideosListPagination,
   getVideoThreadComments,
   getVideoWithToken,
+  installPlugin,
+  registerUser,
+  setAccessTokensToServers,
   setDefaultVideoChannel,
-  waitJobs,
-  doubleFollow
+  updateVideo,
+  uploadVideo,
+  waitJobs
 } from '../../../shared/extra-utils'
 import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model'
 import { VideoDetails } from '../../../shared/models/videos'
 import { getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports'
+import { ServerConfig } from '@shared/models'
 
 const expect = chai.expect
 
@@ -139,11 +133,13 @@ describe('Test plugin filter hooks', function () {
     }
 
     it('Should blacklist on upload', async function () {
-      const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video please blacklist me' })
+      const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video please blacklist me' })
       await checkIsBlacklisted(res, true)
     })
 
     it('Should blacklist on import', async function () {
+      this.timeout(15000)
+
       const attributes = {
         name: 'video please blacklist me',
         targetUrl: getYoutubeVideoUrl(),
@@ -154,18 +150,18 @@ describe('Test plugin filter hooks', function () {
     })
 
     it('Should blacklist on update', async function () {
-      const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video' })
+      const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' })
       const videoId = res.body.video.uuid
       await checkIsBlacklisted(res, false)
 
-      await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoId, { name: 'please blacklist me' })
+      await updateVideo(servers[0].url, servers[0].accessToken, videoId, { name: 'please blacklist me' })
       await checkIsBlacklisted(res, true)
     })
 
     it('Should blacklist on remote upload', async function () {
       this.timeout(45000)
 
-      const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'remote please blacklist me' })
+      const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'remote please blacklist me' })
       await waitJobs(servers)
 
       await checkIsBlacklisted(res, true)
@@ -174,7 +170,7 @@ describe('Test plugin filter hooks', function () {
     it('Should blacklist on remote update', async function () {
       this.timeout(45000)
 
-      const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video' })
+      const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video' })
       await waitJobs(servers)
 
       const videoId = res.body.video.uuid
@@ -187,6 +183,24 @@ describe('Test plugin filter hooks', function () {
     })
   })
 
+  describe('Should run filter:api.user.signup.allowed.result', function () {
+
+    it('Should run on config endpoint', async function () {
+      const res = await getConfig(servers[0].url)
+      expect((res.body as ServerConfig).signup.allowed).to.be.true
+    })
+
+    it('Should allow a signup', async function () {
+      await registerUser(servers[0].url, 'john', 'password')
+    })
+
+    it('Should not allow a signup', async function () {
+      const res = await registerUser(servers[0].url, 'jma', 'password', 403)
+
+      expect(res.body.error).to.equal('No jma')
+    })
+  })
+
   after(async function () {
     await cleanupTests(servers)
   })