-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
a9842f2
commit 4da6d99
Showing
46 changed files
with
287 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
apps/server/src/infra/schulconnex-client/response/schulconnex-personenkontext-response.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
apps/server/src/modules/provisioning/dto/external-user.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
apps/server/src/modules/provisioning/loggable/fetching-policies-info-failed.loggable.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
apps/server/src/modules/provisioning/loggable/school-missing.loggable-exception.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { externalUserDtoFactory } from '../testing'; | ||
import { SchoolMissingLoggableException } from './school-missing.loggable-exception'; | ||
|
||
describe(SchoolMissingLoggableException.name, () => { | ||
describe('getLogMessage', () => { | ||
const setup = () => { | ||
const externalUser = externalUserDtoFactory.build(); | ||
|
||
const loggable = new SchoolMissingLoggableException(externalUser); | ||
|
||
return { | ||
loggable, | ||
externalUser, | ||
}; | ||
}; | ||
|
||
it('should return a loggable message', () => { | ||
const { loggable, externalUser } = setup(); | ||
|
||
const message = loggable.getLogMessage(); | ||
|
||
expect(message).toEqual({ | ||
type: 'SCHOOL_MISSING', | ||
stack: expect.any(String), | ||
message: 'Unable to create new external user without a school', | ||
data: { | ||
externalUserId: externalUser.externalId, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
apps/server/src/modules/provisioning/loggable/school-missing.loggable-exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { HttpStatus } from '@nestjs/common'; | ||
import { BusinessError } from '@shared/common'; | ||
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger'; | ||
import { ExternalUserDto } from '../dto'; | ||
|
||
export class SchoolMissingLoggableException extends BusinessError implements Loggable { | ||
constructor(private readonly externalUser: ExternalUserDto) { | ||
super( | ||
{ | ||
type: 'SCHOOL_MISSING', | ||
title: 'Invalid school data', | ||
defaultMessage: 'Unable to create new external user without a school', | ||
}, | ||
HttpStatus.UNPROCESSABLE_ENTITY | ||
); | ||
} | ||
|
||
public getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage { | ||
return { | ||
type: this.type, | ||
message: this.message, | ||
stack: this.stack, | ||
data: { | ||
externalUserId: this.externalUser.externalId, | ||
}, | ||
}; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
apps/server/src/modules/provisioning/loggable/user-role-unknown.loggable-exception.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { externalUserDtoFactory } from '../testing'; | ||
import { UserRoleUnknownLoggableException } from './user-role-unknown.loggable-exception'; | ||
|
||
describe(UserRoleUnknownLoggableException.name, () => { | ||
describe('getLogMessage', () => { | ||
const setup = () => { | ||
const externalUser = externalUserDtoFactory.build(); | ||
|
||
const loggable = new UserRoleUnknownLoggableException(externalUser); | ||
|
||
return { | ||
loggable, | ||
externalUser, | ||
}; | ||
}; | ||
|
||
it('should return a loggable message', () => { | ||
const { loggable, externalUser } = setup(); | ||
|
||
const message = loggable.getLogMessage(); | ||
|
||
expect(message).toEqual({ | ||
type: 'EXTERNAL_USER_ROLE_UNKNOWN', | ||
stack: expect.any(String), | ||
message: 'External user has no or no known role assigned to them', | ||
data: { | ||
externalUserId: externalUser.externalId, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
apps/server/src/modules/provisioning/loggable/user-role-unknown.loggable-exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { HttpStatus } from '@nestjs/common'; | ||
import { BusinessError } from '@shared/common'; | ||
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger'; | ||
import { ExternalUserDto } from '../dto'; | ||
|
||
export class UserRoleUnknownLoggableException extends BusinessError implements Loggable { | ||
constructor(private readonly externalUser: ExternalUserDto) { | ||
super( | ||
{ | ||
type: 'EXTERNAL_USER_ROLE_UNKNOWN', | ||
title: 'Invalid user role', | ||
defaultMessage: 'External user has no or no known role assigned to them', | ||
}, | ||
HttpStatus.UNPROCESSABLE_ENTITY | ||
); | ||
} | ||
|
||
public getLogMessage(): LogMessage | ErrorLogMessage | ValidationErrorLogMessage { | ||
return { | ||
type: this.type, | ||
message: this.message, | ||
stack: this.stack, | ||
data: { | ||
externalUserId: this.externalUser.externalId, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.