Skip to content

Commit

Permalink
feat(api): update usecase identity access management
Browse files Browse the repository at this point in the history
  • Loading branch information
xav-car committed Dec 4, 2024
1 parent c82ad8e commit f9bcc75
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {{
* temporaryKey: string,
* accountRecoveryDemandRepository: AccountRecoveryDemandRepository,
* organizationLearnerRepository: OrganizationLearnerRepository,
* prescriptionOrganizationLearnerRepository: PrescriptionOrganizationLearnerRepository,
* userRepository: UserRepository,
* scoAccountRecoveryService: ScoAccountRecoveryService,
* }} params
Expand All @@ -11,7 +11,7 @@
export const getAccountRecoveryDetails = async function ({
temporaryKey,
accountRecoveryDemandRepository,
organizationLearnerRepository,
prescriptionOrganizationLearnerRepository,
userRepository,
scoAccountRecoveryService,
}) {
Expand All @@ -22,7 +22,7 @@ export const getAccountRecoveryDetails = async function ({
userRepository,
});

const { firstName } = await organizationLearnerRepository.get(organizationLearnerId);
const { firstName } = await prescriptionOrganizationLearnerRepository.getLearnerInfo(organizationLearnerId);

return {
id,
Expand Down
2 changes: 2 additions & 0 deletions api/src/identity-access-management/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as campaignRepository from '../../../../lib/infrastructure/repositories
import * as organizationLearnerRepository from '../../../../lib/infrastructure/repositories/organization-learner-repository.js';
import * as userRecommendedTrainingRepository from '../../../devcomp/infrastructure/repositories/user-recommended-training-repository.js';
import { repositories as campaignRepositories } from '../../../prescription/campaign/infrastructure/repositories/index.js';
import * as prescriptionOrganizationLearnerRepository from '../../../prescription/learner-management/infrastructure/repositories/organization-learner-repository.js';
import { config } from '../../../shared/config.js';
import { cryptoService } from '../../../shared/domain/services/crypto-service.js';
import { tokenService } from '../../../shared/domain/services/token-service.js';
Expand Down Expand Up @@ -59,6 +60,7 @@ const repositories = {
membershipRepository,
oidcProviderRepository,
organizationLearnerRepository,
prescriptionOrganizationLearnerRepository,
privacyUsersApiRepository,
refreshTokenRepository,
resetPasswordDemandRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ describe('Unit | Identity Access Management | Domain | UseCase | get-account-rec
it('returns new email and firstName of account recovery demand', async function () {
// given
const temporaryKey = 'ZHABCDEFJSJ';
const organizationLearnerRepository = {
get: sinon.stub(),
const prescriptionOrganizationLearnerRepository = {
getLearnerInfo: sinon.stub(),
};
const scoAccountRecoveryService = {
retrieveAndValidateAccountRecoveryDemand: sinon.stub(),
Expand All @@ -16,12 +16,12 @@ describe('Unit | Identity Access Management | Domain | UseCase | get-account-rec
const firstName = 'Emma';

scoAccountRecoveryService.retrieveAndValidateAccountRecoveryDemand.resolves({ organizationLearnerId, newEmail });
organizationLearnerRepository.get.withArgs(organizationLearnerId).resolves({ firstName });
prescriptionOrganizationLearnerRepository.getLearnerInfo.withArgs(organizationLearnerId).resolves({ firstName });

// when
const result = await getAccountRecoveryDetails({
temporaryKey,
organizationLearnerRepository,
prescriptionOrganizationLearnerRepository,
scoAccountRecoveryService,
});

Expand Down

0 comments on commit f9bcc75

Please sign in to comment.