Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap committed Jan 15, 2024
1 parent fde6ac7 commit 2e3bcd5
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
TestApiClient,
UserAndAccountTestFactory,
} from '@shared/testing';
import { ltiToolFactory } from '@shared/testing/factory/ltitool.factory';
import { pseudonymEntityFactory } from '@shared/testing/factory/pseudonym.factory';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import {
Expand Down Expand Up @@ -343,7 +345,7 @@ describe(OauthProviderController.name, () => {
challenge,
});
const redirectResponse: ProviderRedirectResponse = { redirect_to: 'redirect' };
const externalTool = externalToolEntityFactory.withOauth2Config(loginResponse.client.client_id).buildWithId();
const ltiTool = ltiToolFactory.buildWithId({ oAuthClientId: loginResponse.client.client_id });
const { studentAccount, studentUser } = UserAndAccountTestFactory.buildStudent();

axiosMock
Expand All @@ -352,7 +354,7 @@ describe(OauthProviderController.name, () => {
.onPut(`${hydraUri}/oauth2/auth/requests/login/accept?login_challenge=${challenge}`)
.replyOnce<ProviderRedirectResponse>(HttpStatus.OK, redirectResponse);

await em.persistAndFlush([studentAccount, studentUser, externalTool]);
await em.persistAndFlush([studentAccount, studentUser, ltiTool]);
em.clear();

const loggedInClient = await testApiClient.login(studentAccount);
Expand Down Expand Up @@ -486,9 +488,9 @@ describe(OauthProviderController.name, () => {
subject: studentUser.id,
});
const redirectResponse: ProviderRedirectResponse = { redirect_to: 'redirect' };
const externalTool = externalToolEntityFactory.withOauth2Config(consentResponse.client.client_id).buildWithId();
const pseudonym = externalToolPseudonymEntityFactory.buildWithId({
toolId: externalTool.id,
const ltiTool = ltiToolFactory.buildWithId({ oAuthClientId: consentResponse.client.client_id });
const pseudonym = pseudonymEntityFactory.buildWithId({
toolId: ltiTool.id,
userId: studentUser.id,
});

Expand All @@ -498,7 +500,7 @@ describe(OauthProviderController.name, () => {
.onPut(`${hydraUri}/oauth2/auth/requests/consent/accept?consent_challenge=${challenge}`)
.replyOnce<ProviderRedirectResponse>(HttpStatus.OK, redirectResponse);

await em.persistAndFlush([studentAccount, studentUser, externalTool, pseudonym]);
await em.persistAndFlush([studentAccount, studentUser, ltiTool, pseudonym]);
em.clear();

const loggedInClient = await testApiClient.login(studentAccount);
Expand Down

0 comments on commit 2e3bcd5

Please sign in to comment.