Skip to content

Commit

Permalink
Merge branch 'main' into EW-644
Browse files Browse the repository at this point in the history
  • Loading branch information
Fshmit committed Nov 17, 2023
2 parents ff711da + 4f746c5 commit a9d134d
Show file tree
Hide file tree
Showing 18 changed files with 125 additions and 74 deletions.
6 changes: 3 additions & 3 deletions config/config.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"SESSION_SECRET": "SessionSecretForDevelopment",
"SESSION_TTL_MS": 3600000,
"BACKEND_ADDRESS": "http://127.0.0.1:9090",
"OIDC_CALLBACK_URL": "http://localhost:8099/api/frontend/login",
"DEFAULT_LOGIN_REDIRECT": "http://localhost:8099/",
"LOGOUT_REDIRECT": "http://localhost:8099/"
"OIDC_CALLBACK_URL": "https://localhost:8099/api/frontend/login",
"DEFAULT_LOGIN_REDIRECT": "https://localhost:8099/",
"LOGOUT_REDIRECT": "https://localhost:8099/"
},
"DB": {
"CLIENT_URL": "postgres://admin:[email protected]:5432",
Expand Down
4 changes: 2 additions & 2 deletions dev-realm-spsh.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@
"secret": "YDp6fYkbUcj4ZkyAOnbAHGQ9O72htc5M",
"redirectUris": [
"http://localhost:9091/*",
"http://localhost:8099/*",
"https://localhost:8099/*",
"/*"
],
"webOrigins": [
Expand Down Expand Up @@ -2364,4 +2364,4 @@
"clientPolicies": {
"policies": []
}
}
}
127 changes: 71 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@automapper/classes": "^8.7.7",
"@automapper/core": "^8.7.7",
"@automapper/nestjs": "^8.7.7",
"@faker-js/faker": "^8.3.0",
"@faker-js/faker": "^8.3.1",
"@mikro-orm/core": "^5.9.3",
"@mikro-orm/nestjs": "^5.2.2",
"@mikro-orm/postgresql": "^5.9.3",
Expand All @@ -44,18 +44,18 @@
"@nestjs/core": "^9.0.0",
"@nestjs/passport": "^10.0.2",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/swagger": "^7.1.15",
"@nestjs/swagger": "^7.1.16",
"@nestjs/terminus": "^10.1.1",
"@s3pweb/keycloak-admin-client-cjs": "^22.0.1",
"axios": "^1.5.0",
"axios": "^1.6.2",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"connect-redis": "^7.1.0",
"express": "^4.18.2",
"express-session": "^1.17.3",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"nest-commander": "^3.12.2",
"nest-commander": "~3.10",
"nest-keycloak-connect": "^1.9.2",
"openid-client": "^5.6.0",
"passport": "^0.6.0",
Expand Down Expand Up @@ -90,7 +90,7 @@
"supertest": "^6.1.3",
"testcontainers": "^10.2.2",
"ts-jest": "^29.1.0",
"ts-loader": "^9.5.0",
"ts-loader": "^9.5.1",
"ts-node": "^10.0.0",
"typescript": "^5.0.0"
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/frontend/api/frontend.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ describe('FrontendController', () => {
geschlecht: Geschlecht.M,
lokalisierung: '',
vertrauensstufe: Vertrauensstufe.VOLL,
revision: '1',
};
const personenKontextResponse: PersonenkontextResponse[] = [];
const response: PersonendatensatzResponse = {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/frontend/auth/user.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ExecutionContext, createParamDecorator } from '@nestjs/common';
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { Request } from 'express';
import { UserinfoResponse } from 'openid-client';

type UserDecoratorFactory = () => ParameterDecorator;

export type User = { id_token: string; access_token: string; userinfo: UserinfoResponse } & Express.User;
export type User = { id_token: string; access_token: string; userinfo: UserinfoResponse };

export const CurrentUser: UserDecoratorFactory = createParamDecorator((_data: unknown, ctx: ExecutionContext) => {
const request: Request = ctx.switchToHttp().getRequest<Request>();
Expand Down
2 changes: 2 additions & 0 deletions src/modules/person/api/person-api.mapper.profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class PersonApiMapperProfile extends AutomapperProfile {
forMember((dest: PersonDo<boolean>) => dest.id, ignore()),
forMember((dest: PersonDo<boolean>) => dest.createdAt, ignore()),
forMember((dest: PersonDo<boolean>) => dest.updatedAt, ignore()),
forMember((dest: PersonDo<boolean>) => dest.revision, ignore()),
);
createMap(
mapper,
Expand Down Expand Up @@ -200,6 +201,7 @@ export class PersonApiMapperProfile extends AutomapperProfile {
forMember((dest: PersonDo<false>) => dest.lokalisierung, ignore()),
forMember((dest: PersonDo<false>) => dest.vertrauensstufe, ignore()),
forMember((dest: PersonDo<false>) => dest.auskunftssperre, ignore()),
forMember((dest: PersonDo<false>) => dest.revision, ignore()),
);

createMap(mapper, CreatePersonDto, UserDo);
Expand Down
3 changes: 2 additions & 1 deletion src/modules/person/api/person.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ describe('PersonController', () => {

describe('when creating a person', () => {
it('should not throw', async () => {
personUcMock.createPerson.mockResolvedValue();
const personDto: PersonDto = {} as PersonDto;
personUcMock.createPerson.mockResolvedValue(personDto);
const params: CreatePersonBodyParams = {
username: faker.internet.userName(),
mandant: faker.string.uuid(),
Expand Down
16 changes: 14 additions & 2 deletions src/modules/person/api/person.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { CreatedPersonenkontextDto } from './created-personenkontext.dto.js';
import { FindPersonendatensatzDto } from './find-personendatensatz.dto.js';
import { FindPersonenkontextDto } from './find-personenkontext.dto.js';
import { PersonByIdParams } from './person-by-id.param.js';
import { PersonDto } from './person.dto.js';
import { PersonenQueryParams } from './personen-query.param.js';
import { PersonendatensatzDto } from './personendatensatz.dto.js';
import { PersonendatensatzResponse } from './personendatensatz.response.js';
Expand All @@ -59,14 +60,25 @@ export class PersonController {
) {}

@Post()
@HttpCode(200)
@ApiCreatedResponse({ description: 'The person was successfully created.' })
@ApiBadRequestResponse({ description: 'The person already exists.' })
@ApiUnauthorizedResponse({ description: 'Not authorized to create the person.' })
@ApiForbiddenResponse({ description: 'Insufficient permissions to create the person.' })
@ApiInternalServerErrorResponse({ description: 'Internal server error while creating the person.' })
public async createPerson(@Body() params: CreatePersonBodyParams): Promise<void> {
public async createPerson(@Body() params: CreatePersonBodyParams): Promise<PersonendatensatzResponse> {
const dto: CreatePersonDto = this.mapper.map(params, CreatePersonBodyParams, CreatePersonDto);
await this.personUc.createPerson(dto);
const person: PersonDto = await this.personUc.createPerson(dto);
const personendatensatzDto: PersonendatensatzDto = {
person: person,
personenkontexte: [],
};
const personendatensatzResponse: PersonendatensatzResponse = this.mapper.map(
personendatensatzDto,
PersonendatensatzDto,
PersonendatensatzResponse,
);
return personendatensatzResponse;
}

@Get(':personId')
Expand Down
Loading

0 comments on commit a9d134d

Please sign in to comment.