Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-5522-Implementation of an API for deleting data #4533

Merged
merged 125 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
cce8684
endpoints preparation
sszafGCA Nov 8, 2023
aa32e24
Merge remote-tracking branch 'origin' into BC-5522-impl-of-deletion-api
sszafGCA Nov 8, 2023
5308f8f
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 9, 2023
d6e0922
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 9, 2023
175e495
auth startegy impl
sszafGCA Nov 9, 2023
fd2b9b8
api impl
sszafGCA Nov 10, 2023
7d3b626
some changes
WojciechGrancow Nov 10, 2023
a954f6b
some fixes need in KNL module
WojciechGrancow Nov 11, 2023
a07bd74
Merge branch 'main' into BC-5522-impl-of-deletion-api
WojciechGrancow Nov 11, 2023
60aa0ac
changes in uc and register entities
WojciechGrancow Nov 12, 2023
c65367b
Pr fixes and minor changes
sszafGCA Nov 12, 2023
bf27fd8
rename file
sszafGCA Nov 12, 2023
d477ba7
some fixes
WojciechGrancow Nov 13, 2023
762a9ee
Merge branch 'main' into BC-5522-impl-of-deletion-api
WojciechGrancow Nov 13, 2023
80430f5
add exposing admin API port from the api-svc
bn-pass Nov 13, 2023
24b823c
add server test module + delete FileEntity from allEntities
sszafGCA Nov 13, 2023
f4e10ff
change module
sszafGCA Nov 13, 2023
f2f2a5d
admin api server module test impl
sszafGCA Nov 13, 2023
9c4be9e
add some tests
WojciechGrancow Nov 14, 2023
4ab94f8
Merge branch 'BC-5522-impl-of-deletion-api' of https://github.com/hpi…
WojciechGrancow Nov 14, 2023
9a790fd
Merge branch 'main' into BC-5522-impl-of-deletion-api
WojciechGrancow Nov 14, 2023
b5e2a01
add some test for API
WojciechGrancow Nov 14, 2023
495e953
Merge branch 'main' into BC-5522-impl-of-deletion-api
WojciechGrancow Nov 14, 2023
bd430e9
add some test
WojciechGrancow Nov 14, 2023
fb3012f
Merge branch 'main' into BC-5522-impl-of-deletion-api
WojciechGrancow Nov 14, 2023
caf07ab
x-api-key.strategy tests
sszafGCA Nov 14, 2023
b040876
x-api-key-strategy-tests impl
sszafGCA Nov 14, 2023
0d3074e
remove test for api-setup-helper, remove unused imports
sszafGCA Nov 14, 2023
d935d13
remove test file
sszafGCA Nov 14, 2023
01340fb
add info for the Admin API port
bn-pass Nov 15, 2023
c866efe
add test for controller
WojciechGrancow Nov 15, 2023
bf68c68
Merge branch 'BC-5522-impl-of-deletion-api' of https://github.com/hpi…
WojciechGrancow Nov 15, 2023
adb77c9
add test for deletionRequestResponse
WojciechGrancow Nov 15, 2023
3f046f5
remove not needed parameter from constructor
sszafGCA Nov 15, 2023
9a04a4a
add test for deletionRequestLogResponse
WojciechGrancow Nov 15, 2023
9ea749f
Merge branch 'BC-5522-impl-of-deletion-api' of https://github.com/hpi…
WojciechGrancow Nov 15, 2023
46c98b2
add test for executionParams and requestbodyParams
WojciechGrancow Nov 15, 2023
539c173
replace hard-coded Admin API server port value with the one taken fro…
bn-pass Nov 15, 2023
c1f1f35
change creation of API method location
sszafGCA Nov 15, 2023
9ad4206
change default json
sszafGCA Nov 15, 2023
f422a7b
fix import in server module
sszafGCA Nov 15, 2023
8c46093
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 15, 2023
3b58d13
fixes soma issues
WojciechGrancow Nov 15, 2023
01bdd63
Merge branch 'BC-5522-impl-of-deletion-api' of https://github.com/hpi…
WojciechGrancow Nov 15, 2023
4fc4c70
fixes after review
WojciechGrancow Nov 15, 2023
aba6e1a
add admin api object
sszafGCA Nov 15, 2023
6764f95
default json chnages
sszafGCA Nov 15, 2023
15ed045
Revert "default json chnages"
sszafGCA Nov 15, 2023
2a15fe3
Revert "add admin api object"
sszafGCA Nov 15, 2023
2e80ece
Revert "fixes after review"
sszafGCA Nov 15, 2023
c57995f
Revert "fixes soma issues"
sszafGCA Nov 15, 2023
011b0f7
fixes after review
WojciechGrancow Nov 16, 2023
ccf0aef
small fixes
WojciechGrancow Nov 16, 2023
30ab3f4
Revert "small fixes"
sszafGCA Nov 16, 2023
6feb0a8
Revert "Revert "small fixes""
sszafGCA Nov 16, 2023
8b6243e
default ADMIN_API_KEY
WojciechGrancow Nov 16, 2023
2ffb06a
fix some imports
WojciechGrancow Nov 16, 2023
4bbf149
small change in x-api-key.strategy
WojciechGrancow Nov 16, 2023
a6f0b6a
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 16, 2023
0188096
Update apps/server/src/modules/deletion/uc/builder/deletion-log-stati…
WojciechGrancow Nov 16, 2023
2e07dc3
change default.schema.json
sszafGCA Nov 16, 2023
3826319
new changes to default.schema.json
sszafGCA Nov 16, 2023
a0046bc
fix after review
WojciechGrancow Nov 16, 2023
8373501
add logger for error in deeltionRequestUC
WojciechGrancow Nov 17, 2023
2695b3d
fix problem with fileentity
WojciechGrancow Nov 17, 2023
92dba86
fix imports
WojciechGrancow Nov 17, 2023
3155b71
add logger to test in uc of deletionModule
WojciechGrancow Nov 17, 2023
2196f1e
change module config
sszafGCA Nov 17, 2023
c0ae9d7
hard-coded Admin API server port after the discussion with Paul
bn-pass Nov 17, 2023
b0c730b
fixes bug during deletion uders data from lessons
WojciechGrancow Nov 17, 2023
3a8f8d4
Merge branch 'main' into BC-5522-impl-of-deletion-api
WojciechGrancow Nov 17, 2023
684cd52
Merge branch 'BC-5522-impl-of-deletion-api' of https://github.com/hpi…
WojciechGrancow Nov 17, 2023
7a97f28
merge with main
WojciechGrancow Nov 21, 2023
9d40aea
fix pipeline
sszafGCA Nov 21, 2023
87cdfd2
fix pipeline #2
sszafGCA Nov 21, 2023
048875d
fix pipeline
sszafGCA Nov 21, 2023
8ccf2d6
fix lint
sszafGCA Nov 21, 2023
d2fc5dc
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 23, 2023
2848964
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 23, 2023
1e0bb2d
fix modules imports
sszafGCA Nov 23, 2023
994262f
fix providers in exports in deletion module
sszafGCA Nov 23, 2023
72e7f31
split deletion module and deletion-api.module
sszafGCA Nov 23, 2023
86b176d
move setup sessions to server config
sszafGCA Nov 23, 2023
e336196
try to fix test coverage
sszafGCA Nov 23, 2023
235a83c
Revert "try to fix test coverage"
sszafGCA Nov 23, 2023
e4b133d
Revert "move setup sessions to server config"
sszafGCA Nov 23, 2023
0cd52ca
remove api key from default.json
sszafGCA Nov 23, 2023
d86d1e5
changes to server module
sszafGCA Nov 24, 2023
41fcd0c
use timers in tests
sszafGCA Nov 24, 2023
a254858
revert last commit
sszafGCA Nov 24, 2023
4892112
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 24, 2023
fe26bb0
add testXApiKeyClient
WojciechGrancow Nov 27, 2023
fce93f5
merge with main
WojciechGrancow Nov 27, 2023
bb48803
deployment impl
sszafGCA Nov 27, 2023
ee6c312
add newlines
sszafGCA Nov 27, 2023
7c229e2
add test
WojciechGrancow Nov 27, 2023
49f82f5
Merge branch 'main' into BC-5522-impl-of-deletion-api
WojciechGrancow Nov 27, 2023
2c37383
change character length
sszafGCA Nov 27, 2023
d98d11c
fix imports
WojciechGrancow Nov 27, 2023
fc41e5f
fix deployment in PR
WojciechGrancow Nov 27, 2023
eea9009
PR fixes part 1
sszafGCA Nov 28, 2023
ed55cdb
fix build and push
sszafGCA Nov 28, 2023
53905bb
fix prettier
sszafGCA Nov 28, 2023
2496a8b
default schema changes
sszafGCA Nov 28, 2023
787ab34
small fixes
WojciechGrancow Nov 28, 2023
c0567ff
Merge remote-tracking branch 'origin' into BC-5522-impl-of-deletion-api
WojciechGrancow Nov 28, 2023
1d53580
fix lint
sszafGCA Nov 28, 2023
084e46e
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 28, 2023
228ab7a
add registration pins module
sszafGCA Nov 28, 2023
6590fc0
change sorting of code lines
CeEv Nov 29, 2023
9d98975
small fixes after review
WojciechGrancow Nov 29, 2023
02e37c8
add enabled in admiApiServer
WojciechGrancow Nov 29, 2023
df06ed7
add process.exit
WojciechGrancow Nov 29, 2023
b2fa12f
test revert enabled (testing purposes)
sszafGCA Nov 29, 2023
bc3faa1
Revert "test revert enabled (testing purposes)"
sszafGCA Nov 29, 2023
d589435
add default for testers
sszafGCA Nov 29, 2023
9d6e7c8
Revert "add default for testers"
sszafGCA Nov 29, 2023
a13fc2d
fix with elsson entity
WojciechGrancow Nov 29, 2023
760190d
Merge branch 'main' into BC-5522-impl-of-deletion-api
WojciechGrancow Nov 29, 2023
25b15c6
Merge branch 'BC-5522-impl-of-deletion-api' of https://github.com/hpi…
WojciechGrancow Nov 29, 2023
499d22b
fix lint
sszafGCA Nov 30, 2023
fcacb61
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 30, 2023
7e75f2b
changes in main.yml
sszafGCA Nov 30, 2023
e482fd6
Merge branch 'main' into BC-5522-impl-of-deletion-api
sszafGCA Nov 30, 2023
1d41b33
fix enabled
WojciechGrancow Nov 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/server/src/apps/helpers/admin-api-setup-helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import express from 'express';
import { Configuration } from '@hpi-schul-cloud/commons/lib';
import { Logger } from '@src/core/logger';
import { AdminApiServerModule } from '@src/modules/server/admin-api.server.module';
import { ExpressAdapter } from '@nestjs/platform-express';
import { NestFactory } from '@nestjs/core';
import { AppStartLoggable } from './app-start-loggable';

