Skip to content

Commit

Permalink
Merge branch 'main' into BC-8193-start-bbb
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchuhmacher authored Dec 11, 2024
2 parents d830df8 + acb3c2e commit 07a775e
Show file tree
Hide file tree
Showing 77 changed files with 568 additions and 512 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,12 @@ describe(EtherpadClientAdapter.name, () => {
it('should throw EtherpadErrorLoggableException', async () => {
const groupId = setup();

const exception = new EtherpadErrorLoggableException(EtherpadErrorType.INTERNAL_ERROR, { padId: groupId }, {});
const exception = new EtherpadErrorLoggableException(
EtherpadErrorType.INTERNAL_ERROR,
{ padId: groupId },
undefined,
{}
);
await expect(service.deleteGroup(groupId)).rejects.toThrowError(exception);
});
});
Expand Down Expand Up @@ -1084,7 +1089,12 @@ describe(EtherpadClientAdapter.name, () => {
it('should throw EtherpadErrorLoggableException', async () => {
const sessionId = setup();

const exception = new EtherpadErrorLoggableException(EtherpadErrorType.BAD_REQUEST, { sessionId }, {});
const exception = new EtherpadErrorLoggableException(
EtherpadErrorType.BAD_REQUEST,
{ sessionId },
undefined,
{}
);
await expect(service.deleteSession(sessionId)).rejects.toThrowError(exception);
});
});
Expand Down Expand Up @@ -1150,7 +1160,7 @@ describe(EtherpadClientAdapter.name, () => {
it('should throw EtherpadErrorLoggableException', async () => {
const padId = setup();

const exception = new EtherpadErrorLoggableException(EtherpadErrorType.BAD_REQUEST, { padId }, {});
const exception = new EtherpadErrorLoggableException(EtherpadErrorType.BAD_REQUEST, { padId }, undefined, {});
await expect(service.deletePad(padId)).rejects.toThrowError(exception);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class EtherpadErrorLoggableException extends InternalServerErrorException
constructor(
private readonly type: EtherpadErrorType,
private readonly payload: EtherpadParams,
private readonly originalMessage: string | undefined,
private readonly exceptionOptions: HttpExceptionOptions
) {
super(type, exceptionOptions);
Expand All @@ -20,6 +21,7 @@ export class EtherpadErrorLoggableException extends InternalServerErrorException
data: {
userId,
parentId,
originalMessage: this.originalMessage,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('EtherpadErrorLoggableException', () => {
const error = new Error('error');
const httpExceptionOptions = ErrorUtils.createHttpExceptionOptions(error);

const exception = new EtherpadErrorLoggableException(type, payload, httpExceptionOptions);
const exception = new EtherpadErrorLoggableException(type, payload, 'hugo ist nudeln', httpExceptionOptions);
const result = exception.getLogMessage();

expect(result).toStrictEqual({
Expand All @@ -22,6 +22,7 @@ describe('EtherpadErrorLoggableException', () => {
data: {
userId: 'userId',
parentId: 'parentId',
originalMessage: 'hugo ist nudeln',
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ export class EtherpadResponseMapper {
payload: EtherpadParams,
response: T | Error
): EtherpadErrorLoggableException {
return new EtherpadErrorLoggableException(type, payload, ErrorUtils.createHttpExceptionOptions(response.message));
return new EtherpadErrorLoggableException(
type,
payload,
response.message,
ErrorUtils.createHttpExceptionOptions(response.message)
);
}

static mapEtherpadSessionsToSessions(etherpadSessions: unknown): Session[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Type } from 'class-transformer';
import { IsEnum, IsObject, IsOptional, IsString, ValidateNested } from 'class-validator';
import { SchulconnexGroupType } from './schulconnex-group-type';
import { IsObject, IsOptional, IsString, ValidateNested } from 'class-validator';
import { SchulconnexLaufzeitResponse } from './schulconnex-laufzeit-response';

export class SchulconnexGruppeResponse {
Expand All @@ -10,8 +9,8 @@ export class SchulconnexGruppeResponse {
@IsString()
bezeichnung!: string;

@IsEnum(SchulconnexGroupType)
typ!: SchulconnexGroupType;
@IsString()
typ!: string;

@IsOptional()
@IsObject()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { Type } from 'class-transformer';
import { IsArray, IsEnum, IsObject, IsOptional, IsString, ValidateNested } from 'class-validator';
import { IsArray, IsObject, IsOptional, IsString, ValidateNested } from 'class-validator';
import { SchulconnexErreichbarkeitenResponse } from './schulconnex-erreichbarkeiten-response';
import { SchulconnexGruppenResponse } from './schulconnex-gruppen-response';
import { SchulconnexOrganisationResponse } from './schulconnex-organisation-response';
import { SchulconnexResponseValidationGroups } from './schulconnex-response-validation-groups';
import { SchulconnexRole } from './schulconnex-role';

export class SchulconnexPersonenkontextResponse {
@IsString({ groups: [SchulconnexResponseValidationGroups.USER, SchulconnexResponseValidationGroups.GROUPS] })
id!: string;

@IsEnum(SchulconnexRole, { groups: [SchulconnexResponseValidationGroups.USER] })
rolle!: SchulconnexRole;
@IsString({ groups: [SchulconnexResponseValidationGroups.USER] })
rolle!: string;

@IsObject({ groups: [SchulconnexResponseValidationGroups.SCHOOL] })
@ValidateNested({ groups: [SchulconnexResponseValidationGroups.SCHOOL] })
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/infra/sync/tsp/tsp-oauth-data.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class TspOauthDataMapper {
});

const externalSchools = new Map<string, ExternalSchoolDto>();
const externalClasses = new Map<string, ExternalUserDto>();
const externalClasses = new Map<string, ExternalClassDto>();
const teacherForClasses = new Map<string, Array<string>>();
const oauthDataDtos: OauthDataDto[] = [];

Expand Down Expand Up @@ -85,9 +85,9 @@ export class TspOauthDataMapper {
});

const classIds = teacherForClasses.get(tspTeacher.lehrerUid) ?? [];
const classes = classIds
const classes: ExternalClassDto[] = classIds
.map((classId) => externalClasses.get(classId))
.filter((externalClass) => !!externalClass);
.filter((externalClass: ExternalClassDto | undefined): externalClass is ExternalClassDto => !!externalClass);

const externalSchool = tspTeacher.schuleNummer == null ? undefined : externalSchools.get(tspTeacher.schuleNummer);

Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/infra/sync/tsp/tsp-sync.strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { schoolFactory } from '@src/modules/school/testing';
import { System } from '@src/modules/system';
import { systemFactory } from '@src/modules/system/testing';
import { SyncStrategyTarget } from '../sync-strategy.types';
import { TspLegacyMigrationService } from './tsp-legacy-migration.service';
import { TspFetchService } from './tsp-fetch.service';
import { TspLegacyMigrationService } from './tsp-legacy-migration.service';
import { TspOauthDataMapper } from './tsp-oauth-data.mapper';
import { TspSyncConfig } from './tsp-sync.config';
import { TspSyncService } from './tsp-sync.service';
Expand Down Expand Up @@ -171,6 +171,7 @@ describe(TspSyncStrategy.name, () => {
}),
externalUser: new ExternalUserDto({
externalId: faker.string.alpha(),
roles: [],
}),
});
const tspTeacher: RobjExportLehrerMigration = {
Expand Down
31 changes: 0 additions & 31 deletions apps/server/src/migrations/mikro-orm/Migration20241112163538.ts

This file was deleted.

102 changes: 0 additions & 102 deletions apps/server/src/migrations/mikro-orm/Migration20241113152001.ts

This file was deleted.

15 changes: 0 additions & 15 deletions apps/server/src/migrations/mikro-orm/Migration20241127195120.ts

This file was deleted.

61 changes: 0 additions & 61 deletions apps/server/src/migrations/mikro-orm/Migration20241128155801.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export class AuthorizationContextBuilder {
return context;
}

static write(requiredPermissions: Permission[]): AuthorizationContext {
public static write(requiredPermissions: Permission[]): AuthorizationContext {
const context = this.build(requiredPermissions, Action.write);

return context;
}

static read(requiredPermissions: Permission[]): AuthorizationContext {
public static read(requiredPermissions: Permission[]): AuthorizationContext {
const context = this.build(requiredPermissions, Action.read);

return context;
Expand Down
Loading

0 comments on commit 07a775e

Please sign in to comment.