mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00
refactor(config): extract note config from app config
This commit separates the app config object from a new note config object. This was done to separate different concerns in different config files. Especially if the number of settings that are about notes increase, it is a good idea to keep them separate from the app config. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
baa6606729
commit
f4a580cf2a
30 changed files with 161 additions and 78 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,7 @@ import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../authors/author.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../../../config/mock/note.config.mock';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { GroupsModule } from '../../../groups/groups.module';
|
import { GroupsModule } from '../../../groups/groups.module';
|
||||||
import { HistoryEntry } from '../../../history/history-entry.entity';
|
import { HistoryEntry } from '../../../history/history-entry.entity';
|
||||||
|
@ -75,7 +76,7 @@ describe('AliasController', () => {
|
||||||
MediaModule,
|
MediaModule,
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock, mediaConfigMock],
|
load: [appConfigMock, noteConfigMock, mediaConfigMock],
|
||||||
}),
|
}),
|
||||||
TypeOrmModule.forRoot(),
|
TypeOrmModule.forRoot(),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@ import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import authConfigMock from '../../../config/mock/auth.config.mock';
|
import authConfigMock from '../../../config/mock/auth.config.mock';
|
||||||
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
||||||
import externalConfigMock from '../../../config/mock/external-services.config.mock';
|
import externalConfigMock from '../../../config/mock/external-services.config.mock';
|
||||||
|
import noteConfigMock from '../../../config/mock/note.config.mock';
|
||||||
import { FrontendConfigModule } from '../../../frontend-config/frontend-config.module';
|
import { FrontendConfigModule } from '../../../frontend-config/frontend-config.module';
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
import { ConfigController } from './config.controller';
|
import { ConfigController } from './config.controller';
|
||||||
|
@ -24,6 +25,7 @@ describe('ConfigController', () => {
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [
|
load: [
|
||||||
appConfigMock,
|
appConfigMock,
|
||||||
|
noteConfigMock,
|
||||||
authConfigMock,
|
authConfigMock,
|
||||||
customizationConfigMock,
|
customizationConfigMock,
|
||||||
externalConfigMock,
|
externalConfigMock,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +14,7 @@ import {
|
||||||
import { AuthToken } from '../../../../auth/auth-token.entity';
|
import { AuthToken } from '../../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../../authors/author.entity';
|
import { Author } from '../../../../authors/author.entity';
|
||||||
import appConfigMock from '../../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../../config/mock/app.config.mock';
|
||||||
|
import noteConfigMock from '../../../../config/mock/note.config.mock';
|
||||||
import { Group } from '../../../../groups/group.entity';
|
import { Group } from '../../../../groups/group.entity';
|
||||||
import { HistoryEntry } from '../../../../history/history-entry.entity';
|
import { HistoryEntry } from '../../../../history/history-entry.entity';
|
||||||
import { HistoryModule } from '../../../../history/history.module';
|
import { HistoryModule } from '../../../../history/history.module';
|
||||||
|
@ -45,7 +46,7 @@ describe('HistoryController', () => {
|
||||||
LoggerModule,
|
LoggerModule,
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock],
|
load: [appConfigMock, noteConfigMock],
|
||||||
}),
|
}),
|
||||||
TypeOrmModule.forRoot(),
|
TypeOrmModule.forRoot(),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -13,6 +13,7 @@ import authConfigMock from '../../../config/mock/auth.config.mock';
|
||||||
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
||||||
import externalServicesConfigMock from '../../../config/mock/external-services.config.mock';
|
import externalServicesConfigMock from '../../../config/mock/external-services.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../../../config/mock/note.config.mock';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { Identity } from '../../../identity/identity.entity';
|
import { Identity } from '../../../identity/identity.entity';
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
|
@ -44,6 +45,7 @@ describe('MeController', () => {
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [
|
load: [
|
||||||
appConfigMock,
|
appConfigMock,
|
||||||
|
noteConfigMock,
|
||||||
authConfigMock,
|
authConfigMock,
|
||||||
mediaConfigMock,
|
mediaConfigMock,
|
||||||
customizationConfigMock,
|
customizationConfigMock,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +14,7 @@ import authConfigMock from '../../../config/mock/auth.config.mock';
|
||||||
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
import customizationConfigMock from '../../../config/mock/customization.config.mock';
|
||||||
import externalConfigMock from '../../../config/mock/external-services.config.mock';
|
import externalConfigMock from '../../../config/mock/external-services.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../../../config/mock/note.config.mock';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { Identity } from '../../../identity/identity.entity';
|
import { Identity } from '../../../identity/identity.entity';
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
|
@ -45,6 +46,7 @@ describe('MediaController', () => {
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [
|
load: [
|
||||||
appConfigMock,
|
appConfigMock,
|
||||||
|
noteConfigMock,
|
||||||
mediaConfigMock,
|
mediaConfigMock,
|
||||||
authConfigMock,
|
authConfigMock,
|
||||||
customizationConfigMock,
|
customizationConfigMock,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,7 @@ import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../authors/author.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../../../config/mock/note.config.mock';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { GroupsModule } from '../../../groups/groups.module';
|
import { GroupsModule } from '../../../groups/groups.module';
|
||||||
import { HistoryEntry } from '../../../history/history-entry.entity';
|
import { HistoryEntry } from '../../../history/history-entry.entity';
|
||||||
|
@ -73,7 +74,7 @@ describe('NotesController', () => {
|
||||||
MediaModule,
|
MediaModule,
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock, mediaConfigMock],
|
load: [appConfigMock, noteConfigMock, mediaConfigMock],
|
||||||
}),
|
}),
|
||||||
TypeOrmModule.forRoot(),
|
TypeOrmModule.forRoot(),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,7 @@ import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../authors/author.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../../../config/mock/note.config.mock';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { GroupsModule } from '../../../groups/groups.module';
|
import { GroupsModule } from '../../../groups/groups.module';
|
||||||
import { HistoryEntry } from '../../../history/history-entry.entity';
|
import { HistoryEntry } from '../../../history/history-entry.entity';
|
||||||
|
@ -75,7 +76,7 @@ describe('AliasController', () => {
|
||||||
MediaModule,
|
MediaModule,
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock, mediaConfigMock],
|
load: [appConfigMock, noteConfigMock, mediaConfigMock],
|
||||||
}),
|
}),
|
||||||
TypeOrmModule.forRoot(),
|
TypeOrmModule.forRoot(),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,7 @@ import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../authors/author.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../../../config/mock/note.config.mock';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { HistoryEntry } from '../../../history/history-entry.entity';
|
import { HistoryEntry } from '../../../history/history-entry.entity';
|
||||||
import { HistoryModule } from '../../../history/history.module';
|
import { HistoryModule } from '../../../history/history.module';
|
||||||
|
@ -44,7 +45,7 @@ describe('Me Controller', () => {
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock, mediaConfigMock],
|
load: [appConfigMock, noteConfigMock, mediaConfigMock],
|
||||||
}),
|
}),
|
||||||
UsersModule,
|
UsersModule,
|
||||||
HistoryModule,
|
HistoryModule,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@ import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../authors/author.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../../../config/mock/note.config.mock';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { Identity } from '../../../identity/identity.entity';
|
import { Identity } from '../../../identity/identity.entity';
|
||||||
import { LoggerModule } from '../../../logger/logger.module';
|
import { LoggerModule } from '../../../logger/logger.module';
|
||||||
|
@ -37,7 +38,7 @@ describe('Media Controller', () => {
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock, mediaConfigMock],
|
load: [appConfigMock, noteConfigMock, mediaConfigMock],
|
||||||
}),
|
}),
|
||||||
LoggerModule,
|
LoggerModule,
|
||||||
MediaModule,
|
MediaModule,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,7 @@ import { AuthToken } from '../../../auth/auth-token.entity';
|
||||||
import { Author } from '../../../authors/author.entity';
|
import { Author } from '../../../authors/author.entity';
|
||||||
import appConfigMock from '../../../config/mock/app.config.mock';
|
import appConfigMock from '../../../config/mock/app.config.mock';
|
||||||
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
import mediaConfigMock from '../../../config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../../../config/mock/note.config.mock';
|
||||||
import { Group } from '../../../groups/group.entity';
|
import { Group } from '../../../groups/group.entity';
|
||||||
import { GroupsModule } from '../../../groups/groups.module';
|
import { GroupsModule } from '../../../groups/groups.module';
|
||||||
import { HistoryEntry } from '../../../history/history-entry.entity';
|
import { HistoryEntry } from '../../../history/history-entry.entity';
|
||||||
|
@ -73,7 +74,7 @@ describe('Notes Controller', () => {
|
||||||
MediaModule,
|
MediaModule,
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock, mediaConfigMock],
|
load: [appConfigMock, noteConfigMock, mediaConfigMock],
|
||||||
}),
|
}),
|
||||||
TypeOrmModule.forRoot(),
|
TypeOrmModule.forRoot(),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -21,6 +21,7 @@ import databaseConfig from './config/database.config';
|
||||||
import externalConfig from './config/external-services.config';
|
import externalConfig from './config/external-services.config';
|
||||||
import hstsConfig from './config/hsts.config';
|
import hstsConfig from './config/hsts.config';
|
||||||
import mediaConfig from './config/media.config';
|
import mediaConfig from './config/media.config';
|
||||||
|
import noteConfig from './config/note.config';
|
||||||
import { FrontendConfigModule } from './frontend-config/frontend-config.module';
|
import { FrontendConfigModule } from './frontend-config/frontend-config.module';
|
||||||
import { FrontendConfigService } from './frontend-config/frontend-config.service';
|
import { FrontendConfigService } from './frontend-config/frontend-config.service';
|
||||||
import { GroupsModule } from './groups/groups.module';
|
import { GroupsModule } from './groups/groups.module';
|
||||||
|
@ -57,6 +58,7 @@ const routes: Routes = [
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
load: [
|
load: [
|
||||||
appConfig,
|
appConfig,
|
||||||
|
noteConfig,
|
||||||
mediaConfig,
|
mediaConfig,
|
||||||
hstsConfig,
|
hstsConfig,
|
||||||
cspConfig,
|
cspConfig,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -7,15 +7,13 @@ import { registerAs } from '@nestjs/config';
|
||||||
import * as Joi from 'joi';
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
import { Loglevel } from './loglevel.enum';
|
import { Loglevel } from './loglevel.enum';
|
||||||
import { buildErrorMessage, parseOptionalInt, toArrayConfig } from './utils';
|
import { buildErrorMessage, parseOptionalInt } from './utils';
|
||||||
|
|
||||||
export interface AppConfig {
|
export interface AppConfig {
|
||||||
domain: string;
|
domain: string;
|
||||||
rendererOrigin: string;
|
rendererOrigin: string;
|
||||||
port: number;
|
port: number;
|
||||||
loglevel: Loglevel;
|
loglevel: Loglevel;
|
||||||
forbiddenNoteIds: string[];
|
|
||||||
maxDocumentLength: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const schema = Joi.object({
|
const schema = Joi.object({
|
||||||
|
@ -30,15 +28,6 @@ const schema = Joi.object({
|
||||||
.default(Loglevel.WARN)
|
.default(Loglevel.WARN)
|
||||||
.optional()
|
.optional()
|
||||||
.label('HD_LOGLEVEL'),
|
.label('HD_LOGLEVEL'),
|
||||||
forbiddenNoteIds: Joi.array()
|
|
||||||
.items(Joi.string())
|
|
||||||
.optional()
|
|
||||||
.default([])
|
|
||||||
.label('HD_FORBIDDEN_NOTE_IDS'),
|
|
||||||
maxDocumentLength: Joi.number()
|
|
||||||
.default(100000)
|
|
||||||
.optional()
|
|
||||||
.label('HD_MAX_DOCUMENT_LENGTH'),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default registerAs('appConfig', () => {
|
export default registerAs('appConfig', () => {
|
||||||
|
@ -48,8 +37,6 @@ export default registerAs('appConfig', () => {
|
||||||
rendererOrigin: process.env.HD_RENDERER_ORIGIN,
|
rendererOrigin: process.env.HD_RENDERER_ORIGIN,
|
||||||
port: parseOptionalInt(process.env.PORT),
|
port: parseOptionalInt(process.env.PORT),
|
||||||
loglevel: process.env.HD_LOGLEVEL,
|
loglevel: process.env.HD_LOGLEVEL,
|
||||||
forbiddenNoteIds: toArrayConfig(process.env.HD_FORBIDDEN_NOTE_IDS, ','),
|
|
||||||
maxDocumentLength: parseOptionalInt(process.env.HD_MAX_DOCUMENT_LENGTH),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
abortEarly: false,
|
abortEarly: false,
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
|
import { AppConfig } from '../app.config';
|
||||||
import { Loglevel } from '../loglevel.enum';
|
import { Loglevel } from '../loglevel.enum';
|
||||||
|
|
||||||
export default registerAs('appConfig', () => ({
|
export default registerAs(
|
||||||
domain: 'md.example.com',
|
'appConfig',
|
||||||
rendererOrigin: 'md-renderer.example.com',
|
(): AppConfig => ({
|
||||||
port: 3000,
|
domain: 'md.example.com',
|
||||||
loglevel: Loglevel.ERROR,
|
rendererOrigin: 'md-renderer.example.com',
|
||||||
maxDocumentLength: 100000,
|
port: 3000,
|
||||||
forbiddenNoteIds: ['forbiddenNoteId'],
|
loglevel: Loglevel.ERROR,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
16
src/config/mock/note.config.mock.ts
Normal file
16
src/config/mock/note.config.mock.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
|
import { NoteConfig } from '../note.config';
|
||||||
|
|
||||||
|
export default registerAs(
|
||||||
|
'noteConfig',
|
||||||
|
(): NoteConfig => ({
|
||||||
|
maxDocumentLength: 100000,
|
||||||
|
forbiddenNoteIds: ['forbiddenNoteId'],
|
||||||
|
}),
|
||||||
|
);
|
46
src/config/note.config.ts
Normal file
46
src/config/note.config.ts
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
import { registerAs } from '@nestjs/config';
|
||||||
|
import * as Joi from 'joi';
|
||||||
|
|
||||||
|
import { buildErrorMessage, parseOptionalInt, toArrayConfig } from './utils';
|
||||||
|
|
||||||
|
export interface NoteConfig {
|
||||||
|
forbiddenNoteIds: string[];
|
||||||
|
maxDocumentLength: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const schema = Joi.object({
|
||||||
|
forbiddenNoteIds: Joi.array()
|
||||||
|
.items(Joi.string())
|
||||||
|
.optional()
|
||||||
|
.default([])
|
||||||
|
.label('HD_FORBIDDEN_NOTE_IDS'),
|
||||||
|
maxDocumentLength: Joi.number()
|
||||||
|
.default(100000)
|
||||||
|
.optional()
|
||||||
|
.label('HD_MAX_DOCUMENT_LENGTH'),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default registerAs('noteConfig', () => {
|
||||||
|
const noteConfig = schema.validate(
|
||||||
|
{
|
||||||
|
forbiddenNoteIds: toArrayConfig(process.env.HD_FORBIDDEN_NOTE_IDS, ','),
|
||||||
|
maxDocumentLength: parseOptionalInt(process.env.HD_MAX_DOCUMENT_LENGTH),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
abortEarly: false,
|
||||||
|
presence: 'required',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (noteConfig.error) {
|
||||||
|
const errorMessages = noteConfig.error.details.map(
|
||||||
|
(detail) => detail.message,
|
||||||
|
);
|
||||||
|
throw new Error(buildErrorMessage(errorMessages));
|
||||||
|
}
|
||||||
|
return noteConfig.value as NoteConfig;
|
||||||
|
});
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -13,6 +13,7 @@ import { CustomizationConfig } from '../config/customization.config';
|
||||||
import { ExternalServicesConfig } from '../config/external-services.config';
|
import { ExternalServicesConfig } from '../config/external-services.config';
|
||||||
import { GitlabScope, GitlabVersion } from '../config/gitlab.enum';
|
import { GitlabScope, GitlabVersion } from '../config/gitlab.enum';
|
||||||
import { Loglevel } from '../config/loglevel.enum';
|
import { Loglevel } from '../config/loglevel.enum';
|
||||||
|
import { NoteConfig } from '../config/note.config';
|
||||||
import { LoggerModule } from '../logger/logger.module';
|
import { LoggerModule } from '../logger/logger.module';
|
||||||
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
||||||
import { AuthProviderType } from './frontend-config.dto';
|
import { AuthProviderType } from './frontend-config.dto';
|
||||||
|
@ -194,8 +195,6 @@ describe('FrontendConfigService', () => {
|
||||||
rendererOrigin: renderOrigin ?? domain,
|
rendererOrigin: renderOrigin ?? domain,
|
||||||
port: 3000,
|
port: 3000,
|
||||||
loglevel: Loglevel.ERROR,
|
loglevel: Loglevel.ERROR,
|
||||||
forbiddenNoteIds: [],
|
|
||||||
maxDocumentLength: maxDocumentLength,
|
|
||||||
};
|
};
|
||||||
const authConfig: AuthConfig = {
|
const authConfig: AuthConfig = {
|
||||||
...emptyAuthConfig,
|
...emptyAuthConfig,
|
||||||
|
@ -221,6 +220,10 @@ describe('FrontendConfigService', () => {
|
||||||
plantUmlServer: plantUmlServer,
|
plantUmlServer: plantUmlServer,
|
||||||
imageProxy: imageProxy,
|
imageProxy: imageProxy,
|
||||||
};
|
};
|
||||||
|
const noteConfig: NoteConfig = {
|
||||||
|
forbiddenNoteIds: [],
|
||||||
|
maxDocumentLength: maxDocumentLength,
|
||||||
|
};
|
||||||
const module: TestingModule =
|
const module: TestingModule =
|
||||||
await Test.createTestingModule({
|
await Test.createTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -240,6 +243,10 @@ describe('FrontendConfigService', () => {
|
||||||
'externalServicesConfig',
|
'externalServicesConfig',
|
||||||
() => externalServicesConfig,
|
() => externalServicesConfig,
|
||||||
),
|
),
|
||||||
|
registerAs(
|
||||||
|
'noteConfig',
|
||||||
|
() => noteConfig,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
LoggerModule,
|
LoggerModule,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +14,7 @@ import customizationConfiguration, {
|
||||||
import externalServicesConfiguration, {
|
import externalServicesConfiguration, {
|
||||||
ExternalServicesConfig,
|
ExternalServicesConfig,
|
||||||
} from '../config/external-services.config';
|
} from '../config/external-services.config';
|
||||||
|
import noteConfiguration, { NoteConfig } from '../config/note.config';
|
||||||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||||
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
import { getServerVersionFromPackageJson } from '../utils/serverVersion';
|
||||||
import {
|
import {
|
||||||
|
@ -31,6 +32,8 @@ export class FrontendConfigService {
|
||||||
private readonly logger: ConsoleLoggerService,
|
private readonly logger: ConsoleLoggerService,
|
||||||
@Inject(appConfiguration.KEY)
|
@Inject(appConfiguration.KEY)
|
||||||
private appConfig: AppConfig,
|
private appConfig: AppConfig,
|
||||||
|
@Inject(noteConfiguration.KEY)
|
||||||
|
private noteConfig: NoteConfig,
|
||||||
@Inject(authConfiguration.KEY)
|
@Inject(authConfiguration.KEY)
|
||||||
private authConfig: AuthConfig,
|
private authConfig: AuthConfig,
|
||||||
@Inject(customizationConfiguration.KEY)
|
@Inject(customizationConfiguration.KEY)
|
||||||
|
@ -49,7 +52,7 @@ export class FrontendConfigService {
|
||||||
authProviders: this.getAuthProviders(),
|
authProviders: this.getAuthProviders(),
|
||||||
branding: this.getBranding(),
|
branding: this.getBranding(),
|
||||||
iframeCommunication: this.getIframeCommunication(),
|
iframeCommunication: this.getIframeCommunication(),
|
||||||
maxDocumentLength: this.appConfig.maxDocumentLength,
|
maxDocumentLength: this.noteConfig.maxDocumentLength,
|
||||||
plantUmlServer: this.externalServicesConfig.plantUmlServer
|
plantUmlServer: this.externalServicesConfig.plantUmlServer
|
||||||
? new URL(this.externalServicesConfig.plantUmlServer)
|
? new URL(this.externalServicesConfig.plantUmlServer)
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@ import { Connection, Repository } from 'typeorm';
|
||||||
import { AuthToken } from '../auth/auth-token.entity';
|
import { AuthToken } from '../auth/auth-token.entity';
|
||||||
import { Author } from '../authors/author.entity';
|
import { Author } from '../authors/author.entity';
|
||||||
import appConfigMock from '../config/mock/app.config.mock';
|
import appConfigMock from '../config/mock/app.config.mock';
|
||||||
|
import noteConfigMock from '../config/mock/note.config.mock';
|
||||||
import { NotInDBError } from '../errors/errors';
|
import { NotInDBError } from '../errors/errors';
|
||||||
import { Group } from '../groups/group.entity';
|
import { Group } from '../groups/group.entity';
|
||||||
import { Identity } from '../identity/identity.entity';
|
import { Identity } from '../identity/identity.entity';
|
||||||
|
@ -65,7 +66,7 @@ describe('HistoryService', () => {
|
||||||
NotesModule,
|
NotesModule,
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock],
|
load: [appConfigMock, noteConfigMock],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -13,6 +13,7 @@ import appConfigMock from '../../src/config/mock/app.config.mock';
|
||||||
import { AuthToken } from '../auth/auth-token.entity';
|
import { AuthToken } from '../auth/auth-token.entity';
|
||||||
import { Author } from '../authors/author.entity';
|
import { Author } from '../authors/author.entity';
|
||||||
import mediaConfigMock from '../config/mock/media.config.mock';
|
import mediaConfigMock from '../config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../config/mock/note.config.mock';
|
||||||
import { ClientError, NotInDBError } from '../errors/errors';
|
import { ClientError, NotInDBError } from '../errors/errors';
|
||||||
import { Group } from '../groups/group.entity';
|
import { Group } from '../groups/group.entity';
|
||||||
import { Identity } from '../identity/identity.entity';
|
import { Identity } from '../identity/identity.entity';
|
||||||
|
@ -51,7 +52,7 @@ describe('MediaService', () => {
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [mediaConfigMock, appConfigMock],
|
load: [mediaConfigMock, appConfigMock, noteConfigMock],
|
||||||
}),
|
}),
|
||||||
LoggerModule,
|
LoggerModule,
|
||||||
NotesModule,
|
NotesModule,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@ import { Repository } from 'typeorm';
|
||||||
import { AuthToken } from '../auth/auth-token.entity';
|
import { AuthToken } from '../auth/auth-token.entity';
|
||||||
import { Author } from '../authors/author.entity';
|
import { Author } from '../authors/author.entity';
|
||||||
import appConfigMock from '../config/mock/app.config.mock';
|
import appConfigMock from '../config/mock/app.config.mock';
|
||||||
|
import noteConfigMock from '../config/mock/note.config.mock';
|
||||||
import {
|
import {
|
||||||
AlreadyInDBError,
|
AlreadyInDBError,
|
||||||
ForbiddenIdError,
|
ForbiddenIdError,
|
||||||
|
@ -65,7 +66,7 @@ describe('AliasService', () => {
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock],
|
load: [appConfigMock, noteConfigMock],
|
||||||
}),
|
}),
|
||||||
LoggerModule,
|
LoggerModule,
|
||||||
UsersModule,
|
UsersModule,
|
||||||
|
@ -102,7 +103,7 @@ describe('AliasService', () => {
|
||||||
.compile();
|
.compile();
|
||||||
|
|
||||||
const config = module.get<ConfigService>(ConfigService);
|
const config = module.get<ConfigService>(ConfigService);
|
||||||
forbiddenNoteId = config.get('appConfig').forbiddenNoteIds[0];
|
forbiddenNoteId = config.get('noteConfig').forbiddenNoteIds[0];
|
||||||
service = module.get<AliasService>(AliasService);
|
service = module.get<AliasService>(AliasService);
|
||||||
noteRepo = module.get<Repository<Note>>(getRepositoryToken(Note));
|
noteRepo = module.get<Repository<Note>>(getRepositoryToken(Note));
|
||||||
aliasRepo = module.get<Repository<Alias>>(getRepositoryToken(Alias));
|
aliasRepo = module.get<Repository<Alias>>(getRepositoryToken(Alias));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@ import { Repository } from 'typeorm';
|
||||||
import { AuthToken } from '../auth/auth-token.entity';
|
import { AuthToken } from '../auth/auth-token.entity';
|
||||||
import { Author } from '../authors/author.entity';
|
import { Author } from '../authors/author.entity';
|
||||||
import appConfigMock from '../config/mock/app.config.mock';
|
import appConfigMock from '../config/mock/app.config.mock';
|
||||||
|
import noteConfigMock from '../config/mock/note.config.mock';
|
||||||
import {
|
import {
|
||||||
AlreadyInDBError,
|
AlreadyInDBError,
|
||||||
ForbiddenIdError,
|
ForbiddenIdError,
|
||||||
|
@ -76,7 +77,7 @@ describe('NotesService', () => {
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock],
|
load: [appConfigMock, noteConfigMock],
|
||||||
}),
|
}),
|
||||||
LoggerModule,
|
LoggerModule,
|
||||||
UsersModule,
|
UsersModule,
|
||||||
|
@ -113,7 +114,7 @@ describe('NotesService', () => {
|
||||||
.compile();
|
.compile();
|
||||||
|
|
||||||
const config = module.get<ConfigService>(ConfigService);
|
const config = module.get<ConfigService>(ConfigService);
|
||||||
forbiddenNoteId = config.get('appConfig').forbiddenNoteIds[0];
|
forbiddenNoteId = config.get('noteConfig').forbiddenNoteIds[0];
|
||||||
service = module.get<NotesService>(NotesService);
|
service = module.get<NotesService>(NotesService);
|
||||||
noteRepo = module.get<Repository<Note>>(getRepositoryToken(Note));
|
noteRepo = module.get<Repository<Note>>(getRepositoryToken(Note));
|
||||||
revisionRepo = module.get<Repository<Revision>>(
|
revisionRepo = module.get<Repository<Revision>>(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -7,7 +7,7 @@ import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
import appConfiguration, { AppConfig } from '../config/app.config';
|
import noteConfiguration, { NoteConfig } from '../config/note.config';
|
||||||
import {
|
import {
|
||||||
AlreadyInDBError,
|
AlreadyInDBError,
|
||||||
ForbiddenIdError,
|
ForbiddenIdError,
|
||||||
|
@ -47,8 +47,8 @@ export class NotesService {
|
||||||
@Inject(GroupsService) private groupsService: GroupsService,
|
@Inject(GroupsService) private groupsService: GroupsService,
|
||||||
@Inject(forwardRef(() => RevisionsService))
|
@Inject(forwardRef(() => RevisionsService))
|
||||||
private revisionsService: RevisionsService,
|
private revisionsService: RevisionsService,
|
||||||
@Inject(appConfiguration.KEY)
|
@Inject(noteConfiguration.KEY)
|
||||||
private appConfig: AppConfig,
|
private noteConfig: NoteConfig,
|
||||||
) {
|
) {
|
||||||
this.logger.setContext(NotesService.name);
|
this.logger.setContext(NotesService.name);
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ export class NotesService {
|
||||||
* @throws {ForbiddenIdError} the requested id or alias is forbidden
|
* @throws {ForbiddenIdError} the requested id or alias is forbidden
|
||||||
*/
|
*/
|
||||||
checkNoteIdOrAlias(noteIdOrAlias: string): void {
|
checkNoteIdOrAlias(noteIdOrAlias: string): void {
|
||||||
if (this.appConfig.forbiddenNoteIds.includes(noteIdOrAlias)) {
|
if (this.noteConfig.forbiddenNoteIds.includes(noteIdOrAlias)) {
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`A note with the alias '${noteIdOrAlias}' is forbidden by the administrator.`,
|
`A note with the alias '${noteIdOrAlias}' is forbidden by the administrator.`,
|
||||||
'checkNoteIdOrAlias',
|
'checkNoteIdOrAlias',
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@ import { getRepositoryToken } from '@nestjs/typeorm';
|
||||||
import { AuthToken } from '../auth/auth-token.entity';
|
import { AuthToken } from '../auth/auth-token.entity';
|
||||||
import { Author } from '../authors/author.entity';
|
import { Author } from '../authors/author.entity';
|
||||||
import appConfigMock from '../config/mock/app.config.mock';
|
import appConfigMock from '../config/mock/app.config.mock';
|
||||||
|
import noteConfigMock from '../config/mock/note.config.mock';
|
||||||
import { Group } from '../groups/group.entity';
|
import { Group } from '../groups/group.entity';
|
||||||
import { SpecialGroup } from '../groups/groups.special';
|
import { SpecialGroup } from '../groups/groups.special';
|
||||||
import { Identity } from '../identity/identity.entity';
|
import { Identity } from '../identity/identity.entity';
|
||||||
|
@ -42,7 +43,7 @@ describe('PermissionsService', () => {
|
||||||
NotesModule,
|
NotesModule,
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock],
|
load: [appConfigMock, noteConfigMock],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@ import { Repository } from 'typeorm';
|
||||||
import { AuthToken } from '../auth/auth-token.entity';
|
import { AuthToken } from '../auth/auth-token.entity';
|
||||||
import { Author } from '../authors/author.entity';
|
import { Author } from '../authors/author.entity';
|
||||||
import appConfigMock from '../config/mock/app.config.mock';
|
import appConfigMock from '../config/mock/app.config.mock';
|
||||||
|
import noteConfigMock from '../config/mock/note.config.mock';
|
||||||
import { NotInDBError } from '../errors/errors';
|
import { NotInDBError } from '../errors/errors';
|
||||||
import { Group } from '../groups/group.entity';
|
import { Group } from '../groups/group.entity';
|
||||||
import { Identity } from '../identity/identity.entity';
|
import { Identity } from '../identity/identity.entity';
|
||||||
|
@ -45,7 +46,7 @@ describe('RevisionsService', () => {
|
||||||
LoggerModule,
|
LoggerModule,
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [appConfigMock],
|
load: [appConfigMock, noteConfigMock],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -25,7 +25,7 @@ describe('Alias', () => {
|
||||||
await testSetup.app.init();
|
await testSetup.app.init();
|
||||||
|
|
||||||
forbiddenNoteId =
|
forbiddenNoteId =
|
||||||
testSetup.configService.get('appConfig').forbiddenNoteIds[0];
|
testSetup.configService.get('noteConfig').forbiddenNoteIds[0];
|
||||||
users = testSetup.users;
|
users = testSetup.users;
|
||||||
|
|
||||||
agent1 = request.agent(testSetup.app.getHttpServer());
|
agent1 = request.agent(testSetup.app.getHttpServer());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -33,12 +33,11 @@ describe('History', () => {
|
||||||
testSetup = await TestSetupBuilder.create().build();
|
testSetup = await TestSetupBuilder.create().build();
|
||||||
|
|
||||||
forbiddenNoteId =
|
forbiddenNoteId =
|
||||||
testSetup.configService.get('appConfig').forbiddenNoteIds[0];
|
testSetup.configService.get('noteConfig').forbiddenNoteIds[0];
|
||||||
|
|
||||||
const moduleRef = testSetup.moduleRef;
|
const moduleRef = testSetup.moduleRef;
|
||||||
|
|
||||||
const config = moduleRef.get<ConfigService>(ConfigService);
|
const config = moduleRef.get<ConfigService>(ConfigService);
|
||||||
forbiddenNoteId = config.get('appConfig').forbiddenNoteIds[0];
|
|
||||||
|
|
||||||
const authConfig = config.get('authConfig') as AuthConfig;
|
const authConfig = config.get('authConfig') as AuthConfig;
|
||||||
setupSessionMiddleware(testSetup.app, authConfig);
|
setupSessionMiddleware(testSetup.app, authConfig);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -28,7 +28,7 @@ describe('Notes', () => {
|
||||||
testSetup = await TestSetupBuilder.create().build();
|
testSetup = await TestSetupBuilder.create().build();
|
||||||
|
|
||||||
forbiddenNoteId =
|
forbiddenNoteId =
|
||||||
testSetup.configService.get('appConfig').forbiddenNoteIds[0];
|
testSetup.configService.get('noteConfig').forbiddenNoteIds[0];
|
||||||
uploadPath =
|
uploadPath =
|
||||||
testSetup.configService.get('mediaConfig').backend.filesystem.uploadPath;
|
testSetup.configService.get('mediaConfig').backend.filesystem.uploadPath;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +18,7 @@ describe('Alias', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
testSetup = await TestSetupBuilder.create().withUsers().withNotes().build();
|
testSetup = await TestSetupBuilder.create().withUsers().withNotes().build();
|
||||||
forbiddenNoteId =
|
forbiddenNoteId =
|
||||||
testSetup.configService.get('appConfig').forbiddenNoteIds[0];
|
testSetup.configService.get('noteConfig').forbiddenNoteIds[0];
|
||||||
|
|
||||||
await testSetup.app.init();
|
await testSetup.app.init();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -26,7 +26,7 @@ describe('Notes', () => {
|
||||||
testSetup = await TestSetupBuilder.create().withMockAuth().build();
|
testSetup = await TestSetupBuilder.create().withMockAuth().build();
|
||||||
|
|
||||||
forbiddenNoteId =
|
forbiddenNoteId =
|
||||||
testSetup.configService.get('appConfig').forbiddenNoteIds[0];
|
testSetup.configService.get('noteConfig').forbiddenNoteIds[0];
|
||||||
uploadPath =
|
uploadPath =
|
||||||
testSetup.configService.get('mediaConfig').backend.filesystem.uploadPath;
|
testSetup.configService.get('mediaConfig').backend.filesystem.uploadPath;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -23,6 +23,7 @@ import authConfigMock from '../src/config/mock/auth.config.mock';
|
||||||
import customizationConfigMock from '../src/config/mock/customization.config.mock';
|
import customizationConfigMock from '../src/config/mock/customization.config.mock';
|
||||||
import externalServicesConfigMock from '../src/config/mock/external-services.config.mock';
|
import externalServicesConfigMock from '../src/config/mock/external-services.config.mock';
|
||||||
import mediaConfigMock from '../src/config/mock/media.config.mock';
|
import mediaConfigMock from '../src/config/mock/media.config.mock';
|
||||||
|
import noteConfigMock from '../src/config/mock/note.config.mock';
|
||||||
import { FrontendConfigModule } from '../src/frontend-config/frontend-config.module';
|
import { FrontendConfigModule } from '../src/frontend-config/frontend-config.module';
|
||||||
import { GroupsModule } from '../src/groups/groups.module';
|
import { GroupsModule } from '../src/groups/groups.module';
|
||||||
import { HistoryModule } from '../src/history/history.module';
|
import { HistoryModule } from '../src/history/history.module';
|
||||||
|
@ -105,6 +106,7 @@ export class TestSetupBuilder {
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
load: [
|
load: [
|
||||||
appConfigMock,
|
appConfigMock,
|
||||||
|
noteConfigMock,
|
||||||
authConfigMock,
|
authConfigMock,
|
||||||
mediaConfigMock,
|
mediaConfigMock,
|
||||||
customizationConfigMock,
|
customizationConfigMock,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue