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

N21-1968 schulconnex config fix #5002

Merged
merged 5 commits into from
May 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
N21-1968 adds test
arnegns committed May 14, 2024
commit 27c2ecd876b17fa36d31ef7fdf3c32b0f75b2120
Original file line number Diff line number Diff line change
@@ -41,8 +41,8 @@ describe(SchulconnexRestClient.name, () => {
const setup = () => {
const badOptions: SchulconnexRestClientOptions = {
apiUrl: '',
clientId: '',
clientSecret: '',
clientId: undefined,
clientSecret: undefined,
tokenEndpoint: '',
};
return {
@@ -58,6 +58,16 @@ describe(SchulconnexRestClient.name, () => {

expect(logger.debug).toHaveBeenCalledWith(new SchulconnexConfigurationMissingLoggable());
});

it('should reject promise if configuration is missing', async () => {
const { badOptions } = setup();

const badOptionsClient = new SchulconnexRestClient(badOptions, httpService, oauthAdapterService, logger);

await expect(badOptionsClient.getPersonenInfo({})).rejects.toThrow(
'Missing configuration for SchulconnexRestClient'
);
});
});
});

@@ -80,7 +90,7 @@ describe(SchulconnexRestClient.name, () => {

await client.getPersonInfo(accessToken);

expect(httpService.get).toHaveBeenCalledWith(`${options.apiUrl}/person-info`, {
expect(httpService.get).toHaveBeenCalledWith(`${options.apiUrl ?? ''}/person-info`, {
headers: {
Authorization: `Bearer ${accessToken}`,
'Accept-Encoding': 'gzip',
@@ -163,7 +173,9 @@ describe(SchulconnexRestClient.name, () => {
});

expect(httpService.get).toHaveBeenCalledWith(
`${optionsWithTimeout.apiUrl}/personen-info?organisation.id=1234&vollstaendig=personen%2Corganisationen`,
`${
optionsWithTimeout.apiUrl ?? ''
}/personen-info?organisation.id=1234&vollstaendig=personen%2Corganisationen`,
{
headers: {
Authorization: `Bearer ${tokens.accessToken}`,
@@ -202,7 +214,7 @@ describe(SchulconnexRestClient.name, () => {

await client.getLizenzInfo(accessToken);

expect(httpService.get).toHaveBeenCalledWith(`${options.apiUrl}/lizenz-info`, {
expect(httpService.get).toHaveBeenCalledWith(`${options.apiUrl ?? ''}/lizenz-info`, {
headers: {
Authorization: `Bearer ${accessToken}`,
'Accept-Encoding': 'gzip',
Loading