export const createAndStartAdminApiServer = async (logger: Logger) => {
const nestAdminServerExpress = express();
const nestAdminServerExpressAdapter = new ExpressAdapter(nestAdminServerExpress);
const nestAdminServerApp = await NestFactory.create(AdminApiServerModule, nestAdminServerExpressAdapter);

nestAdminServerApp.setGlobalPrefix('/admin/api/v1');
await nestAdminServerApp.init();

const adminApiServerPort = Configuration.get('ADMIN_API__PORT') as number;

nestAdminServerExpress.listen(adminApiServerPort, () => {
logger.info(
new AppStartLoggable({
appName: 'Admin Api server app',
port: adminApiServerPort,
mountsDescription: `/admin/api/v1 --> Admin Api Server`,
})
);
});
};
6 changes: 6 additions & 0 deletions apps/server/src/apps/server.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ import { join } from 'path';
// register source-map-support for debugging
import { install as sourceMapInstall } from 'source-map-support';
import { FeathersRosterService } from '@modules/pseudonym';
import { Configuration } from '@hpi-schul-cloud/commons/lib';
import legacyAppPromise = require('../../../../src/app');

import { AppStartLoggable } from './helpers/app-start-loggable';
import {
addPrometheusMetricsMiddlewaresIfEnabled,
createAndStartPrometheusMetricsAppIfEnabled,
} from './helpers/prometheus-metrics';
import { createAndStartAdminApiServer } from './helpers/admin-api-setup-helper';

