From 4ce7eb71ba28a563336c07d10c182ff89461c72b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 25 Oct 2019 13:54:32 +0200 Subject: Add plugin hook on registration --- server/tests/plugins/filter-hooks.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'server/tests/plugins/filter-hooks.ts') diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index ec0679b04..b2436fb9e 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -28,11 +28,12 @@ import { getVideoWithToken, setDefaultVideoChannel, waitJobs, - doubleFollow + doubleFollow, getConfig, registerUser } 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 @@ -187,6 +188,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) }) -- cgit v1.2.3