diff --git a/apps/server/src/infra/schulconnex-client/schulconnex-client-config.ts b/apps/server/src/infra/schulconnex-client/schulconnex-client-config.ts index 7663af52449..e7d5e6b23b6 100644 --- a/apps/server/src/infra/schulconnex-client/schulconnex-client-config.ts +++ b/apps/server/src/infra/schulconnex-client/schulconnex-client-config.ts @@ -1,5 +1,6 @@ export interface SchulconnexClientConfig { SCHULCONNEX_CLIENT__PERSONEN_INFO_TIMEOUT_IN_MS: number; + SCHULCONNEX_CLIENT__POLICIES_INFO_TIMEOUT_IN_MS: number; SCHULCONNEX_CLIENT__API_URL?: string; SCHULCONNEX_CLIENT__TOKEN_ENDPOINT?: string; SCHULCONNEX_CLIENT__CLIENT_ID?: string; diff --git a/apps/server/src/infra/schulconnex-client/schulconnex-client.module.ts b/apps/server/src/infra/schulconnex-client/schulconnex-client.module.ts index 11a6c3c8278..b16a7f55458 100644 --- a/apps/server/src/infra/schulconnex-client/schulconnex-client.module.ts +++ b/apps/server/src/infra/schulconnex-client/schulconnex-client.module.ts @@ -28,6 +28,7 @@ export class SchulconnexClientModule { clientId: configService.get('SCHULCONNEX_CLIENT__CLIENT_ID'), clientSecret: configService.get('SCHULCONNEX_CLIENT__CLIENT_SECRET'), personenInfoTimeoutInMs: configService.get('SCHULCONNEX_CLIENT__PERSONEN_INFO_TIMEOUT_IN_MS'), + policiesInfoTimeoutInMs: configService.get('SCHULCONNEX_CLIENT__POLICIES_INFO_TIMEOUT_IN_MS'), }; return new SchulconnexRestClient(options, httpService, oauthAdapterService, logger); }, diff --git a/apps/server/src/infra/schulconnex-client/schulconnex-rest-client-options.ts b/apps/server/src/infra/schulconnex-client/schulconnex-rest-client-options.ts index 9f47b1d5694..01391ec207e 100644 --- a/apps/server/src/infra/schulconnex-client/schulconnex-rest-client-options.ts +++ b/apps/server/src/infra/schulconnex-client/schulconnex-rest-client-options.ts @@ -8,4 +8,6 @@ export interface SchulconnexRestClientOptions { clientSecret?: string; personenInfoTimeoutInMs?: number; + + policiesInfoTimeoutInMs?: number; } diff --git a/apps/server/src/infra/schulconnex-client/schulconnex-rest-client.spec.ts b/apps/server/src/infra/schulconnex-client/schulconnex-rest-client.spec.ts index 7d802924304..5af753d8554 100644 --- a/apps/server/src/infra/schulconnex-client/schulconnex-rest-client.spec.ts +++ b/apps/server/src/infra/schulconnex-client/schulconnex-rest-client.spec.ts @@ -25,6 +25,8 @@ describe(SchulconnexRestClient.name, () => { clientId: 'clientId', clientSecret: 'clientSecret', tokenEndpoint: 'https://schulconnex.url/token', + personenInfoTimeoutInMs: 30000, + policiesInfoTimeoutInMs: 30000, }; beforeAll(() => { @@ -144,47 +146,31 @@ describe(SchulconnexRestClient.name, () => { }); const response: SchulconnexResponse[] = schulconnexResponseFactory.buildList(2); - const optionsWithTimeout: SchulconnexRestClientOptions = { - ...options, - personenInfoTimeoutInMs: 30000, - }; - - const optionsClient: SchulconnexRestClient = new SchulconnexRestClient( - optionsWithTimeout, - httpService, - oauthAdapterService, - logger - ); - oauthAdapterService.sendTokenRequest.mockResolvedValueOnce(tokens); httpService.get.mockReturnValueOnce(of(axiosResponseFactory.build({ data: response }))); return { tokens, response, - optionsClient, - optionsWithTimeout, }; }; it('should make a request to a SchulConneX-API', async () => { - const { tokens, optionsClient, optionsWithTimeout } = setup(); + const { tokens } = setup(); - await optionsClient.getPersonenInfo({ + await client.getPersonenInfo({ 'organisation.id': '1234', vollstaendig: ['personen', 'organisationen'], }); expect(httpService.get).toHaveBeenCalledWith( - `${ - optionsWithTimeout.apiUrl ?? '' - }/personen-info?organisation.id=1234&vollstaendig=personen%2Corganisationen`, + `${options.apiUrl ?? ''}/personen-info?organisation.id=1234&vollstaendig=personen%2Corganisationen`, { headers: { Authorization: `Bearer ${tokens.accessToken}`, 'Accept-Encoding': 'gzip', }, - timeout: optionsWithTimeout.personenInfoTimeoutInMs, + timeout: options.personenInfoTimeoutInMs, } ); }); @@ -223,6 +209,7 @@ describe(SchulconnexRestClient.name, () => { Authorization: `Bearer ${accessToken}`, 'Accept-Encoding': 'gzip', }, + timeout: options.policiesInfoTimeoutInMs, }); }); diff --git a/apps/server/src/infra/schulconnex-client/schulconnex-rest-client.ts b/apps/server/src/infra/schulconnex-client/schulconnex-rest-client.ts index 317bd1eca38..820668c16ce 100644 --- a/apps/server/src/infra/schulconnex-client/schulconnex-rest-client.ts +++ b/apps/server/src/infra/schulconnex-client/schulconnex-rest-client.ts @@ -62,7 +62,8 @@ export class SchulconnexRestClient implements SchulconnexApiInterface { const response: (SchulconnexPoliciesInfoLicenseResponse | SchulconnexPoliciesInfoErrorResponse)[] = await this.getRequest<(SchulconnexPoliciesInfoLicenseResponse | SchulconnexPoliciesInfoErrorResponse)[]>( url, - accessToken + accessToken, + this.options.policiesInfoTimeoutInMs ); const responseObject: SchulconnexPoliciesInfoResponse = { data: response }; diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index 8e33750addf..b79bca43b1f 100644 --- a/apps/server/src/modules/server/server.config.ts +++ b/apps/server/src/modules/server/server.config.ts @@ -274,6 +274,9 @@ const config: ServerConfig = { SCHULCONNEX_CLIENT__PERSONEN_INFO_TIMEOUT_IN_MS: Configuration.get( 'SCHULCONNEX_CLIENT__PERSONEN_INFO_TIMEOUT_IN_MS' ) as number, + SCHULCONNEX_CLIENT__POLICIES_INFO_TIMEOUT_IN_MS: Configuration.get( + 'SCHULCONNEX_CLIENT__POLICIES_INFO_TIMEOUT_IN_MS' + ) as number, FEATURE_SCHULCONNEX_COURSE_SYNC_ENABLED: Configuration.get('FEATURE_SCHULCONNEX_COURSE_SYNC_ENABLED') as boolean, ...getTldrawClientConfig(), FEATURE_MEDIA_SHELF_ENABLED: Configuration.get('FEATURE_MEDIA_SHELF_ENABLED') as boolean, diff --git a/config/default.schema.json b/config/default.schema.json index e65a77afc14..9b59ef6b422 100644 --- a/config/default.schema.json +++ b/config/default.schema.json @@ -1669,6 +1669,11 @@ "type": "integer", "description": "Timeout in milliseconds for fetching personen info from schulconnex", "default": 120000 + }, + "POLICIES_INFO_TIMEOUT_IN_MS": { + "type": "integer", + "description": "Timeout in milliseconds for fetching policies info from schulconnex", + "default": 4000 } }, "default": {