async function bootstrap() {
sourceMapInstall();
Expand Down Expand Up @@ -127,6 +129,10 @@ async function bootstrap() {
createAndStartPrometheusMetricsAppIfEnabled(logger);
});

if (Configuration.get('ADMIN_API__ENABLED') === true) {
await createAndStartAdminApiServer(logger);
}

console.log('#################################');
console.log(`### Start Server ###`);
console.log(`### Port: ${port} ###`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { JwtStrategy } from './strategy/jwt.strategy';
import { LdapStrategy } from './strategy/ldap.strategy';
import { LocalStrategy } from './strategy/local.strategy';
import { Oauth2Strategy } from './strategy/oauth2.strategy';
import { XApiKeyStrategy } from './strategy/x-api-key.strategy';

// values copied from Algorithm definition. Type does not exist at runtime and can't be checked anymore otherwise
const algorithms = [
Expand Down Expand Up @@ -76,6 +77,7 @@ const jwtModuleOptions: JwtModuleOptions = {
LdapService,
LdapStrategy,
Oauth2Strategy,
XApiKeyStrategy,
],
exports: [AuthenticationService],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IXApiKeyConfig {
ADMIN_API__ALLOWED_API_KEYS: string[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Injectable, UnauthorizedException } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { ConfigService } from '@nestjs/config';
import Strategy from 'passport-headerapikey';
import { IXApiKeyConfig } from '../config/x-api-key.config';

@Injectable()
export class XApiKeyStrategy extends PassportStrategy(Strategy, 'api-key') {
private readonly allowedApiKeys: string[];

constructor(private readonly configService: ConfigService<IXApiKeyConfig, true>) {
super(
{ header: 'X-API-KEY', prefix: '' },
true,
// eslint-disable-next-line @typescript-eslint/require-await
async (apiKey: string, done: (error: Error | null, data: boolean | null) => void) => this.validate(apiKey, done)
);
this.allowedApiKeys = this.configService.get<string[]>('ADMIN_API__ALLOWED_API_KEYS');
}

public validate = (apiKey: string, done: (error: Error | null, data: boolean | null) => void) => {
CeEv marked this conversation as resolved.
Show resolved Hide resolved
if (this.allowedApiKeys.includes(apiKey)) {
done(null, true);
}
done(new UnauthorizedException(), null);
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Controller, Post, Query, UseGuards } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ForbiddenOperationError, ValidationError } from '@shared/common';
import { AuthGuard } from '@nestjs/passport';
import { DeletionRequestUc } from '../uc/deletion-request.uc';
import { DeletionExecutionParams } from './dto';

@ApiTags('DeletionExecutions')
@UseGuards(AuthGuard('api-key'))
@Controller('deletionExecutions')
export class DeletionExecutionsController {
constructor(private readonly deletionRequestUc: DeletionRequestUc) {}

@Post()
@ApiOperation({
summary: '"Queueing" a deletion request',
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
})
@ApiResponse({
status: 204,
})
@ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' })
@ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero or administrator.' })
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
async executeDeletions(@Query() deletionExecutionQuery: DeletionExecutionParams) {
return this.deletionRequestUc.executeDeletionRequests(deletionExecutionQuery.limit);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ForbiddenOperationError, ValidationError } from '@shared/common';
import { AuthGuard } from '@nestjs/passport';
import { DeletionRequestUc } from '../uc/deletion-request.uc';
import { DeletionRequestResponse } from './dto/deletion-request.response';
import { DeletionRequestBodyProps } from './dto/deletion-request.body.params';
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
import { DeletionRequestLogResponse } from './dto';

@ApiTags('DeletionRequests')
@UseGuards(AuthGuard('api-key'))
@Controller('deletionRequests')
export class DeletionRequestsController {
constructor(private readonly deletionRequestUc: DeletionRequestUc) {}

@Post()
@ApiOperation({
summary: '"Queueing" a deletion request',
})
@ApiResponse({
status: 202,
type: DeletionRequestResponse,
description: 'Returns identifier of the deletion request and when deletion is planned at',
})
@ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' })
@ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero or administrator.' })
async createDeletionRequests(
@Body() deletionRequestBody: DeletionRequestBodyProps
): Promise<DeletionRequestResponse> {
return this.deletionRequestUc.createDeletionRequest(deletionRequestBody);
}

@Get(':requestId')
@ApiOperation({
sszafGCA marked this conversation as resolved.
Show resolved Hide resolved
summary: 'Retrieving details of performed or planned deletion',
})
@ApiResponse({
status: 202,
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
type: DeletionRequestLogResponse,
description: 'Return details of performed or planned deletion',
})
@ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' })
@ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero or administrator.' })
async getPerformedDeletionDetails(@Param('requestId') requestId: string): Promise<DeletionRequestLogResponse> {
CeEv marked this conversation as resolved.
Show resolved Hide resolved
return this.deletionRequestUc.findById(requestId);
}

@Delete(':requestId')
@ApiOperation({
summary: 'Canceling a deletion request',
})
@ApiResponse({
status: 204,
})
@ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' })
@ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero or administrator.' })
async cancelDeletionRequest(@Param('requestId') requestId: string) {
return this.deletionRequestUc.deleteDeletionRequestById(requestId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsInt, Min } from 'class-validator';

export class DeletionExecutionParams {
@IsInt()
@Min(0)
@ApiPropertyOptional({ description: 'Page limit, defaults to 100.', minimum: 0 })
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
limit?: number = 100;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsOptional } from 'class-validator';
import { DeletionLogStatistic, DeletionTargetRef } from '../../uc/interface';
CeEv marked this conversation as resolved.
Show resolved Hide resolved

export class DeletionRequestLogResponse {
@ApiProperty()
targetRef: DeletionTargetRef;

@ApiProperty()
deletionPlannedAt: Date;

@ApiProperty()
@IsOptional()
statistics?: DeletionLogStatistic[];

constructor(response: DeletionRequestLogResponse) {
this.targetRef = response.targetRef;
this.deletionPlannedAt = response.deletionPlannedAt;
this.statistics = response.statistics;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsNumber } from 'class-validator';
import { EntityId } from '@shared/domain';
import { DeletionDomainModel } from '../../domain/types/deletion-domain-model.enum';
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved

export class DeletionRequestBodyProps {
@ApiProperty({
required: true,
nullable: false,
})
targetRef!: { targetRefDomain: DeletionDomainModel; targetRefId: EntityId };

@IsNumber()
@ApiProperty({
required: true,
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
nullable: false,
})
deleteInMinutes?: number;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiProperty } from '@nestjs/swagger';

export class DeletionRequestResponse {
@ApiProperty()
requestId: string;

@ApiProperty()
deletionPlannedAt: Date;

constructor(response: DeletionRequestResponse) {
this.requestId = response.requestId;
this.deletionPlannedAt = response.deletionPlannedAt;
}
}
4 changes: 4 additions & 0 deletions apps/server/src/modules/deletion/controller/dto/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './deletion-request.response';
export * from './deletion-request.body.params';
export * from './deletion-request-log.response';
export * from './deletion-execution.params';
58 changes: 56 additions & 2 deletions apps/server/src/modules/deletion/deletion.module.ts
CeEv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,11 +1,65 @@
import { Module } from '@nestjs/common';
import { LoggerModule } from '@src/core/logger';
import { ConfigService } from '@nestjs/config';
import { CourseGroupRepo } from '@shared/repo';
import { Configuration } from '@hpi-schul-cloud/commons';
import { DeletionRequestService } from './services/deletion-request.service';
import { DeletionRequestRepo } from './repo/deletion-request.repo';
import { AuthenticationModule } from '../authentication';
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
import { DeletionRequestsController } from './controller/deletion-requests.controller';
import { DeletionExecutionsController } from './controller/deletion-executions.controller';
import { IXApiKeyConfig } from '../authentication/config/x-api-key.config';
import { DeletionRequestUc } from './uc/deletion-request.uc';
import { DeletionLogService } from './services/deletion-log.service';
import { AccountModule } from '../account';
import { ClassModule } from '../class';
import { CourseGroupService } from '../learnroom/service';
import { LearnroomModule } from '../learnroom';
import { FilesService } from '../files/service';
import { LessonModule } from '../lesson';
import { PseudonymModule } from '../pseudonym';
import { TeamsModule } from '../teams';
import { UserModule } from '../user';
import { RocketChatUserService } from '../rocketchat-user';
import { RocketChatModule } from '../rocketchat';
import { DeletionLogRepo } from './repo';
import { FilesRepo } from '../files/repo';
import { RocketChatUserRepo } from '../rocketchat-user/repo';

@Module({
imports: [LoggerModule],
providers: [DeletionRequestService, DeletionRequestRepo],
imports: [
LoggerModule,
AuthenticationModule,
AccountModule,
ClassModule,
LearnroomModule,
LessonModule,
PseudonymModule,
TeamsModule,
UserModule,
RocketChatModule.forRoot({
uri: Configuration.get('ROCKET_CHAT_URI') as string,
adminId: Configuration.get('ROCKET_CHAT_ADMIN_ID') as string,
adminToken: Configuration.get('ROCKET_CHAT_ADMIN_TOKEN') as string,
adminUser: Configuration.get('ROCKET_CHAT_ADMIN_USER') as string,
adminPassword: Configuration.get('ROCKET_CHAT_ADMIN_PASSWORD') as string,
}),
],
controllers: [DeletionRequestsController, DeletionExecutionsController],
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
providers: [
DeletionRequestService,
DeletionRequestRepo,
ConfigService<IXApiKeyConfig, true>,
DeletionRequestUc,
DeletionLogService,
CourseGroupService,
FilesService,
DeletionLogRepo,
CourseGroupRepo,
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
FilesRepo,
RocketChatUserService,
RocketChatUserRepo,
],
exports: [DeletionRequestService],
})
export class DeletionModule {}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DeletionDomainModel } from '../../domain/types/deletion-domain-model.enum';
import { DeletionLogStatisticBuilder } from './deletion-log-statistic.builder';
import { DeletionRequestLogBuilder } from './deletion-request-log.builder';
import { DeletionRequestLogResponseBuilder } from './deletion-request-log.builder';
import { DeletionTargetRefBuilder } from './deletion-target-ref.builder';

describe(DeletionRequestLogBuilder.name, () => {
describe(DeletionRequestLogResponseBuilder.name, () => {
afterAll(() => {
jest.clearAllMocks();
});
Expand All @@ -18,7 +18,7 @@ describe(DeletionRequestLogBuilder.name, () => {
const deletedCount = 2;
const statistics = [DeletionLogStatisticBuilder.build(targetRefDomain, modifiedCount, deletedCount)];

const result = DeletionRequestLogBuilder.build(targetRef, deletionPlannedAt, statistics);
const result = DeletionRequestLogResponseBuilder.build(targetRef, deletionPlannedAt, statistics);

// Assert
expect(result.targetRef).toEqual(targetRef);
Expand Down
WojciechGrancow marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { DeletionLogStatistic, DeletionRequestLog, DeletionTargetRef } from '../interface';
import { DeletionRequestLogResponse } from '../../controller/dto';
import { DeletionLogStatistic, DeletionTargetRef } from '../interface';

export class DeletionRequestLogBuilder {
export class DeletionRequestLogResponseBuilder {
static build(
targetRef: DeletionTargetRef,
deletionPlannedAt: Date,
statistics?: DeletionLogStatistic[]
): DeletionRequestLog {
): DeletionRequestLogResponse {
const deletionRequestLog = { targetRef, deletionPlannedAt, statistics };

return deletionRequestLog;
Expand Down
Loading
Loading