-
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
* handle policies-info error responses * fix everything --------- Co-authored-by: Marvin Öhlerking <[email protected]>
- Loading branch information
1 parent
6d86aa1
commit 2eba077
Showing
38 changed files
with
403 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
export { SchulconnexRestClientOptions } from './schulconnex-rest-client-options'; | ||
export { SchulconnexClientModule } from './schulconnex-client.module'; | ||
export { SchulconnexRestClient } from './schulconnex-rest-client'; | ||
export * from './response'; | ||
export { schulconnexResponseFactory, schulconnexPoliciesInfoResponseFactory } from './testing'; | ||
export { SchulconnexClientConfig } from './schulconnex-client-config'; |
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
13 changes: 13 additions & 0 deletions
13
...connex-client/response/policies-info/schulconnex-policies-info-access-control-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Type } from 'class-transformer'; | ||
import { IsObject, IsString, ValidateNested } from 'class-validator'; | ||
import { SchulconnexPoliciesInfoErrorDescriptionResponse } from './schulconnex-policies-info-error-description-response'; | ||
|
||
export class SchulconnexPoliciesInfoAccessControlResponse { | ||
@IsString() | ||
'@type'!: string; | ||
|
||
@IsObject() | ||
@ValidateNested() | ||
@Type(() => SchulconnexPoliciesInfoErrorDescriptionResponse) | ||
error!: SchulconnexPoliciesInfoErrorDescriptionResponse; | ||
} |
9 changes: 9 additions & 0 deletions
9
...nex-client/response/policies-info/schulconnex-policies-info-error-description-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { IsString } from 'class-validator'; | ||
|
||
export class SchulconnexPoliciesInfoErrorDescriptionResponse { | ||
@IsString() | ||
code!: string; | ||
|
||
@IsString() | ||
value!: string; | ||
} |
10 changes: 10 additions & 0 deletions
10
...fra/schulconnex-client/response/policies-info/schulconnex-policies-info-error-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Type } from 'class-transformer'; | ||
import { IsObject, ValidateNested } from 'class-validator'; | ||
import { SchulconnexPoliciesInfoAccessControlResponse } from './schulconnex-policies-info-access-control-response'; | ||
|
||
export class SchulconnexPoliciesInfoErrorResponse { | ||
@IsObject() | ||
@ValidateNested() | ||
@Type(() => SchulconnexPoliciesInfoAccessControlResponse) | ||
access_control!: SchulconnexPoliciesInfoAccessControlResponse; | ||
} |
16 changes: 16 additions & 0 deletions
16
...a/schulconnex-client/response/policies-info/schulconnex-policies-info-license-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Type } from 'class-transformer'; | ||
import { IsArray, IsObject, ValidateNested } from 'class-validator'; | ||
import { SchulconnexPoliciesInfoPermissionResponse } from './schulconnex-policies-info-permission-response'; | ||
import { SchulconnexPoliciesInfoTargetResponse } from './schulconnex-policies-info-target-response'; | ||
|
||
export class SchulconnexPoliciesInfoLicenseResponse { | ||
@IsObject() | ||
@ValidateNested() | ||
@Type(() => SchulconnexPoliciesInfoTargetResponse) | ||
target!: SchulconnexPoliciesInfoTargetResponse; | ||
|
||
@IsArray() | ||
@ValidateNested({ each: true }) | ||
@Type(() => SchulconnexPoliciesInfoPermissionResponse) | ||
permission!: SchulconnexPoliciesInfoPermissionResponse[]; | ||
} |
3 changes: 2 additions & 1 deletion
3
...chulconnex-client/response/policies-info/schulconnex-policies-info-permission-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { IsArray } from 'class-validator'; | ||
import { IsArray, IsString } from 'class-validator'; | ||
import { SchulconnexPoliciesInfoActionType } from './schulconnex-policies-info-action-type'; | ||
|
||
export class SchulconnexPoliciesInfoPermissionResponse { | ||
@IsArray() | ||
@IsString({ each: true }) | ||
action!: SchulconnexPoliciesInfoActionType[]; | ||
} |
25 changes: 14 additions & 11 deletions
25
...src/infra/schulconnex-client/response/policies-info/schulconnex-policies-info-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import { Type } from 'class-transformer'; | ||
import { IsArray, IsObject, ValidateNested } from 'class-validator'; | ||
import { SchulconnexPoliciesInfoPermissionResponse } from './schulconnex-policies-info-permission-response'; | ||
import { SchulconnexPoliciesInfoTargetResponse } from './schulconnex-policies-info-target-response'; | ||
import { PolymorphicArrayTransform } from '@shared/controller'; | ||
import { ClassConstructor } from 'class-transformer'; | ||
import { IsArray, ValidateNested } from 'class-validator'; | ||
import { SchulconnexPoliciesInfoErrorResponse } from './schulconnex-policies-info-error-response'; | ||
import { SchulconnexPoliciesInfoLicenseResponse } from './schulconnex-policies-info-license-response'; | ||
|
||
export class SchulconnexPoliciesInfoResponse { | ||
@IsObject() | ||
@ValidateNested() | ||
@Type(() => SchulconnexPoliciesInfoTargetResponse) | ||
target!: SchulconnexPoliciesInfoTargetResponse; | ||
const policiesInfoDiscriminator = ( | ||
obj: unknown | ||
): ClassConstructor<SchulconnexPoliciesInfoLicenseResponse | SchulconnexPoliciesInfoErrorResponse> => | ||
typeof obj === 'object' && obj !== null && 'target' in obj && 'permission' in obj | ||
? SchulconnexPoliciesInfoLicenseResponse | ||
: SchulconnexPoliciesInfoErrorResponse; | ||
|
||
export class SchulconnexPoliciesInfoResponse { | ||
@IsArray() | ||
@ValidateNested({ each: true }) | ||
@Type(() => SchulconnexPoliciesInfoPermissionResponse) | ||
permission!: SchulconnexPoliciesInfoPermissionResponse[]; | ||
@PolymorphicArrayTransform(policiesInfoDiscriminator) | ||
data!: (SchulconnexPoliciesInfoLicenseResponse | SchulconnexPoliciesInfoErrorResponse)[]; | ||
} |
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
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
export { schulconnexResponseFactory } from './schulconnex-response-factory'; | ||
export { schulconnexPoliciesInfoResponseFactory } from './schulconnex-policies-info-response-factory'; | ||
export { | ||
schulconnexPoliciesInfoLicenseResponseFactory, | ||
schulconnexPoliciesInfoErrorResponseFactory, | ||
schulconnexPoliciesInfoResponseFactory, | ||
} from './schulconnex-policies-info-response.factory'; |
16 changes: 0 additions & 16 deletions
16
...server/src/infra/schulconnex-client/testing/schulconnex-policies-info-response-factory.ts
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
...server/src/infra/schulconnex-client/testing/schulconnex-policies-info-response.factory.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,41 @@ | ||
import { Factory } from 'fishery'; | ||
import { | ||
SchulconnexPoliciesInfoActionType, | ||
SchulconnexPoliciesInfoErrorResponse, | ||
SchulconnexPoliciesInfoLicenseResponse, | ||
SchulconnexPoliciesInfoResponse, | ||
} from '../response'; | ||
|
||
export const schulconnexPoliciesInfoLicenseResponseFactory = Factory.define<SchulconnexPoliciesInfoLicenseResponse>( | ||
() => { | ||
return { | ||
target: { | ||
uid: 'bildungscloud', | ||
partOf: '', | ||
}, | ||
permission: [ | ||
{ | ||
action: [SchulconnexPoliciesInfoActionType.EXECUTE], | ||
}, | ||
], | ||
}; | ||
} | ||
); | ||
|
||
export const schulconnexPoliciesInfoErrorResponseFactory = Factory.define<SchulconnexPoliciesInfoErrorResponse>(() => { | ||
return { | ||
access_control: { | ||
'@type': 'bilo error mock', | ||
error: { | ||
code: '500', | ||
value: 'something went wrong', | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
export const schulconnexPoliciesInfoResponseFactory = Factory.define<SchulconnexPoliciesInfoResponse>(() => { | ||
return { | ||
data: [schulconnexPoliciesInfoLicenseResponseFactory.build(), schulconnexPoliciesInfoErrorResponseFactory.build()], | ||
}; | ||
}); |
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
3 changes: 2 additions & 1 deletion
3
apps/server/src/modules/idp-console/uc/synchronization.uc.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './oauth.module'; | ||
export * from './interface'; | ||
export * from './service'; |
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
31 changes: 31 additions & 0 deletions
31
apps/server/src/modules/provisioning/loggable/policies-info-error-response-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { SchulconnexPoliciesInfoErrorResponse } from '@infra/schulconnex-client'; | ||
import { schulconnexPoliciesInfoErrorResponseFactory } from '@infra/schulconnex-client/testing'; | ||
import { PoliciesInfoErrorResponseLoggable } from './policies-info-error-response-loggable'; | ||
|
||
describe(PoliciesInfoErrorResponseLoggable.name, () => { | ||
describe('getLogMessage', () => { | ||
const setup = () => { | ||
const errorResponse: SchulconnexPoliciesInfoErrorResponse = schulconnexPoliciesInfoErrorResponseFactory.build(); | ||
|
||
const loggable: PoliciesInfoErrorResponseLoggable = new PoliciesInfoErrorResponseLoggable(errorResponse); | ||
|
||
return { | ||
loggable, | ||
errorResponse, | ||
}; | ||
}; | ||
|
||
it('should return the correct log message', () => { | ||
const { loggable, errorResponse } = setup(); | ||
|
||
expect(loggable.getLogMessage()).toEqual({ | ||
message: 'The /policies-info endpoint returned an error for a media source.', | ||
data: { | ||
type: errorResponse.access_control['@type'], | ||
code: errorResponse.access_control.error.code, | ||
value: errorResponse.access_control.error.value, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
apps/server/src/modules/provisioning/loggable/policies-info-error-response-loggable.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,17 @@ | ||
import { SchulconnexPoliciesInfoErrorResponse } from '@infra/schulconnex-client'; | ||
import { Loggable, LoggableMessage } from '@shared/common/loggable/interfaces'; | ||
|
||
export class PoliciesInfoErrorResponseLoggable implements Loggable { | ||
constructor(private readonly item: SchulconnexPoliciesInfoErrorResponse) {} | ||
|
||
getLogMessage(): LoggableMessage { | ||
return { | ||
message: 'The /policies-info endpoint returned an error for a media source.', | ||
data: { | ||
type: this.item.access_control['@type'], | ||
code: this.item.access_control.error.code, | ||
value: this.item.access_control.error.value, | ||
}, | ||
}; | ||
} | ||
} |
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
1 change: 0 additions & 1 deletion
1
apps/server/src/modules/provisioning/strategy/loggable/index.ts
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './sanis.strategy'; | ||
export { SanisProvisioningStrategy } from './sanis.strategy'; | ||
export { SchulconnexResponseMapper } from './schulconnex-response-mapper'; |
Oops, something went wrong.