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

SPSH-1288 #774

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

SPSH-1288 #774

wants to merge 30 commits into from

Conversation

he-meyer
Copy link
Contributor

Description

Links to Tickets or other pull requests

https://ticketsystem.dbildungscloud.de/browse/SPSH-1288

Changes

Datasecurity

Deployment

New Repos, NPM pakages or vendor scripts

Approval for review

  • QA: In addition to review, the code has been manually tested (if manual testing is possible)
  • All points were discussed with the ticket creator, support-team or product owner. The code upholds all quality guidelines from the PR-template.

if (permissions) {
if (error) {
this.logger.error(
`Admin ${permissions.personFields.familienname} (${permissions.personFields.id}) hat versucht eine neue Klasse ${organisation.name} (${schoolName}) anzulegen. Fehler: ${error.message}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ist familienname richtig? ich würde einfach den username nehmen

Comment on lines 92 to 105
const permissionsMock: PersonPermissions = createMock<PersonPermissions>({
get personFields(): Person<true> {
return createMock<Person<true>>({
familienname: 'current-user',
});
},
getPersonenkontextewithRoles: (): Promise<PersonenkontextRolleFields[]> =>
Promise.resolve([
{
organisationsId: '',
rolle: { systemrechte: [], serviceProviderIds: [] },
},
]),
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leeres Permissions-Objekt sollte an dieser Stelle ausreichend sein.

Comment on lines 737 to 750
const permissionsMock: PersonPermissions = createMock<PersonPermissions>({
get personFields(): Person<true> {
return createMock<Person<true>>({
familienname: 'current-user',
});
},
getPersonenkontextewithRoles: (): Promise<PersonenkontextRolleFields[]> =>
Promise.resolve([
{
organisationsId: '',
rolle: { systemrechte: [], serviceProviderIds: [] },
},
]),
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Siehe oben

Comment on lines 820 to 833
const permissionsMock: PersonPermissions = createMock<PersonPermissions>({
get personFields(): Person<true> {
return createMock<Person<true>>({
familienname: 'current-user',
});
},
getPersonenkontextewithRoles: (): Promise<PersonenkontextRolleFields[]> =>
Promise.resolve([
{
organisationsId: '',
rolle: { systemrechte: [], serviceProviderIds: [] },
},
]),
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Siehe oben

Comment on lines 68 to 82
const permissionsMock: DeepMocked<PersonPermissions> = createMock<PersonPermissions>({
get personFields(): Person<true> {
return createMock<Person<true>>({
id: 'test-id',
keycloakUserId: 'test-keycloak',
vorname: 'test-vorname',
familienname: 'test-familienname',
rufname: 'test-rufname',
username: 'test-username',
geschlecht: Geschlecht.M,
geburtsdatum: faker.date.past(),
updatedAt: faker.date.recent(),
});
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Permissions-Objekt kann hier auch ohne die Spezifizierung für den Test gemocked werden

Comment on lines 373 to 387
const permissionsMock: DeepMocked<PersonPermissions> = createMock<PersonPermissions>({
get personFields(): Person<true> {
return createMock<Person<true>>({
id: 'test-id',
keycloakUserId: 'test-keycloak',
vorname: 'test-vorname',
familienname: 'test-familienname',
rufname: 'test-rufname',
username: 'test-username',
geschlecht: Geschlecht.M,
geburtsdatum: faker.date.past(),
updatedAt: faker.date.recent(),
});
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Siehe oben. Überflüssige Importe können dann entfernt werden.

Comment on lines 845 to 859
const permissionsMock: PersonPermissions = createMock<PersonPermissions>({
get personFields(): Person<true> {
return createMock<Person<true>>({
id: 'test-id',
keycloakUserId: 'test-keycloak',
vorname: 'test-vorname',
familienname: 'test-familienname',
rufname: 'test-rufname',
username: 'test-username',
geschlecht: Geschlecht.M,
geburtsdatum: faker.date.past(),
updatedAt: faker.date.recent(),
});
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Siehe oben.

@@ -423,13 +428,24 @@ export class OrganisationRepository {
await this.em.removeAndFlush(organisationEntity);
this.eventService.publish(new KlasseDeletedEvent(organisationEntity.id));

let schoolName: string = 'SCHOOL_NOT_FOUND';
if (permissions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Siehe oben

Comment on lines 139 to 153
permissionsMock = createMock<PersonPermissions>({
get personFields(): Person<true> {
return createMock<Person<true>>({
id: 'test-id',
keycloakUserId: 'test-keycloak',
vorname: 'test-vorname',
familienname: 'test-familienname',
rufname: 'test-rufname',
username: 'test-username',
geschlecht: Geschlecht.M,
geburtsdatum: faker.date.past(),
updatedAt: faker.date.recent(),
});
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Siehe oben

rolle: { systemrechte: [], serviceProviderIds: [] },
},
]),
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Siehe oben

Comment on lines 468 to 480

private async getOrganisationNameForCurrentUser(permissions: PersonPermissions): Promise<string> {
const personenkontextRolleFields: PersonenkontextRolleFields[] =
await permissions?.getPersonenkontextewithRoles();
const organisationIdUser: string | undefined = personenkontextRolleFields.at(0)?.organisationsId;
if (organisationIdUser) {
const organisationUser: Option<Organisation<true>> =
await this.organisationRepository.findById(organisationIdUser);
if (organisationUser) if (organisationUser.name) return organisationUser.name;
}
this.logger.error(`No Organisation id found for given Person id: ${permissions.personFields.id}`);
return 'ORGANISATION_NOT_FOUND';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ein Benutzer kann mehrere Organisationen und Rollen haben, bzw. eine Person kann mehrere Personenkontexte haben. Ich glaube der Mehrwert ist hier nicht gegeben, sich den ersten Index des Arrays für die Rollen anzuschauen.

Comment on lines 193 to 196
if (!orgResult.ok) {
this.logger.info(
`Admin ${permissions.personFields.username} (${permissions.personFields.id}) hat versucht eine neue Rolle ${params.name} anzulegen. Fehler: ${orgResult.error.message}`,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hier logger.error verwenden. Am Besten nochmal überall prüfen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants