diff --git a/apps/server/src/modules/provisioning/dto/external-school.dto.ts b/apps/server/src/modules/provisioning/dto/external-school.dto.ts index c853c090228..701ee63f931 100644 --- a/apps/server/src/modules/provisioning/dto/external-school.dto.ts +++ b/apps/server/src/modules/provisioning/dto/external-school.dto.ts @@ -5,9 +5,12 @@ export class ExternalSchoolDto { officialSchoolNumber?: string; + location?: string; + constructor(props: ExternalSchoolDto) { this.externalId = props.externalId; this.name = props.name; this.officialSchoolNumber = props.officialSchoolNumber; + this.location = props.location; } } diff --git a/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.spec.ts b/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.spec.ts index 09e253dddbf..5fcd5fc37a5 100644 --- a/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.spec.ts +++ b/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.spec.ts @@ -1,28 +1,29 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { AccountService } from '@modules/account/services/account.service'; +import { AccountSaveDto } from '@modules/account/services/dto'; +import { Group, GroupService } from '@modules/group'; +import { FederalStateService, LegacySchoolService, SchoolYearService } from '@modules/legacy-school'; +import { RoleService } from '@modules/role'; +import { RoleDto } from '@modules/role/service/dto/role.dto'; +import { UserService } from '@modules/user'; import { UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { NotFoundLoggableException } from '@shared/common/loggable-exception'; import { ExternalSource, LegacySchoolDo, RoleName, RoleReference, SchoolFeatures } from '@shared/domain'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { externalGroupDtoFactory, federalStateFactory, groupFactory, - roleDtoFactory, legacySchoolDoFactory, + roleDtoFactory, + roleFactory, schoolYearFactory, userDoFactory, - roleFactory, } from '@shared/testing'; import { Logger } from '@src/core/logger'; -import { AccountService } from '@modules/account/services/account.service'; -import { AccountSaveDto } from '@modules/account/services/dto'; -import { Group, GroupService } from '@modules/group'; -import { RoleService } from '@modules/role'; -import { RoleDto } from '@modules/role/service/dto/role.dto'; -import { FederalStateService, LegacySchoolService, SchoolYearService } from '@modules/legacy-school'; -import { UserService } from '@modules/user'; import CryptoJS from 'crypto-js'; -import { NotFoundLoggableException } from '@shared/common/loggable-exception'; import { ExternalGroupDto, ExternalSchoolDto, ExternalUserDto } from '../../../dto'; import { SchoolForGroupNotFoundLoggable, UserForGroupNotFoundLoggable } from '../../../loggable'; import { OidcProvisioningService } from './oidc-provisioning.service'; @@ -101,102 +102,414 @@ describe('OidcProvisioningService', () => { }); describe('provisionExternalSchool', () => { - const setup = () => { - const systemId = 'systemId'; - const externalSchoolDto: ExternalSchoolDto = new ExternalSchoolDto({ - externalId: 'externalId', - name: 'name', - officialSchoolNumber: 'officialSchoolNumber', - }); - const savedSchoolDO = legacySchoolDoFactory.build({ - id: 'schoolId', - externalId: 'externalId', - name: 'name', - officialSchoolNumber: 'officialSchoolNumber', - systems: [systemId], - features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + describe('when systemId is given and external school does not exist', () => { + describe('when successful', () => { + const setup = () => { + const systemId = new ObjectId().toHexString(); + const externalSchoolDto: ExternalSchoolDto = new ExternalSchoolDto({ + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + }); + + const schoolYear = schoolYearFactory.build(); + const federalState = federalStateFactory.build(); + const savedSchoolDO = new LegacySchoolDo({ + id: 'schoolId', + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + schoolYear, + federalState, + }); + + schoolService.save.mockResolvedValue(savedSchoolDO); + schoolService.getSchoolByExternalId.mockResolvedValue(null); + schoolYearService.getCurrentSchoolYear.mockResolvedValue(schoolYear); + federalStateService.findFederalStateByName.mockResolvedValue(federalState); + + return { + systemId, + externalSchoolDto, + savedSchoolDO, + }; + }; + + it('should save the correct data', async () => { + const { systemId, externalSchoolDto, savedSchoolDO } = setup(); + + await service.provisionExternalSchool(externalSchoolDto, systemId); + + expect(schoolService.save).toHaveBeenCalledWith({ ...savedSchoolDO, id: undefined }, true); + }); + + it('should save the new school', async () => { + const { systemId, externalSchoolDto, savedSchoolDO } = setup(); + + const result: LegacySchoolDo = await service.provisionExternalSchool(externalSchoolDto, systemId); + + expect(result).toEqual(savedSchoolDO); + }); }); - const existingSchoolDO = legacySchoolDoFactory.build({ - id: 'schoolId', - externalId: 'externalId', - name: 'existingName', - officialSchoolNumber: 'existingOfficialSchoolNumber', - systems: [systemId], - features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + + describe('when the external system provides a location for the school', () => { + const setup = () => { + const systemId = new ObjectId().toHexString(); + const externalSchoolDto: ExternalSchoolDto = new ExternalSchoolDto({ + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + location: 'Hannover', + }); + + const schoolYear = schoolYearFactory.build(); + const federalState = federalStateFactory.build(); + const savedSchoolDO = new LegacySchoolDo({ + id: 'schoolId', + externalId: 'externalId', + name: 'name (Hannover)', + officialSchoolNumber: 'officialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + schoolYear, + federalState, + }); + + schoolService.save.mockResolvedValue(savedSchoolDO); + schoolService.getSchoolByExternalId.mockResolvedValue(null); + schoolYearService.getCurrentSchoolYear.mockResolvedValue(schoolYear); + federalStateService.findFederalStateByName.mockResolvedValue(federalState); + + return { + systemId, + externalSchoolDto, + savedSchoolDO, + }; + }; + + it('should append it to the school name', async () => { + const { systemId, externalSchoolDto, savedSchoolDO } = setup(); + + await service.provisionExternalSchool(externalSchoolDto, systemId); + + expect(schoolService.save).toHaveBeenCalledWith({ ...savedSchoolDO, id: undefined }, true); + }); }); - schoolService.save.mockResolvedValue(savedSchoolDO); - schoolService.getSchoolByExternalId.mockResolvedValue(null); - schoolYearService.getCurrentSchoolYear.mockResolvedValue(schoolYearFactory.build()); - federalStateService.findFederalStateByName.mockResolvedValue(federalStateFactory.build()); + describe('when the external system does not provide a location for the school', () => { + const setup = () => { + const systemId = new ObjectId().toHexString(); + const externalSchoolDto: ExternalSchoolDto = new ExternalSchoolDto({ + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + }); - return { - systemId, - externalSchoolDto, - savedSchoolDO, - existingSchoolDO, - }; - }; + const schoolYear = schoolYearFactory.build(); + const federalState = federalStateFactory.build(); + const savedSchoolDO = new LegacySchoolDo({ + id: 'schoolId', + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + schoolYear, + federalState, + }); - describe('when systemId is given and external school does not exist', () => { - it('should save the new school', async () => { - const { systemId, externalSchoolDto, savedSchoolDO } = setup(); + schoolService.save.mockResolvedValue(savedSchoolDO); + schoolService.getSchoolByExternalId.mockResolvedValue(null); + schoolYearService.getCurrentSchoolYear.mockResolvedValue(schoolYear); + federalStateService.findFederalStateByName.mockResolvedValue(federalState); - const result: LegacySchoolDo = await service.provisionExternalSchool(externalSchoolDto, systemId); + return { + systemId, + externalSchoolDto, + savedSchoolDO, + }; + }; + + it('should only use the school name', async () => { + const { systemId, externalSchoolDto, savedSchoolDO } = setup(); - expect(result).toEqual(savedSchoolDO); + await service.provisionExternalSchool(externalSchoolDto, systemId); + + expect(schoolService.save).toHaveBeenCalledWith({ ...savedSchoolDO, id: undefined }, true); + }); }); }); describe('when external school already exist', () => { - it('should update the existing school', async () => { - const { systemId, externalSchoolDto, existingSchoolDO, savedSchoolDO } = setup(); + describe('when successful', () => { + const setup = () => { + const systemId = new ObjectId().toHexString(); + const externalSchoolDto: ExternalSchoolDto = new ExternalSchoolDto({ + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + }); - schoolService.getSchoolByExternalId.mockResolvedValue(existingSchoolDO); + const schoolYear = schoolYearFactory.build(); + const federalState = federalStateFactory.build(); + const savedSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + schoolYear, + federalState, + }); + const existingSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'existingName', + officialSchoolNumber: 'existingOfficialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + }); + + schoolService.save.mockResolvedValue(savedSchoolDO); + schoolService.getSchoolByExternalId.mockResolvedValue(existingSchoolDO); + schoolYearService.getCurrentSchoolYear.mockResolvedValue(schoolYear); + federalStateService.findFederalStateByName.mockResolvedValue(federalState); + + return { + systemId, + externalSchoolDto, + savedSchoolDO, + existingSchoolDO, + }; + }; - const result: LegacySchoolDo = await service.provisionExternalSchool(externalSchoolDto, systemId); + it('should update the existing school', async () => { + const { systemId, externalSchoolDto, savedSchoolDO } = setup(); - expect(result).toEqual(savedSchoolDO); + const result: LegacySchoolDo = await service.provisionExternalSchool(externalSchoolDto, systemId); + + expect(result).toEqual(savedSchoolDO); + }); }); - it('should append the new system', async () => { - const { systemId, externalSchoolDto, existingSchoolDO, savedSchoolDO } = setup(); - const otherSystemId = 'otherSystemId'; - existingSchoolDO.systems = [otherSystemId]; + describe('when the external system provides a location for the school', () => { + const setup = () => { + const systemId = new ObjectId().toHexString(); + const externalSchoolDto: ExternalSchoolDto = new ExternalSchoolDto({ + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + location: 'Hannover', + }); - schoolService.getSchoolByExternalId.mockResolvedValue(existingSchoolDO); + const schoolYear = schoolYearFactory.build(); + const federalState = federalStateFactory.build(); + const savedSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'name (Hannover)', + officialSchoolNumber: 'officialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + schoolYear, + federalState, + }); + const existingSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'existingName', + officialSchoolNumber: 'existingOfficialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + }); - await service.provisionExternalSchool(externalSchoolDto, systemId); + schoolService.save.mockResolvedValue(savedSchoolDO); + schoolService.getSchoolByExternalId.mockResolvedValue(existingSchoolDO); + schoolYearService.getCurrentSchoolYear.mockResolvedValue(schoolYear); + federalStateService.findFederalStateByName.mockResolvedValue(federalState); - expect(schoolService.save).toHaveBeenCalledWith( - { - ...savedSchoolDO, - systems: [otherSystemId, systemId], - }, - true - ); + return { + systemId, + externalSchoolDto, + savedSchoolDO, + existingSchoolDO, + }; + }; + + it('should append it to the school name', async () => { + const { systemId, externalSchoolDto, savedSchoolDO } = setup(); + + await service.provisionExternalSchool(externalSchoolDto, systemId); + + expect(schoolService.save).toHaveBeenCalledWith(savedSchoolDO, true); + }); }); - it('should create a new system list', async () => { - const { systemId, externalSchoolDto, existingSchoolDO, savedSchoolDO } = setup(); - existingSchoolDO.systems = undefined; + describe('when the external system does not provide a location for the school', () => { + const setup = () => { + const systemId = new ObjectId().toHexString(); + const externalSchoolDto: ExternalSchoolDto = new ExternalSchoolDto({ + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + }); + + const schoolYear = schoolYearFactory.build(); + const federalState = federalStateFactory.build(); + const savedSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + schoolYear, + federalState, + }); + const existingSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'existingName', + officialSchoolNumber: 'existingOfficialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + }); + + schoolService.save.mockResolvedValue(savedSchoolDO); + schoolService.getSchoolByExternalId.mockResolvedValue(existingSchoolDO); + schoolYearService.getCurrentSchoolYear.mockResolvedValue(schoolYear); + federalStateService.findFederalStateByName.mockResolvedValue(federalState); - schoolService.getSchoolByExternalId.mockResolvedValue(existingSchoolDO); + return { + systemId, + externalSchoolDto, + savedSchoolDO, + existingSchoolDO, + }; + }; + + it('should only use the school name', async () => { + const { systemId, externalSchoolDto, savedSchoolDO } = setup(); - await service.provisionExternalSchool(externalSchoolDto, systemId); + await service.provisionExternalSchool(externalSchoolDto, systemId); - expect(schoolService.save).toHaveBeenCalledWith( - { - ...savedSchoolDO, - federalState: { - ...savedSchoolDO.federalState, - createdAt: expect.any(Date), - updatedAt: expect.any(Date), + expect(schoolService.save).toHaveBeenCalledWith(savedSchoolDO, true); + }); + }); + + describe('when there is a system at the school', () => { + const setup = () => { + const systemId = new ObjectId().toHexString(); + const otherSystemId = new ObjectId().toHexString(); + const externalSchoolDto: ExternalSchoolDto = new ExternalSchoolDto({ + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + }); + + const schoolYear = schoolYearFactory.build(); + const federalState = federalStateFactory.build(); + const savedSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + systems: [otherSystemId, systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + schoolYear, + federalState, + }); + const existingSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'existingName', + officialSchoolNumber: 'existingOfficialSchoolNumber', + systems: [otherSystemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + }); + + schoolService.save.mockResolvedValue(savedSchoolDO); + schoolService.getSchoolByExternalId.mockResolvedValue(existingSchoolDO); + schoolYearService.getCurrentSchoolYear.mockResolvedValue(schoolYear); + federalStateService.findFederalStateByName.mockResolvedValue(federalState); + + return { + systemId, + otherSystemId, + externalSchoolDto, + savedSchoolDO, + existingSchoolDO, + }; + }; + + it('should append the new system', async () => { + const { systemId, otherSystemId, externalSchoolDto, savedSchoolDO } = setup(); + + await service.provisionExternalSchool(externalSchoolDto, systemId); + + expect(schoolService.save).toHaveBeenCalledWith( + { + ...savedSchoolDO, + systems: [otherSystemId, systemId], }, - inMaintenanceSince: expect.any(Date), - }, - true - ); + true + ); + }); + }); + + describe('when there is no system at the school yet', () => { + const setup = () => { + const systemId = new ObjectId().toHexString(); + const externalSchoolDto: ExternalSchoolDto = new ExternalSchoolDto({ + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + }); + + const schoolYear = schoolYearFactory.build(); + const federalState = federalStateFactory.build(); + const savedSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'name', + officialSchoolNumber: 'officialSchoolNumber', + systems: [systemId], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + schoolYear, + federalState, + }); + const existingSchoolDO = legacySchoolDoFactory.build({ + id: 'schoolId', + externalId: 'externalId', + name: 'existingName', + officialSchoolNumber: 'existingOfficialSchoolNumber', + systems: [], + features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], + }); + + schoolService.save.mockResolvedValue(savedSchoolDO); + schoolService.getSchoolByExternalId.mockResolvedValue(existingSchoolDO); + schoolYearService.getCurrentSchoolYear.mockResolvedValue(schoolYear); + federalStateService.findFederalStateByName.mockResolvedValue(federalState); + + return { + systemId, + externalSchoolDto, + savedSchoolDO, + existingSchoolDO, + }; + }; + + it('should create a new system list', async () => { + const { systemId, externalSchoolDto, savedSchoolDO } = setup(); + + await service.provisionExternalSchool(externalSchoolDto, systemId); + + expect(schoolService.save).toHaveBeenCalledWith(savedSchoolDO, true); + }); }); }); }); diff --git a/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.ts b/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.ts index 66c243e6457..6d13537439b 100644 --- a/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.ts +++ b/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.ts @@ -1,7 +1,3 @@ -import { Injectable, UnprocessableEntityException } from '@nestjs/common'; -import { EntityId, ExternalSource, FederalStateEntity, SchoolFeatures, SchoolYearEntity } from '@shared/domain'; -import { LegacySchoolDo, RoleReference, UserDO } from '@shared/domain/domainobject'; -import { Logger } from '@src/core/logger'; import { AccountService } from '@modules/account/services/account.service'; import { AccountSaveDto } from '@modules/account/services/dto'; import { Group, GroupService, GroupUser } from '@modules/group'; @@ -10,9 +6,13 @@ import { FederalStateNames } from '@modules/legacy-school/types'; import { RoleService } from '@modules/role'; import { RoleDto } from '@modules/role/service/dto/role.dto'; import { UserService } from '@modules/user'; +import { Injectable, UnprocessableEntityException } from '@nestjs/common'; +import { NotFoundLoggableException } from '@shared/common/loggable-exception'; +import { EntityId, ExternalSource, FederalStateEntity, SchoolFeatures, SchoolYearEntity } from '@shared/domain'; +import { LegacySchoolDo, RoleReference, UserDO } from '@shared/domain/domainobject'; +import { Logger } from '@src/core/logger'; import { ObjectId } from 'bson'; import CryptoJS from 'crypto-js'; -import { NotFoundLoggableException } from '@shared/common/loggable-exception'; import { ExternalGroupDto, ExternalGroupUserDto, ExternalSchoolDto, ExternalUserDto } from '../../../dto'; import { SchoolForGroupNotFoundLoggable, UserForGroupNotFoundLoggable } from '../../../loggable'; @@ -37,7 +37,7 @@ export class OidcProvisioningService { let school: LegacySchoolDo; if (existingSchool) { school = existingSchool; - school.name = externalSchool.name; + school.name = this.getSchoolName(externalSchool); school.officialSchoolNumber = externalSchool.officialSchoolNumber ?? existingSchool.officialSchoolNumber; if (!school.systems) { school.systems = [systemId]; @@ -52,7 +52,7 @@ export class OidcProvisioningService { school = new LegacySchoolDo({ externalId: externalSchool.externalId, - name: externalSchool.name, + name: this.getSchoolName(externalSchool), officialSchoolNumber: externalSchool.officialSchoolNumber, systems: [systemId], features: [SchoolFeatures.OAUTH_PROVISIONING_ENABLED], @@ -63,9 +63,18 @@ export class OidcProvisioningService { } const savedSchool: LegacySchoolDo = await this.schoolService.save(school, true); + return savedSchool; } + private getSchoolName(externalSchool: ExternalSchoolDto): string { + const schoolName: string = externalSchool.location + ? `${externalSchool.name} (${externalSchool.location})` + : externalSchool.name; + + return schoolName; + } + async provisionExternalUser(externalUser: ExternalUserDto, systemId: EntityId, schoolId?: string): Promise { let roleRefs: RoleReference[] | undefined; if (externalUser.roles) { diff --git a/apps/server/src/modules/provisioning/strategy/sanis/response/index.ts b/apps/server/src/modules/provisioning/strategy/sanis/response/index.ts index 56f70ad0f41..bb8cc6e8d07 100644 --- a/apps/server/src/modules/provisioning/strategy/sanis/response/index.ts +++ b/apps/server/src/modules/provisioning/strategy/sanis/response/index.ts @@ -11,3 +11,4 @@ export * from './sanis-personenkontext-response'; export * from './sanis-gruppenzugehoerigkeit-response'; export * from './sanis-person-response'; export * from './sanis-sonstige-gruppenzugehoerige-response'; +export * from './sanis-anschrift-response'; diff --git a/apps/server/src/modules/provisioning/strategy/sanis/response/sanis-anschrift-response.ts b/apps/server/src/modules/provisioning/strategy/sanis/response/sanis-anschrift-response.ts new file mode 100644 index 00000000000..6b793ba4486 --- /dev/null +++ b/apps/server/src/modules/provisioning/strategy/sanis/response/sanis-anschrift-response.ts @@ -0,0 +1,9 @@ +export interface SanisAnschriftResponse { + adresszeile?: string; + + postleitzahl?: string; + + ort?: string; + + ortsteil?: string; +} diff --git a/apps/server/src/modules/provisioning/strategy/sanis/response/sanis-organisation-response.ts b/apps/server/src/modules/provisioning/strategy/sanis/response/sanis-organisation-response.ts index 258cde00a50..fa7d2846ad1 100644 --- a/apps/server/src/modules/provisioning/strategy/sanis/response/sanis-organisation-response.ts +++ b/apps/server/src/modules/provisioning/strategy/sanis/response/sanis-organisation-response.ts @@ -1,3 +1,5 @@ +import { SanisAnschriftResponse } from './sanis-anschrift-response'; + export interface SanisOrganisationResponse { id: string; @@ -6,4 +8,6 @@ export interface SanisOrganisationResponse { name: string; typ: string; + + anschrift?: SanisAnschriftResponse; } diff --git a/apps/server/src/modules/provisioning/strategy/sanis/sanis-response.mapper.spec.ts b/apps/server/src/modules/provisioning/strategy/sanis/sanis-response.mapper.spec.ts index 2fe68c0163b..9829e3cb930 100644 --- a/apps/server/src/modules/provisioning/strategy/sanis/sanis-response.mapper.spec.ts +++ b/apps/server/src/modules/provisioning/strategy/sanis/sanis-response.mapper.spec.ts @@ -1,8 +1,8 @@ import { createMock } from '@golevelup/ts-jest'; +import { GroupTypes } from '@modules/group'; import { Test, TestingModule } from '@nestjs/testing'; import { RoleName } from '@shared/domain'; import { Logger } from '@src/core/logger'; -import { GroupTypes } from '@modules/group'; import { UUID } from 'bson'; import { ExternalGroupDto, ExternalSchoolDto, ExternalUserDto } from '../../dto'; import { @@ -56,6 +56,9 @@ describe('SanisResponseMapper', () => { name: 'schoolName', typ: 'SCHULE', kennung: 'NI_123456_NI_ashd3838', + anschrift: { + ort: 'Hannover', + }, }, personenstatus: '', gruppen: [ @@ -103,6 +106,7 @@ describe('SanisResponseMapper', () => { externalId: externalSchoolId, name: 'schoolName', officialSchoolNumber: '123456_NI_ashd3838', + location: 'Hannover', }); }); }); diff --git a/apps/server/src/modules/provisioning/strategy/sanis/sanis-response.mapper.ts b/apps/server/src/modules/provisioning/strategy/sanis/sanis-response.mapper.ts index 23d9b15fbdc..ee912dd67b5 100644 --- a/apps/server/src/modules/provisioning/strategy/sanis/sanis-response.mapper.ts +++ b/apps/server/src/modules/provisioning/strategy/sanis/sanis-response.mapper.ts @@ -1,7 +1,7 @@ +import { GroupTypes } from '@modules/group'; import { Injectable } from '@nestjs/common'; import { RoleName } from '@shared/domain'; import { Logger } from '@src/core/logger'; -import { GroupTypes } from '@modules/group'; import { ExternalGroupDto, ExternalGroupUserDto, ExternalSchoolDto, ExternalUserDto } from '../../dto'; import { GroupRoleUnknownLoggable } from '../../loggable'; import { @@ -45,6 +45,7 @@ export class SanisResponseMapper { name: source.personenkontexte[0].organisation.name, externalId: source.personenkontexte[0].organisation.id.toString(), officialSchoolNumber, + location: source.personenkontexte[0].organisation.anschrift?.ort, }); return mapped;