From b379759f55a35837b803a3b988674972db2903d1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Jan 2023 09:28:29 +0100 Subject: Add signup approval API tests --- shared/server-commands/server/config-command.ts | 50 +++++++++++++++++++++---- shared/server-commands/server/server.ts | 3 ++ 2 files changed, 46 insertions(+), 7 deletions(-) (limited to 'shared/server-commands/server') diff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.ts index 1c2315ed1..51267b85b 100644 --- a/shared/server-commands/server/config-command.ts +++ b/shared/server-commands/server/config-command.ts @@ -18,6 +18,33 @@ export class ConfigCommand extends AbstractCommand { } } + // --------------------------------------------------------------------------- + + static getEmailOverrideConfig (emailPort: number) { + return { + smtp: { + hostname: '127.0.0.1', + port: emailPort + } + } + } + + // --------------------------------------------------------------------------- + + enableSignup (requiresApproval: boolean) { + return this.updateExistingSubConfig({ + newConfig: { + signup: { + enabled: true, + requiresApproval, + limit: -1 + } + } + }) + } + + // --------------------------------------------------------------------------- + disableImports () { return this.setImportsEnabled(false) } @@ -44,6 +71,16 @@ export class ConfigCommand extends AbstractCommand { }) } + // --------------------------------------------------------------------------- + + enableChannelSync () { + return this.setChannelSyncEnabled(true) + } + + disableChannelSync () { + return this.setChannelSyncEnabled(false) + } + private setChannelSyncEnabled (enabled: boolean) { return this.updateExistingSubConfig({ newConfig: { @@ -56,13 +93,7 @@ export class ConfigCommand extends AbstractCommand { }) } - enableChannelSync () { - return this.setChannelSyncEnabled(true) - } - - disableChannelSync () { - return this.setChannelSyncEnabled(false) - } + // --------------------------------------------------------------------------- enableLive (options: { allowReplay?: boolean @@ -142,6 +173,8 @@ export class ConfigCommand extends AbstractCommand { }) } + // --------------------------------------------------------------------------- + enableStudio () { return this.updateExistingSubConfig({ newConfig: { @@ -152,6 +185,8 @@ export class ConfigCommand extends AbstractCommand { }) } + // --------------------------------------------------------------------------- + getConfig (options: OverrideCommandOptions = {}) { const path = '/api/v1/config' @@ -304,6 +339,7 @@ export class ConfigCommand extends AbstractCommand { signup: { enabled: false, limit: 5, + requiresApproval: true, requiresEmailVerification: false, minimumAge: 16 }, diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts index ae1395a74..793fae3a8 100644 --- a/shared/server-commands/server/server.ts +++ b/shared/server-commands/server/server.ts @@ -18,6 +18,7 @@ import { BlocklistCommand, LoginCommand, NotificationsCommand, + RegistrationsCommand, SubscriptionsCommand, TwoFactorCommand, UsersCommand @@ -147,6 +148,7 @@ export class PeerTubeServer { views?: ViewsCommand twoFactor?: TwoFactorCommand videoToken?: VideoTokenCommand + registrations?: RegistrationsCommand constructor (options: { serverNumber: number } | { url: string }) { if ((options as any).url) { @@ -430,5 +432,6 @@ export class PeerTubeServer { this.views = new ViewsCommand(this) this.twoFactor = new TwoFactorCommand(this) this.videoToken = new VideoTokenCommand(this) + this.registrations = new RegistrationsCommand(this) } } -- cgit v1.2.3