From fe67842546e0fc4bc8983f9eb922bc564af57bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Burkard?= Date: Wed, 15 Jan 2025 11:20:59 +0100 Subject: [PATCH] rename Pe to Ft --- .../addConventionAndSendMails.e2e.test.ts | 10 +- .../createFtConnectRouter.ts} | 16 +- back/src/config/bootstrap/createGateways.ts | 16 +- back/src/config/bootstrap/createUseCases.ts | 2 +- back/src/config/bootstrap/server.ts | 4 +- .../helpers/createAxiosSharedClients.ts | 2 +- .../helpers/createFetchSharedClients.ts | 2 +- back/src/config/pg/kysely/model/database.ts | 4 +- .../HttpFtAgenciesReferential.manual.test.ts} | 10 +- .../HttpFtAgenciesReferential.ts} | 14 +- .../HttpRome3Gateway.manual.test.ts | 4 +- .../HttpRome3Gateway.ts | 4 +- .../HttpRome4Gateway.manual.test.ts | 4 +- .../HttpRome4Gateway.ts | 6 +- .../InMemoryFtAgenciesReferential.ts | 16 ++ .../InMemoryPeAgenciesReferential.ts | 16 -- ...PgConventionRepository.integration.test.ts | 20 +-- .../FrancetTravailRoutes.ts | 10 +- .../HttpFranceTravailGateway.manual.test.ts | 24 +-- .../convention/ports/FranceTravailGateway.ts | 4 +- .../use-cases/GetConvention.unit.test.ts | 14 +- ... => ResyncOldConventionsToFt.unit.test.ts} | 40 ++--- ...nceTravailOnConventionUpdates.unit.test.ts | 14 +- ...ifyAllActorsOfFinalConventionValidation.ts | 10 +- ...rsOfFinalConventionValidation.unit.test.ts | 10 +- ...otifyNewConventionNeedsReview.unit.test.ts | 148 +++++++++--------- ...fyToAgencyConventionSubmitted.unit.test.ts | 32 ++-- ...onventionFranceTravailAdvisorRepository.ts | 8 +- ...availAdvisorRepository.integration.test.ts | 12 +- .../HttpFtConnectGateway.manual.test.ts | 122 +++++++-------- .../HttpFtConnectGateway.ts | 78 +++++---- ...Gateway.ts => InMemoryFtConnectGateway.ts} | 8 +- .../ft-connect-gateway/ftConnectApi.error.ts | 22 +-- .../ft-connect-gateway/ftConnectApi.routes.ts | 56 +++---- .../ft-connect-gateway/ftConnectApi.schema.ts | 16 +- .../ft-connect/dto/FtConnect.dto.ts | 2 +- .../BindConventionToFederatedIdentity.ts | 8 +- ...ConventionToFederatedIdentity.unit.test.ts | 32 ++-- ...ceTravailAdvisorAndRedirectToConvention.ts | 8 +- ...dvisorAndRedirectToConvention.unit.test.ts | 20 +-- ...availUserAdvisorOnConventionFullySigned.ts | 12 +- ...dvisorOnConventionFullySigned.unit.test.ts | 8 +- .../HttpLaBonneBoiteGateway.manual.test.ts | 4 +- ...eferential.ts => FtAgenciesReferential.ts} | 6 +- .../triggerResyncOldConventionsToPe.ts | 4 +- back/src/scripts/triggerUpdateLegacyRomeV3.ts | 6 +- back/src/scripts/triggerUpdateRomeData.ts | 6 +- back/src/utils/buildTestApp.ts | 4 +- back/src/utils/logger.ts | 2 +- .../forms/convention/ConventionForm.tsx | 8 +- .../convention/ConventionImmersionPage.tsx | 4 +- .../convention/InitiateConventionPage.tsx | 4 +- .../src/app/routes/routeParams/convention.ts | 4 +- shared/src/convention/ConventionDtoBuilder.ts | 4 +- shared/src/convention/convention.dto.ts | 4 +- .../federatedIdentity.dto.ts | 14 +- .../federatedIdentity.schema.ts | 4 +- shared/src/routes/routes.ts | 4 +- 58 files changed, 472 insertions(+), 478 deletions(-) rename back/src/adapters/primary/routers/{peConnect/createPeConnectRouter.ts => ftConnect/createFtConnectRouter.ts} (68%) rename back/src/domains/agency/adapters/{pe-agencies-referential/HttpPeAgenciesReferential.manual.test.ts => ft-agencies-referential/HttpFtAgenciesReferential.manual.test.ts} (76%) rename back/src/domains/agency/adapters/{pe-agencies-referential/HttpPeAgenciesReferential.ts => ft-agencies-referential/HttpFtAgenciesReferential.ts} (77%) rename back/src/domains/agency/adapters/{pe-agencies-referential => ft-agencies-referential}/HttpRome3Gateway.manual.test.ts (94%) rename back/src/domains/agency/adapters/{pe-agencies-referential => ft-agencies-referential}/HttpRome3Gateway.ts (94%) rename back/src/domains/agency/adapters/{pe-agencies-referential => ft-agencies-referential}/HttpRome4Gateway.manual.test.ts (95%) rename back/src/domains/agency/adapters/{pe-agencies-referential => ft-agencies-referential}/HttpRome4Gateway.ts (93%) create mode 100644 back/src/domains/agency/adapters/ft-agencies-referential/InMemoryFtAgenciesReferential.ts delete mode 100644 back/src/domains/agency/adapters/pe-agencies-referential/InMemoryPeAgenciesReferential.ts rename back/src/domains/convention/use-cases/{ResyncOldConventionsToPe.unit.test.ts => ResyncOldConventionsToFt.unit.test.ts} (93%) rename back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/{InMemoryPeConnectGateway.ts => InMemoryFtConnectGateway.ts} (84%) rename back/src/domains/establishment/ports/{PeAgenciesReferential.ts => FtAgenciesReferential.ts} (76%) diff --git a/back/src/adapters/primary/routers/convention/addConventionAndSendMails.e2e.test.ts b/back/src/adapters/primary/routers/convention/addConventionAndSendMails.e2e.test.ts index 8d4a22ba9f..95761fe4ce 100644 --- a/back/src/adapters/primary/routers/convention/addConventionAndSendMails.e2e.test.ts +++ b/back/src/adapters/primary/routers/convention/addConventionAndSendMails.e2e.test.ts @@ -221,11 +221,11 @@ describe("Add Convention Notifications, then checks the mails are sent (trigerre await processEventsForEmailToBeSent(eventCrawler); expect(inMemoryUow.notificationRepository.notifications).toHaveLength(3); - const peNotification = gateways.franceTravailGateway.notifications[0]; - expect(peNotification.id).toBe(externalId); - expectToEqual(peNotification.statut, "DEMANDE_A_SIGNER"); - expect(peNotification.originalId).toBe(convention.id); - expect(peNotification.email).toBe(convention.signatories.beneficiary.email); + const ftNotification = gateways.franceTravailGateway.notifications[0]; + expect(ftNotification.id).toBe(externalId); + expectToEqual(ftNotification.statut, "DEMANDE_A_SIGNER"); + expect(ftNotification.originalId).toBe(convention.id); + expect(ftNotification.email).toBe(convention.signatories.beneficiary.email); const sentEmails = gateways.notification.getSentEmails(); expect(sentEmails).toHaveLength(numberOfEmailInitialySent - 1); expectArraysToEqualIgnoringOrder( diff --git a/back/src/adapters/primary/routers/peConnect/createPeConnectRouter.ts b/back/src/adapters/primary/routers/ftConnect/createFtConnectRouter.ts similarity index 68% rename from back/src/adapters/primary/routers/peConnect/createPeConnectRouter.ts rename to back/src/adapters/primary/routers/ftConnect/createFtConnectRouter.ts index fe266f490c..eed82d139c 100644 --- a/back/src/adapters/primary/routers/peConnect/createPeConnectRouter.ts +++ b/back/src/adapters/primary/routers/ftConnect/createFtConnectRouter.ts @@ -1,24 +1,24 @@ import { Router } from "express"; -import { ManagedRedirectError, loginPeConnect, peConnect } from "shared"; +import { ManagedRedirectError, ftConnect, loginFtConnect } from "shared"; import { AppDependencies } from "../../../../config/bootstrap/createAppDependencies"; import { sendRedirectResponseWithManagedErrors } from "../../../../config/helpers/sendRedirectResponseWithManagedErrors"; -import { makePeConnectLoginPageUrl } from "../../../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes"; +import { makeFtConnectLoginPageUrl } from "../../../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes"; -export const createPeConnectRouter = (deps: AppDependencies) => { - const peConnectRouter = Router({ mergeParams: true }); +export const createFtConnectRouter = (deps: AppDependencies) => { + const ftConnectRouter = Router({ mergeParams: true }); - peConnectRouter.route(`/${loginPeConnect}`).get(async (req, res) => + ftConnectRouter.route(`/${loginFtConnect}`).get(async (req, res) => sendRedirectResponseWithManagedErrors( req, res, - async () => makePeConnectLoginPageUrl(deps.config), + async () => makeFtConnectLoginPageUrl(deps.config), deps.errorHandlers.handleManagedRedirectResponseError, deps.errorHandlers.handleRawRedirectResponseError, ), ); - peConnectRouter.route(`/${peConnect}`).get(async (req, res) => + ftConnectRouter.route(`/${ftConnect}`).get(async (req, res) => sendRedirectResponseWithManagedErrors( req, res, @@ -35,5 +35,5 @@ export const createPeConnectRouter = (deps: AppDependencies) => { ), ); - return peConnectRouter; + return ftConnectRouter; }; diff --git a/back/src/config/bootstrap/createGateways.ts b/back/src/config/bootstrap/createGateways.ts index 84b2267752..accdde5cae 100644 --- a/back/src/config/bootstrap/createGateways.ts +++ b/back/src/config/bootstrap/createGateways.ts @@ -13,8 +13,8 @@ import { InMemoryAddressGateway } from "../../domains/core/address/adapters/InMe import { HttpSubscribersGateway } from "../../domains/core/api-consumer/adapters/HttpSubscribersGateway"; import { InMemorySubscribersGateway } from "../../domains/core/api-consumer/adapters/InMemorySubscribersGateway"; import { HttpFtConnectGateway } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway"; -import { InMemoryPeConnectGateway } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryPeConnectGateway"; -import { makePeConnectExternalRoutes } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes"; +import { InMemoryFtConnectGateway } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryFtConnectGateway"; +import { makeFtConnectExternalRoutes } from "../../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes"; import { FtConnectGateway } from "../../domains/core/authentication/ft-connect/port/FtConnectGateway"; import { HttpOAuthGateway } from "../../domains/core/authentication/inclusion-connect/adapters/oauth-gateway/HttpOAuthGateway"; import { InMemoryOAuthGateway } from "../../domains/core/authentication/inclusion-connect/adapters/oauth-gateway/InMemoryOAuthGateway"; @@ -188,14 +188,14 @@ export const createGateways = async ( const { withCache, disconnectCache } = await getWithCache(config); - const peConnectGateway: FtConnectGateway = + const ftConnectGateway: FtConnectGateway = config.ftConnectGateway === "HTTPS" ? new HttpFtConnectGateway( createLegacyAxiosHttpClientForExternalAPIs({ partnerName: partnerNames.franceTravailConnect, - routes: makePeConnectExternalRoutes({ - peApiUrl: config.ftApiUrl, - peAuthCandidatUrl: config.ftAuthCandidatUrl, + routes: makeFtConnectExternalRoutes({ + ftApiUrl: config.ftApiUrl, + ftAuthCandidatUrl: config.ftAuthCandidatUrl, }), }), { @@ -204,7 +204,7 @@ export const createGateways = async ( franceTravailClientSecret: config.franceTravailClientSecret, }, ) - : new InMemoryPeConnectGateway(); + : new InMemoryFtConnectGateway(); const oAuthGateway: OAuthGateway = config.inclusionConnectGateway === "HTTPS" @@ -412,7 +412,7 @@ export const createGateways = async ( ? new HttpPassEmploiGateway(config.passEmploiUrl, config.passEmploiKey) : new InMemoryPassEmploiGateway(), pdfGeneratorGateway: createPdfGeneratorGateway(), - peConnectGateway, + ftConnectGateway, franceTravailGateway, timeGateway, establishmentMarketingGateway: diff --git a/back/src/config/bootstrap/createUseCases.ts b/back/src/config/bootstrap/createUseCases.ts index 5a833898d6..c977754c8d 100644 --- a/back/src/config/bootstrap/createUseCases.ts +++ b/back/src/config/bootstrap/createUseCases.ts @@ -281,7 +281,7 @@ export const createUseCases = ( linkFranceTravailAdvisorAndRedirectToConvention: new LinkFranceTravailAdvisorAndRedirectToConvention( uowPerformer, - gateways.peConnectGateway, + gateways.ftConnectGateway, config.immersionFacileBaseUrl, ), diff --git a/back/src/config/bootstrap/server.ts b/back/src/config/bootstrap/server.ts index 829ffa95f8..d0474d2f4a 100644 --- a/back/src/config/bootstrap/server.ts +++ b/back/src/config/bootstrap/server.ts @@ -10,10 +10,10 @@ import { createConventionRouter } from "../../adapters/primary/routers/conventio import { createEstablishmentRouter } from "../../adapters/primary/routers/establishment/createEstablishmentRouter"; import { createEstablishmentLeadRouter } from "../../adapters/primary/routers/establishmentLead/createEstablishmentLeadRouter"; import { createFormCompletionRouter } from "../../adapters/primary/routers/formCompletion/createFormCompletionRouter"; +import { createFtConnectRouter } from "../../adapters/primary/routers/ftConnect/createFtConnectRouter"; import { createInclusionConnectRouter } from "../../adapters/primary/routers/inclusionConnect/createInclusionConnectRouter"; import { createInclusionConnectedAllowedRouter } from "../../adapters/primary/routers/inclusionConnect/createInclusionConnectedAllowedRouter"; import { createMagicLinkRouter } from "../../adapters/primary/routers/magicLink/createMagicLinkRouter"; -import { createPeConnectRouter } from "../../adapters/primary/routers/peConnect/createPeConnectRouter"; import { createRootApiRouter } from "../../adapters/primary/routers/rootApi/createRootApiRouter"; import { createSearchRouter } from "../../adapters/primary/routers/search/createSearchRouter"; import { createTechnicalRouter } from "../../adapters/primary/routers/technical/createTechnicalRouter"; @@ -90,7 +90,7 @@ export const createApp = async ( app.use(createAddressRouter(deps)); app.use(createConventionRouter(deps)); app.use(createAgenciesRouter(deps)); - app.use(createPeConnectRouter(deps)); + app.use(createFtConnectRouter(deps)); app.use(createInclusionConnectRouter(deps)); // Auth issues below this last router app.use(createEstablishmentRouter(deps)); diff --git a/back/src/config/helpers/createAxiosSharedClients.ts b/back/src/config/helpers/createAxiosSharedClients.ts index 6e1ac4020c..9f93f3429d 100644 --- a/back/src/config/helpers/createAxiosSharedClients.ts +++ b/back/src/config/helpers/createAxiosSharedClients.ts @@ -3,7 +3,7 @@ import { createAxiosSharedClient } from "shared-routes/axios"; import { createFranceTravailRoutes } from "../../domains/convention/adapters/france-travail-gateway/FrancetTravailRoutes"; import { AppConfig } from "../bootstrap/appConfig"; -export const createPeAxiosSharedClient = ( +export const createFtAxiosSharedClient = ( config: AppConfig, axiosInstance = axios.create({ timeout: config.externalAxiosTimeout }), ) => { diff --git a/back/src/config/helpers/createFetchSharedClients.ts b/back/src/config/helpers/createFetchSharedClients.ts index 9017b54f0d..2ed5bad8ab 100644 --- a/back/src/config/helpers/createFetchSharedClients.ts +++ b/back/src/config/helpers/createFetchSharedClients.ts @@ -2,7 +2,7 @@ import { createFetchSharedClient } from "shared-routes/fetch"; import { createFranceTravailRoutes } from "../../domains/convention/adapters/france-travail-gateway/FrancetTravailRoutes"; import { AppConfig } from "../bootstrap/appConfig"; -export const createPeFetchSharedClient = (config: AppConfig) => { +export const createFtFetchSharedClient = (config: AppConfig) => { const franceTravailRoutes = createFranceTravailRoutes(config.ftApiUrl); return createFetchSharedClient(franceTravailRoutes, fetch); }; diff --git a/back/src/config/pg/kysely/model/database.ts b/back/src/config/pg/kysely/model/database.ts index 270a03a3e8..13fd7b7a94 100644 --- a/back/src/config/pg/kysely/model/database.ts +++ b/back/src/config/pg/kysely/model/database.ts @@ -47,7 +47,7 @@ export interface Database { outbox_failures: OutboxFailures; outbox_publications: OutboxPublications; outbox: Outbox; - partners_pe_connect: PartnersPeConnect; + partners_pe_connect: PartnersFtConnect; public_appellations_data: PublicAppellationsData; public_department_region: PublicDepartmentRegion; public_naf_classes_2008: PublicNafClasses2008; @@ -276,7 +276,7 @@ interface Actors { id: Generated; } -interface PartnersPeConnect { +interface PartnersFtConnect { user_pe_external_id: string; convention_id: Generated; firstname: string | null; diff --git a/back/src/domains/agency/adapters/pe-agencies-referential/HttpPeAgenciesReferential.manual.test.ts b/back/src/domains/agency/adapters/ft-agencies-referential/HttpFtAgenciesReferential.manual.test.ts similarity index 76% rename from back/src/domains/agency/adapters/pe-agencies-referential/HttpPeAgenciesReferential.manual.test.ts rename to back/src/domains/agency/adapters/ft-agencies-referential/HttpFtAgenciesReferential.manual.test.ts index 7062e20866..edcc324364 100644 --- a/back/src/domains/agency/adapters/pe-agencies-referential/HttpPeAgenciesReferential.manual.test.ts +++ b/back/src/domains/agency/adapters/ft-agencies-referential/HttpFtAgenciesReferential.manual.test.ts @@ -2,17 +2,17 @@ import { AccessTokenResponse, AppConfig, } from "../../../../config/bootstrap/appConfig"; -import { createPeAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients"; +import { createFtAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients"; import { HttpFranceTravailGateway } from "../../../convention/adapters/france-travail-gateway/HttpFranceTravailGateway"; import { InMemoryCachingGateway } from "../../../core/caching-gateway/adapters/InMemoryCachingGateway"; import { noRetries } from "../../../core/retry-strategy/ports/RetryStrategy"; import { RealTimeGateway } from "../../../core/time-gateway/adapters/RealTimeGateway"; -import { HttpPeAgenciesReferential } from "./HttpPeAgenciesReferential"; +import { HttpFtAgenciesReferential } from "./HttpFtAgenciesReferential"; const config = AppConfig.createFromEnv(); -const axiosHttpClient = createPeAxiosSharedClient(config); +const axiosHttpClient = createFtAxiosSharedClient(config); -const referencielAgencesPE = new HttpPeAgenciesReferential( +const referencielAgencesPE = new HttpFtAgenciesReferential( config.ftApiUrl, new HttpFranceTravailGateway( axiosHttpClient, @@ -29,7 +29,7 @@ const referencielAgencesPE = new HttpPeAgenciesReferential( describe("HttpReferencielAgencesPe", () => { it("Should return PE agencies", async () => { - const a = await referencielAgencesPE.getPeAgencies(); + const a = await referencielAgencesPE.getFtAgencies(); expect(a.length).toBeGreaterThan(10); }); }); diff --git a/back/src/domains/agency/adapters/pe-agencies-referential/HttpPeAgenciesReferential.ts b/back/src/domains/agency/adapters/ft-agencies-referential/HttpFtAgenciesReferential.ts similarity index 77% rename from back/src/domains/agency/adapters/pe-agencies-referential/HttpPeAgenciesReferential.ts rename to back/src/domains/agency/adapters/ft-agencies-referential/HttpFtAgenciesReferential.ts index 59aee38dac..393a7d933b 100644 --- a/back/src/domains/agency/adapters/pe-agencies-referential/HttpPeAgenciesReferential.ts +++ b/back/src/domains/agency/adapters/ft-agencies-referential/HttpFtAgenciesReferential.ts @@ -4,27 +4,27 @@ import { createAxiosInstance } from "../../../../utils/axiosUtils"; import { createLogger } from "../../../../utils/logger"; import { FranceTravailGateway } from "../../../convention/ports/FranceTravailGateway"; import { - PeAgenciesReferential, - PeAgencyFromReferenciel, -} from "../../../establishment/ports/PeAgenciesReferential"; + FtAgenciesReferential, + FtAgencyFromReferential, +} from "../../../establishment/ports/FtAgenciesReferential"; const logger = createLogger(__filename); -export class HttpPeAgenciesReferential implements PeAgenciesReferential { +export class HttpFtAgenciesReferential implements FtAgenciesReferential { #axios: AxiosInstance; readonly #referencielAgenceUrl: AbsoluteUrl; constructor( - peApiUrl: AbsoluteUrl, + ftApiUrl: AbsoluteUrl, private readonly franceTravailGateway: FranceTravailGateway, private readonly franceTravailClientId: string, ) { this.#axios = createAxiosInstance(logger); - this.#referencielAgenceUrl = `${peApiUrl}/partenaire/referentielagences/v1/agences`; + this.#referencielAgenceUrl = `${ftApiUrl}/partenaire/referentielagences/v1/agences`; } - public async getPeAgencies(): Promise { + public async getFtAgencies(): Promise { const accessToken = await this.franceTravailGateway.getAccessToken( `application_${this.franceTravailClientId} api_referentielagencesv1 organisationpe`, ); diff --git a/back/src/domains/agency/adapters/pe-agencies-referential/HttpRome3Gateway.manual.test.ts b/back/src/domains/agency/adapters/ft-agencies-referential/HttpRome3Gateway.manual.test.ts similarity index 94% rename from back/src/domains/agency/adapters/pe-agencies-referential/HttpRome3Gateway.manual.test.ts rename to back/src/domains/agency/adapters/ft-agencies-referential/HttpRome3Gateway.manual.test.ts index fdce038c84..7690fbd6e1 100644 --- a/back/src/domains/agency/adapters/pe-agencies-referential/HttpRome3Gateway.manual.test.ts +++ b/back/src/domains/agency/adapters/ft-agencies-referential/HttpRome3Gateway.manual.test.ts @@ -5,7 +5,7 @@ import { AccessTokenResponse, AppConfig, } from "../../../../config/bootstrap/appConfig"; -import { createPeAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients"; +import { createFtAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients"; import { HttpFranceTravailGateway } from "../../../convention/adapters/france-travail-gateway/HttpFranceTravailGateway"; import { InMemoryCachingGateway } from "../../../core/caching-gateway/adapters/InMemoryCachingGateway"; import { noRetries } from "../../../core/retry-strategy/ports/RetryStrategy"; @@ -21,7 +21,7 @@ describe("HttpRome3Gateway", () => { ); const franceTravailGateway = new HttpFranceTravailGateway( - createPeAxiosSharedClient(config), + createFtAxiosSharedClient(config), cachingGateway, config.ftApiUrl, config.franceTravailAccessTokenConfig, diff --git a/back/src/domains/agency/adapters/pe-agencies-referential/HttpRome3Gateway.ts b/back/src/domains/agency/adapters/ft-agencies-referential/HttpRome3Gateway.ts similarity index 94% rename from back/src/domains/agency/adapters/pe-agencies-referential/HttpRome3Gateway.ts rename to back/src/domains/agency/adapters/ft-agencies-referential/HttpRome3Gateway.ts index 1a19573b2b..700187954f 100644 --- a/back/src/domains/agency/adapters/pe-agencies-referential/HttpRome3Gateway.ts +++ b/back/src/domains/agency/adapters/ft-agencies-referential/HttpRome3Gateway.ts @@ -12,11 +12,11 @@ interface Rome3Gateway { } type Rome4Routes = ReturnType; -export const makeRome3Routes = (peApiUrl: AbsoluteUrl) => +export const makeRome3Routes = (ftApiUrl: AbsoluteUrl) => defineRoutes({ getAppellations: defineRoute({ method: "get", - url: `${peApiUrl}/partenaire/rome/v1/appellation?champs=code,libelle,libelleCourt,metier(code)`, + url: `${ftApiUrl}/partenaire/rome/v1/appellation?champs=code,libelle,libelleCourt,metier(code)`, ...withAuthorizationHeaders, responses: { 200: z.array( diff --git a/back/src/domains/agency/adapters/pe-agencies-referential/HttpRome4Gateway.manual.test.ts b/back/src/domains/agency/adapters/ft-agencies-referential/HttpRome4Gateway.manual.test.ts similarity index 95% rename from back/src/domains/agency/adapters/pe-agencies-referential/HttpRome4Gateway.manual.test.ts rename to back/src/domains/agency/adapters/ft-agencies-referential/HttpRome4Gateway.manual.test.ts index e075eba3e7..4ecb4c569d 100644 --- a/back/src/domains/agency/adapters/pe-agencies-referential/HttpRome4Gateway.manual.test.ts +++ b/back/src/domains/agency/adapters/ft-agencies-referential/HttpRome4Gateway.manual.test.ts @@ -5,7 +5,7 @@ import { AccessTokenResponse, AppConfig, } from "../../../../config/bootstrap/appConfig"; -import { createPeAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients"; +import { createFtAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients"; import { HttpFranceTravailGateway } from "../../../convention/adapters/france-travail-gateway/HttpFranceTravailGateway"; import { InMemoryCachingGateway } from "../../../core/caching-gateway/adapters/InMemoryCachingGateway"; import { noRetries } from "../../../core/retry-strategy/ports/RetryStrategy"; @@ -21,7 +21,7 @@ describe("HttpRome4Gateway", () => { ); const franceTravailGateway = new HttpFranceTravailGateway( - createPeAxiosSharedClient(config), + createFtAxiosSharedClient(config), cachingGateway, config.ftApiUrl, config.franceTravailAccessTokenConfig, diff --git a/back/src/domains/agency/adapters/pe-agencies-referential/HttpRome4Gateway.ts b/back/src/domains/agency/adapters/ft-agencies-referential/HttpRome4Gateway.ts similarity index 93% rename from back/src/domains/agency/adapters/pe-agencies-referential/HttpRome4Gateway.ts rename to back/src/domains/agency/adapters/ft-agencies-referential/HttpRome4Gateway.ts index b141ef85e0..d44e47e35b 100644 --- a/back/src/domains/agency/adapters/pe-agencies-referential/HttpRome4Gateway.ts +++ b/back/src/domains/agency/adapters/ft-agencies-referential/HttpRome4Gateway.ts @@ -19,11 +19,11 @@ interface Rome4Gateway { } type Rome4Routes = ReturnType; -export const makeRome4Routes = (peApiUrl: AbsoluteUrl) => +export const makeRome4Routes = (ftApiUrl: AbsoluteUrl) => defineRoutes({ getRomes: defineRoute({ method: "get", - url: `${peApiUrl}/partenaire/rome-metiers/v1/metiers/metier?champs=code,libelle`, + url: `${ftApiUrl}/partenaire/rome-metiers/v1/metiers/metier?champs=code,libelle`, ...withAuthorizationHeaders, responses: { 200: z.array(z.object({ code: z.string(), libelle: z.string() })), @@ -31,7 +31,7 @@ export const makeRome4Routes = (peApiUrl: AbsoluteUrl) => }), getAppellations: defineRoute({ method: "get", - url: `${peApiUrl}/partenaire/rome-metiers/v1/metiers/appellation?champs=code,libelle,libelleCourt,metier(code)`, + url: `${ftApiUrl}/partenaire/rome-metiers/v1/metiers/appellation?champs=code,libelle,libelleCourt,metier(code)`, ...withAuthorizationHeaders, responses: { 200: z.array( diff --git a/back/src/domains/agency/adapters/ft-agencies-referential/InMemoryFtAgenciesReferential.ts b/back/src/domains/agency/adapters/ft-agencies-referential/InMemoryFtAgenciesReferential.ts new file mode 100644 index 0000000000..da6026aeef --- /dev/null +++ b/back/src/domains/agency/adapters/ft-agencies-referential/InMemoryFtAgenciesReferential.ts @@ -0,0 +1,16 @@ +import { + FtAgenciesReferential, + FtAgencyFromReferential, +} from "../../../establishment/ports/FtAgenciesReferential"; + +export class InMemoryFtAgenciesReferential implements FtAgenciesReferential { + #peAgencies: FtAgencyFromReferential[] = []; + + public async getFtAgencies(): Promise { + return this.#peAgencies; + } + + public setFtAgencies(peAgencies: FtAgencyFromReferential[]) { + this.#peAgencies = peAgencies; + } +} diff --git a/back/src/domains/agency/adapters/pe-agencies-referential/InMemoryPeAgenciesReferential.ts b/back/src/domains/agency/adapters/pe-agencies-referential/InMemoryPeAgenciesReferential.ts deleted file mode 100644 index 0649b88df1..0000000000 --- a/back/src/domains/agency/adapters/pe-agencies-referential/InMemoryPeAgenciesReferential.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { - PeAgenciesReferential, - PeAgencyFromReferenciel, -} from "../../../establishment/ports/PeAgenciesReferential"; - -export class InMemoryPeAgenciesReferential implements PeAgenciesReferential { - #peAgencies: PeAgencyFromReferenciel[] = []; - - public async getPeAgencies(): Promise { - return this.#peAgencies; - } - - public setPeAgencies(peAgencies: PeAgencyFromReferenciel[]) { - this.#peAgencies = peAgencies; - } -} diff --git a/back/src/domains/convention/adapters/PgConventionRepository.integration.test.ts b/back/src/domains/convention/adapters/PgConventionRepository.integration.test.ts index e249a17b47..b724e06da6 100644 --- a/back/src/domains/convention/adapters/PgConventionRepository.integration.test.ts +++ b/back/src/domains/convention/adapters/PgConventionRepository.integration.test.ts @@ -33,7 +33,7 @@ describe("PgConventionRepository", () => { phone: "+33112233445", }; - const userPeExternalId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; + const userFtExternalId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; const styliste: AppellationAndRomeDto = { romeCode: "B1805", @@ -269,7 +269,7 @@ describe("PgConventionRepository", () => { }) .withFederatedIdentity({ provider: "peConnect", - token: userPeExternalId, + token: userFtExternalId, payload: { advisor: { email: "john@mail.com", @@ -284,7 +284,7 @@ describe("PgConventionRepository", () => { await db .insertInto("partners_pe_connect") .values({ - user_pe_external_id: userPeExternalId, + user_pe_external_id: userFtExternalId, convention_id: convention.id, email: "john@mail.com", firstname: "John", @@ -303,7 +303,7 @@ describe("PgConventionRepository", () => { conventionRetreived?.signatories.beneficiary.federatedIdentity, ).toStrictEqual({ provider: "peConnect", - token: userPeExternalId, + token: userFtExternalId, payload: { advisor: { email: "john@mail.com", @@ -331,14 +331,14 @@ describe("PgConventionRepository", () => { }) .withFederatedIdentity({ provider: "peConnect", - token: userPeExternalId, + token: userFtExternalId, }) .build(); await db .insertInto("partners_pe_connect") .values({ - user_pe_external_id: userPeExternalId, + user_pe_external_id: userFtExternalId, convention_id: convention.id, email: null, firstname: null, @@ -357,7 +357,7 @@ describe("PgConventionRepository", () => { conventionRetreived?.signatories.beneficiary.federatedIdentity, ).toStrictEqual({ provider: "peConnect", - token: userPeExternalId, + token: userFtExternalId, }); }); @@ -428,11 +428,11 @@ describe("PgConventionRepository", () => { }); it("Retrieves federated identity if exists", async () => { - const peConnectId: FtConnectToken = "bbbbac99-9c0b-bbbb-bb6d-6bb9bd38bbbb"; + const ftConnectId: FtConnectToken = "bbbbac99-9c0b-bbbb-bb6d-6bb9bd38bbbb"; const convention = conventionStylisteBuilder .withFederatedIdentity({ provider: "peConnect", - token: peConnectId, + token: ftConnectId, payload: { advisor: { email: "john@mail.com", @@ -447,7 +447,7 @@ describe("PgConventionRepository", () => { await db .insertInto("partners_pe_connect") .values({ - user_pe_external_id: peConnectId, + user_pe_external_id: ftConnectId, convention_id: convention.id, email: "john@mail.com", firstname: "John", diff --git a/back/src/domains/convention/adapters/france-travail-gateway/FrancetTravailRoutes.ts b/back/src/domains/convention/adapters/france-travail-gateway/FrancetTravailRoutes.ts index 1997b18303..9baab8be92 100644 --- a/back/src/domains/convention/adapters/france-travail-gateway/FrancetTravailRoutes.ts +++ b/back/src/domains/convention/adapters/france-travail-gateway/FrancetTravailRoutes.ts @@ -3,8 +3,8 @@ import { defineRoute, defineRoutes } from "shared-routes"; import { z } from "zod"; import { FranceTravailConvention } from "../../ports/FranceTravailGateway"; -export const getFtTestPrefix = (peApiUrl: AbsoluteUrl) => - ["https://api.peio.pe-qvr.fr", "https://api-r.es-qvr.fr"].includes(peApiUrl) +export const getFtTestPrefix = (ftApiUrl: AbsoluteUrl) => + ["https://api.peio.pe-qvr.fr", "https://api-r.es-qvr.fr"].includes(ftApiUrl) ? "test" : ""; @@ -12,13 +12,13 @@ export type FrancetTravailRoutes = ReturnType; const franceTravailConventionSchema: z.Schema = z.any(); -export const createFranceTravailRoutes = (peApiUrl: AbsoluteUrl) => { - const ftTestPrefix = getFtTestPrefix(peApiUrl); +export const createFranceTravailRoutes = (ftApiUrl: AbsoluteUrl) => { + const ftTestPrefix = getFtTestPrefix(ftApiUrl); return defineRoutes({ broadcastConvention: defineRoute({ method: "post", - url: `${peApiUrl}/partenaire/${ftTestPrefix}immersion-pro/v2/demandes-immersion`, + url: `${ftApiUrl}/partenaire/${ftTestPrefix}immersion-pro/v2/demandes-immersion`, requestBodySchema: franceTravailConventionSchema, ...withAuthorizationHeaders, responses: { diff --git a/back/src/domains/convention/adapters/france-travail-gateway/HttpFranceTravailGateway.manual.test.ts b/back/src/domains/convention/adapters/france-travail-gateway/HttpFranceTravailGateway.manual.test.ts index 2cd648e0fb..078719e991 100644 --- a/back/src/domains/convention/adapters/france-travail-gateway/HttpFranceTravailGateway.manual.test.ts +++ b/back/src/domains/convention/adapters/france-travail-gateway/HttpFranceTravailGateway.manual.test.ts @@ -7,7 +7,7 @@ import { AccessTokenResponse, AppConfig, } from "../../../../config/bootstrap/appConfig"; -import { createPeAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients"; +import { createFtAxiosSharedClient } from "../../../../config/helpers/createAxiosSharedClients"; import { InMemoryCachingGateway } from "../../../core/caching-gateway/adapters/InMemoryCachingGateway"; import { noRetries } from "../../../core/retry-strategy/ports/RetryStrategy"; import { RealTimeGateway } from "../../../core/time-gateway/adapters/RealTimeGateway"; @@ -58,7 +58,7 @@ describe("HttpFranceTravailGateway", () => { "Should have status $expected.status when $testMessage", async ({ fields, expected }) => { const httpFranceTravailGateway = new HttpFranceTravailGateway( - createPeAxiosSharedClient(config), + createFtAxiosSharedClient(config), cachingGateway, config.ftApiUrl, config.franceTravailAccessTokenConfig, @@ -113,7 +113,7 @@ describe("HttpFranceTravailGateway", () => { "Should have status $expected.status when $testMessage", async ({ fields, expected }) => { const httpFranceTravailGateway = new HttpFranceTravailGateway( - createPeAxiosSharedClient(config), + createFtAxiosSharedClient(config), cachingGateway, config.ftApiUrl, config.franceTravailAccessTokenConfig, @@ -134,9 +134,9 @@ describe("HttpFranceTravailGateway", () => { ); it("error feedback axios timeout", async () => { - const peApiUrl = "https://fake-pe.fr"; - const peEnterpriseUrl = "https://fake-pe-enterprise.fr"; - const routes = createFranceTravailRoutes(peApiUrl); + const ftApiUrl = "https://fake-ft.fr"; + const ftEnterpriseUrl = "https://fake-ft-enterprise.fr"; + const routes = createFranceTravailRoutes(ftApiUrl); const httpClient = createAxiosSharedClient(routes, axios, { skipResponseValidation: true, @@ -149,9 +149,9 @@ describe("HttpFranceTravailGateway", () => { const accessTokenConfig: AccessTokenConfig = { immersionFacileBaseUrl: "https://", - ftApiUrl: peApiUrl, + ftApiUrl, ftAuthCandidatUrl: "https://", - ftEnterpriseUrl: peEnterpriseUrl, + ftEnterpriseUrl, clientId: "", clientSecret: "", }; @@ -159,7 +159,7 @@ describe("HttpFranceTravailGateway", () => { const franceTravailGateway = new HttpFranceTravailGateway( httpClient, cachingGateway, - peApiUrl, + ftApiUrl, accessTokenConfig, noRetries, ); @@ -168,7 +168,7 @@ describe("HttpFranceTravailGateway", () => { mock .onPost( - `${peEnterpriseUrl}/connexion/oauth2/access_token?realm=%2Fpartenaire`, + `${ftEnterpriseUrl}/connexion/oauth2/access_token?realm=%2Fpartenaire`, ) .reply(200, { access_token: "yolo" }) .onPost(routes.broadcastConvention.url) @@ -187,8 +187,8 @@ describe("HttpFranceTravailGateway", () => { }); it("error feedback on bad response code", async () => { - const peApiUrl = "https://fake-pe.fr"; - const peEnterpriseUrl = "https://fake-pe-enterprise.fr"; + const peApiUrl = "https://fake-ft.fr"; + const peEnterpriseUrl = "https://fake-ft-enterprise.fr"; const routes = createFranceTravailRoutes(peApiUrl); const httpClient = createAxiosSharedClient(routes, axios, { diff --git a/back/src/domains/convention/ports/FranceTravailGateway.ts b/back/src/domains/convention/ports/FranceTravailGateway.ts index fb0159ef51..367cafad5b 100644 --- a/back/src/domains/convention/ports/FranceTravailGateway.ts +++ b/back/src/domains/convention/ports/FranceTravailGateway.ts @@ -33,7 +33,7 @@ type ConventionStatusToFtStatus = typeof conventionStatusToFranceTravailStatus; type FtConventionStatus = ConventionStatusToFtStatus[keyof ConventionStatusToFtStatus]; -export type AgencyKindForPe = +export type AgencyKindForFt = | Exclude | "france-travail"; @@ -67,7 +67,7 @@ export type FranceTravailConvention = { competencesObservees: string; signatureBeneficiaire: boolean; signatureEntreprise: boolean; - typeAgence: AgencyKindForPe; + typeAgence: AgencyKindForFt; nomAgence: string; prenomValidateurRenseigne?: string; nomValidateurRenseigne?: string; diff --git a/back/src/domains/convention/use-cases/GetConvention.unit.test.ts b/back/src/domains/convention/use-cases/GetConvention.unit.test.ts index 4c2fa42c13..e9ba8e1498 100644 --- a/back/src/domains/convention/use-cases/GetConvention.unit.test.ts +++ b/back/src/domains/convention/use-cases/GetConvention.unit.test.ts @@ -442,15 +442,15 @@ describe("Get Convention", () => { }); }); - it("user is a PeAdvisor", async () => { - const peAdvisorEmail = "pe-advisor@mail.fr"; - const peConnectedConvention = new ConventionDtoBuilder(convention) + it("user is a FtAdvisor", async () => { + const ftAdvisorEmail = "ft-advisor@mail.fr"; + const ftConnectedConvention = new ConventionDtoBuilder(convention) .withFederatedIdentity({ provider: "peConnect", token: "some-id", payload: { advisor: { - email: peAdvisorEmail, + email: ftAdvisorEmail, firstName: "john", lastName: "doe", type: "PLACEMENT", @@ -458,10 +458,10 @@ describe("Get Convention", () => { }, }) .build(); - uow.conventionRepository.setConventions([peConnectedConvention]); + uow.conventionRepository.setConventions([ftConnectedConvention]); const payload: ConventionJwtPayload = { role: "validator", - emailHash: makeEmailHash(peAdvisorEmail), + emailHash: makeEmailHash(ftAdvisorEmail), applicationId: convention.id, iat: 1, version: 1, @@ -473,7 +473,7 @@ describe("Get Convention", () => { ); expectToEqual(conventionResult, { - ...peConnectedConvention, + ...ftConnectedConvention, agencyName: agency.name, agencyDepartment: agency.address.departmentCode, agencyKind: agency.kind, diff --git a/back/src/domains/convention/use-cases/ResyncOldConventionsToPe.unit.test.ts b/back/src/domains/convention/use-cases/ResyncOldConventionsToFt.unit.test.ts similarity index 93% rename from back/src/domains/convention/use-cases/ResyncOldConventionsToPe.unit.test.ts rename to back/src/domains/convention/use-cases/ResyncOldConventionsToFt.unit.test.ts index aa9a43df50..8c1909ead5 100644 --- a/back/src/domains/convention/use-cases/ResyncOldConventionsToPe.unit.test.ts +++ b/back/src/domains/convention/use-cases/ResyncOldConventionsToFt.unit.test.ts @@ -43,16 +43,16 @@ describe("ResyncOldConventionsToPe use case", () => { let uow: InMemoryUnitOfWork; let useCase: ResyncOldConventionsToFt; let timeGateway: CustomTimeGateway; - let peGateway: InMemoryFranceTravailGateway; + let ftGateway: InMemoryFranceTravailGateway; beforeEach(() => { uow = createInMemoryUow(); timeGateway = new CustomTimeGateway(); - peGateway = new InMemoryFranceTravailGateway(); + ftGateway = new InMemoryFranceTravailGateway(); useCase = new ResyncOldConventionsToFt( new InMemoryUowPerformer(uow), - peGateway, + ftGateway, timeGateway, 100, ); @@ -75,7 +75,7 @@ describe("ResyncOldConventionsToPe use case", () => { status: "TO_PROCESS", }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); const report = await useCase.execute(); @@ -95,7 +95,7 @@ describe("ResyncOldConventionsToPe use case", () => { processDate: timeGateway.now(), }, ]); - expectToEqual(peGateway.notifications, [ + expectToEqual(ftGateway.notifications, [ conventionToConventionNotification(conventionToSync1, agencyPE), conventionToConventionNotification(conventionToSync2, agencyPE), ]); @@ -115,7 +115,7 @@ describe("ResyncOldConventionsToPe use case", () => { status: "TO_PROCESS", }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); const report = await useCase.execute(); @@ -127,7 +127,7 @@ describe("ResyncOldConventionsToPe use case", () => { processDate: timeGateway.now(), }, ]); - expectToEqual(peGateway.notifications, [ + expectToEqual(ftGateway.notifications, [ conventionToConventionNotification(conventionToSync1, agencyPE), ]); expectToEqual(report, { @@ -139,13 +139,13 @@ describe("ResyncOldConventionsToPe use case", () => { it("no convention to sync", async () => { uow.conventionsToSyncRepository.setForTesting([]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); const report = await useCase.execute(); expectToEqual(uow.conventionRepository.conventions, []); expectToEqual(uow.conventionsToSyncRepository.conventionsToSync, []); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); expectToEqual(report, { success: 0, skips: {}, @@ -166,7 +166,7 @@ describe("ResyncOldConventionsToPe use case", () => { status: "TO_PROCESS", }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); const report = await useCase.execute(); @@ -179,7 +179,7 @@ describe("ResyncOldConventionsToPe use case", () => { reason: "Agency is not of kind pole-emploi", }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); expectToEqual(report, { success: 0, skips: { @@ -220,7 +220,7 @@ describe("ResyncOldConventionsToPe use case", () => { processDate: subDays(timeGateway.now(), 1), }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); const report = await useCase.execute(); @@ -253,7 +253,7 @@ describe("ResyncOldConventionsToPe use case", () => { processDate: subDays(timeGateway.now(), 1), }, ]); - expectToEqual(peGateway.notifications, [ + expectToEqual(ftGateway.notifications, [ conventionToConventionNotification(conventionToSync1, agencyPE), conventionToConventionNotification(conventionToSync2, agencyPE), ]); @@ -280,11 +280,11 @@ describe("ResyncOldConventionsToPe use case", () => { status: "TO_PROCESS", }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); const report = await new ResyncOldConventionsToFt( new InMemoryUowPerformer(uow), - peGateway, + ftGateway, timeGateway, 1, ).execute(); @@ -304,7 +304,7 @@ describe("ResyncOldConventionsToPe use case", () => { status: "TO_PROCESS", }, ]); - expectToEqual(peGateway.notifications, [ + expectToEqual(ftGateway.notifications, [ conventionToConventionNotification(conventionToSync1, agencyPE), ]); expectToEqual(report, { @@ -324,7 +324,7 @@ describe("ResyncOldConventionsToPe use case", () => { status: "TO_PROCESS", }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); const report = await useCase.execute(); @@ -339,7 +339,7 @@ describe("ResyncOldConventionsToPe use case", () => { }).message, }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); expectToEqual(report, { success: 0, skips: {}, @@ -359,7 +359,7 @@ describe("ResyncOldConventionsToPe use case", () => { status: "TO_PROCESS", }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); const report = await useCase.execute(); @@ -372,7 +372,7 @@ describe("ResyncOldConventionsToPe use case", () => { reason: errors.agency.notFound({ agencyId: agencyPE.id }).message, }, ]); - expectToEqual(peGateway.notifications, []); + expectToEqual(ftGateway.notifications, []); expectToEqual(report, { success: 0, skips: {}, diff --git a/back/src/domains/convention/use-cases/broadcast/BroadcastToFranceTravailOnConventionUpdates.unit.test.ts b/back/src/domains/convention/use-cases/broadcast/BroadcastToFranceTravailOnConventionUpdates.unit.test.ts index 7fe5bbcc61..2fa38341cb 100644 --- a/back/src/domains/convention/use-cases/broadcast/BroadcastToFranceTravailOnConventionUpdates.unit.test.ts +++ b/back/src/domains/convention/use-cases/broadcast/BroadcastToFranceTravailOnConventionUpdates.unit.test.ts @@ -18,7 +18,7 @@ import { createInMemoryUow, } from "../../../core/unit-of-work/adapters/createInMemoryUow"; import { InMemoryFranceTravailGateway } from "../../adapters/france-travail-gateway/InMemoryFranceTravailGateway"; -import { AgencyKindForPe } from "../../ports/FranceTravailGateway"; +import { AgencyKindForFt } from "../../ports/FranceTravailGateway"; import { BroadcastToFranceTravailOnConventionUpdates } from "./BroadcastToFranceTravailOnConventionUpdates"; describe("Broadcasts events to France Travail", () => { @@ -301,7 +301,7 @@ describe("Broadcasts events to France Travail", () => { describe.each([ { - agencyKind: "mission-locale" as AgencyKindForPe, + agencyKind: "mission-locale" as AgencyKindForFt, featureFlag: { enableBroadcastOfMissionLocaleToFT: { kind: "boolean", @@ -311,7 +311,7 @@ describe("Broadcasts events to France Travail", () => { ...createAgencyAndLinkedConvention("mission-locale"), }, { - agencyKind: "conseil-departemental" as AgencyKindForPe, + agencyKind: "conseil-departemental" as AgencyKindForFt, featureFlag: { enableBroadcastOfConseilDepartementalToFT: { kind: "boolean", @@ -321,7 +321,7 @@ describe("Broadcasts events to France Travail", () => { ...createAgencyAndLinkedConvention("conseil-departemental"), }, { - agencyKind: "cap-emploi" as AgencyKindForPe, + agencyKind: "cap-emploi" as AgencyKindForFt, featureFlag: { enableBroadcastOfCapEmploiToFT: { kind: "boolean", @@ -401,15 +401,15 @@ describe("Broadcasts events to France Travail", () => { describe.each([ { - agencyKind: "mission-locale" as AgencyKindForPe, + agencyKind: "mission-locale" as AgencyKindForFt, ...createAgencyAndLinkedConvention("mission-locale"), }, { - agencyKind: "conseil-departemental" as AgencyKindForPe, + agencyKind: "conseil-departemental" as AgencyKindForFt, ...createAgencyAndLinkedConvention("conseil-departemental"), }, { - agencyKind: "cap-emploi" as AgencyKindForPe, + agencyKind: "cap-emploi" as AgencyKindForFt, ...createAgencyAndLinkedConvention("cap-emploi"), }, ])( diff --git a/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.ts b/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.ts index c94fef14c0..7b32b2088d 100644 --- a/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.ts +++ b/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.ts @@ -96,7 +96,7 @@ export class NotifyAllActorsOfFinalConventionValidation extends TransactionalUse email: validatorEmail, }), ), - ...getPeAdvisorEmailAndRoleIfExist( + ...getFtAdvisorEmailAndRoleIfExist( await uow.conventionFranceTravailAdvisorRepository.getByConventionId( convention.id, ), @@ -186,9 +186,9 @@ export class NotifyAllActorsOfFinalConventionValidation extends TransactionalUse } } -const getPeAdvisorEmailAndRoleIfExist = ( - conventionPeUserAdvisor: ConventionFtUserAdvisorEntity | undefined, +const getFtAdvisorEmailAndRoleIfExist = ( + conventionFtUserAdvisor: ConventionFtUserAdvisorEntity | undefined, ): [{ role: Role; email: Email }] | [] => - conventionPeUserAdvisor?.advisor?.email - ? [{ role: "validator", email: conventionPeUserAdvisor.advisor.email }] + conventionFtUserAdvisor?.advisor?.email + ? [{ role: "validator", email: conventionFtUserAdvisor.advisor.email }] : []; diff --git a/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.unit.test.ts b/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.unit.test.ts index 9ccb0c20d5..03d57447f1 100644 --- a/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.unit.test.ts +++ b/back/src/domains/convention/use-cases/notifications/NotifyAllActorsOfFinalConventionValidation.unit.test.ts @@ -37,7 +37,7 @@ describe("NotifyAllActorsOfFinalApplicationValidation", () => { "establishment-representativ@gmail.com"; const beneficiaryCurrentEmployerEmail = "current@employer.com"; const beneficiaryRepresentativeEmail = "beneficiary@representative.fr"; - const peAdvisorEmail = "pe-advisor@pole-emploi.net"; + const peAdvisorEmail = "ft-advisor@pole-emploi.net"; const counsellor = new InclusionConnectedUserBuilder() .withId("counsellor") .withEmail("counsellor@email.fr") @@ -468,7 +468,7 @@ describe("NotifyAllActorsOfFinalApplicationValidation", () => { shortlinkId: "shortLinkId_2", }, ]; - const userPeExternalId = "i-am-an-external-id"; + const userFtExternalId = "i-am-an-external-id"; const userConventionAdvisor: ConventionFtUserAdvisorEntity = { _entityName: "ConventionFranceTravailAdvisor", advisor: { @@ -477,7 +477,7 @@ describe("NotifyAllActorsOfFinalApplicationValidation", () => { lastName: "Oldenburg", type: "CAPEMPLOI", }, - peExternalId: userPeExternalId, + peExternalId: userFtExternalId, conventionId: validConvention.id, }; @@ -559,11 +559,11 @@ describe("NotifyAllActorsOfFinalApplicationValidation", () => { shortlinkId: "shortLinkId_6", }, ]; - const userPeExternalId = "i-am-an-external-id"; + const userFtExternalId = "i-am-an-external-id"; const userConventionAdvisor: ConventionFtUserAdvisorEntity = { _entityName: "ConventionFranceTravailAdvisor", advisor: undefined, - peExternalId: userPeExternalId, + peExternalId: userFtExternalId, conventionId: validConvention.id, }; diff --git a/back/src/domains/convention/use-cases/notifications/NotifyNewConventionNeedsReview.unit.test.ts b/back/src/domains/convention/use-cases/notifications/NotifyNewConventionNeedsReview.unit.test.ts index 4973ae4740..1ffb57df5d 100644 --- a/back/src/domains/convention/use-cases/notifications/NotifyNewConventionNeedsReview.unit.test.ts +++ b/back/src/domains/convention/use-cases/notifications/NotifyNewConventionNeedsReview.unit.test.ts @@ -2,8 +2,8 @@ import { AgencyDtoBuilder, ConventionDto, ConventionDtoBuilder, + FtConnectIdentity, InclusionConnectedUserBuilder, - PeConnectIdentity, expectToEqual, frontRoutes, } from "shared"; @@ -70,8 +70,8 @@ describe("NotifyConventionNeedsReview", () => { }, ); - const peAdvisorEmail = "pe-advisor@gmail.com"; - const peIdentity: PeConnectIdentity = { + const ftAdvisorEmail = "ft-advisor@gmail.com"; + const ftIdentity: FtConnectIdentity = { provider: "peConnect", token: "123", }; @@ -269,11 +269,11 @@ describe("NotifyConventionNeedsReview", () => { it("sends notification to counsellors (when they exist), even if there is a peAdvisor", async () => { uow.agencyRepository.agencies = [agencyWithCounsellorsAndValidators]; - const conventionInReviewWithPeAdvisor = new ConventionDtoBuilder( + const conventionInReviewWithFtAdvisor = new ConventionDtoBuilder( defaultConvention, ) .withStatus("IN_REVIEW") - .withFederatedIdentity(peIdentity) + .withFederatedIdentity(ftIdentity) .build(); const shortLinkIds = [ @@ -287,13 +287,13 @@ describe("NotifyConventionNeedsReview", () => { const userConventionAdvisor: ConventionFtUserAdvisorEntity = { _entityName: "ConventionFranceTravailAdvisor", advisor: { - email: peAdvisorEmail, + email: ftAdvisorEmail, firstName: "Elsa", lastName: "Oldenburg", type: "CAPEMPLOI", }, - peExternalId: peIdentity.token, - conventionId: conventionInReviewWithPeAdvisor.id, + peExternalId: ftIdentity.token, + conventionId: conventionInReviewWithFtAdvisor.id, }; uow.conventionFranceTravailAdvisorRepository.setConventionFranceTravailUsersAdvisor( @@ -301,7 +301,7 @@ describe("NotifyConventionNeedsReview", () => { ); await notifyNewConventionNeedsReview.execute({ - convention: conventionInReviewWithPeAdvisor, + convention: conventionInReviewWithFtAdvisor, }); expectSavedNotificationsAndEvents({ @@ -310,15 +310,15 @@ describe("NotifyConventionNeedsReview", () => { kind: "NEW_CONVENTION_REVIEW_FOR_ELIGIBILITY_OR_VALIDATION", recipients: [councellor2.email], params: { - conventionId: conventionInReviewWithPeAdvisor.id, - internshipKind: conventionInReviewWithPeAdvisor.internshipKind, + conventionId: conventionInReviewWithFtAdvisor.id, + internshipKind: conventionInReviewWithFtAdvisor.internshipKind, beneficiaryFirstName: - conventionInReviewWithPeAdvisor.signatories.beneficiary + conventionInReviewWithFtAdvisor.signatories.beneficiary .firstName, beneficiaryLastName: - conventionInReviewWithPeAdvisor.signatories.beneficiary + conventionInReviewWithFtAdvisor.signatories.beneficiary .lastName, - businessName: conventionInReviewWithPeAdvisor.businessName, + businessName: conventionInReviewWithFtAdvisor.businessName, magicLink: makeShortLinkUrl(config, shortLinkIds[1]), conventionStatusLink: makeShortLinkUrl(config, shortLinkIds[0]), possibleRoleAction: "en vérifier l'éligibilité", @@ -344,23 +344,23 @@ describe("NotifyConventionNeedsReview", () => { ]; shortLinkIdGeneratorGateway.addMoreShortLinkIds(shortLinkIds); - const conventionInReviewWithPeAdvisor = new ConventionDtoBuilder( + const conventionInReviewWithFtAdvisor = new ConventionDtoBuilder( defaultConvention, ) .withStatus("IN_REVIEW") - .withFederatedIdentity(peIdentity) + .withFederatedIdentity(ftIdentity) .build(); const userConventionAdvisor: ConventionFtUserAdvisorEntity = { _entityName: "ConventionFranceTravailAdvisor", advisor: { - email: peAdvisorEmail, + email: ftAdvisorEmail, firstName: "Elsa", lastName: "Oldenburg", type: "CAPEMPLOI", }, - peExternalId: peIdentity.token, - conventionId: conventionInReviewWithPeAdvisor.id, + peExternalId: ftIdentity.token, + conventionId: conventionInReviewWithFtAdvisor.id, }; uow.conventionFranceTravailAdvisorRepository.setConventionFranceTravailUsersAdvisor( @@ -368,47 +368,47 @@ describe("NotifyConventionNeedsReview", () => { ); await notifyNewConventionNeedsReview.execute({ - convention: conventionInReviewWithPeAdvisor, + convention: conventionInReviewWithFtAdvisor, }); expectToEqual(uow.shortLinkQuery.getShortLinks(), { [shortLinkIds[0]]: fakeGenerateMagicLinkUrlFn({ - id: conventionInReviewWithPeAdvisor.id, + id: conventionInReviewWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.conventionStatusDashboard, - email: peAdvisorEmail, + email: ftAdvisorEmail, now: timeGateway.now(), }), [shortLinkIds[1]]: fakeGenerateMagicLinkUrlFn({ - id: conventionInReviewWithPeAdvisor.id, + id: conventionInReviewWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.conventionStatusDashboard, email: validator1.email, now: timeGateway.now(), }), [shortLinkIds[2]]: fakeGenerateMagicLinkUrlFn({ - id: conventionInReviewWithPeAdvisor.id, + id: conventionInReviewWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.conventionStatusDashboard, email: validator2.email, now: timeGateway.now(), }), [shortLinkIds[3]]: fakeGenerateMagicLinkUrlFn({ - id: conventionInReviewWithPeAdvisor.id, + id: conventionInReviewWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.manageConvention, - email: peAdvisorEmail, + email: ftAdvisorEmail, now: timeGateway.now(), }), [shortLinkIds[4]]: fakeGenerateMagicLinkUrlFn({ - id: conventionInReviewWithPeAdvisor.id, + id: conventionInReviewWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.manageConvention, email: validator1.email, now: timeGateway.now(), }), [shortLinkIds[5]]: fakeGenerateMagicLinkUrlFn({ - id: conventionInReviewWithPeAdvisor.id, + id: conventionInReviewWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.manageConvention, email: validator2.email, @@ -420,17 +420,17 @@ describe("NotifyConventionNeedsReview", () => { emails: [ { kind: "NEW_CONVENTION_REVIEW_FOR_ELIGIBILITY_OR_VALIDATION", - recipients: [peAdvisorEmail], + recipients: [ftAdvisorEmail], params: { - conventionId: conventionInReviewWithPeAdvisor.id, - internshipKind: conventionInReviewWithPeAdvisor.internshipKind, + conventionId: conventionInReviewWithFtAdvisor.id, + internshipKind: conventionInReviewWithFtAdvisor.internshipKind, beneficiaryFirstName: - conventionInReviewWithPeAdvisor.signatories.beneficiary + conventionInReviewWithFtAdvisor.signatories.beneficiary .firstName, beneficiaryLastName: - conventionInReviewWithPeAdvisor.signatories.beneficiary + conventionInReviewWithFtAdvisor.signatories.beneficiary .lastName, - businessName: conventionInReviewWithPeAdvisor.businessName, + businessName: conventionInReviewWithFtAdvisor.businessName, magicLink: makeShortLinkUrl(config, shortLinkIds[3]), conventionStatusLink: makeShortLinkUrl(config, shortLinkIds[0]), possibleRoleAction: "en considérer la validation", @@ -447,15 +447,15 @@ describe("NotifyConventionNeedsReview", () => { kind: "NEW_CONVENTION_REVIEW_FOR_ELIGIBILITY_OR_VALIDATION", recipients: [validator1.email], params: { - conventionId: conventionInReviewWithPeAdvisor.id, - internshipKind: conventionInReviewWithPeAdvisor.internshipKind, + conventionId: conventionInReviewWithFtAdvisor.id, + internshipKind: conventionInReviewWithFtAdvisor.internshipKind, beneficiaryFirstName: - conventionInReviewWithPeAdvisor.signatories.beneficiary + conventionInReviewWithFtAdvisor.signatories.beneficiary .firstName, beneficiaryLastName: - conventionInReviewWithPeAdvisor.signatories.beneficiary + conventionInReviewWithFtAdvisor.signatories.beneficiary .lastName, - businessName: conventionInReviewWithPeAdvisor.businessName, + businessName: conventionInReviewWithFtAdvisor.businessName, magicLink: makeShortLinkUrl(config, shortLinkIds[4]), conventionStatusLink: makeShortLinkUrl(config, shortLinkIds[1]), possibleRoleAction: "en considérer la validation", @@ -472,15 +472,15 @@ describe("NotifyConventionNeedsReview", () => { kind: "NEW_CONVENTION_REVIEW_FOR_ELIGIBILITY_OR_VALIDATION", recipients: [validator2.email], params: { - conventionId: conventionInReviewWithPeAdvisor.id, - internshipKind: conventionInReviewWithPeAdvisor.internshipKind, + conventionId: conventionInReviewWithFtAdvisor.id, + internshipKind: conventionInReviewWithFtAdvisor.internshipKind, beneficiaryFirstName: - conventionInReviewWithPeAdvisor.signatories.beneficiary + conventionInReviewWithFtAdvisor.signatories.beneficiary .firstName, beneficiaryLastName: - conventionInReviewWithPeAdvisor.signatories.beneficiary + conventionInReviewWithFtAdvisor.signatories.beneficiary .lastName, - businessName: conventionInReviewWithPeAdvisor.businessName, + businessName: conventionInReviewWithFtAdvisor.businessName, magicLink: makeShortLinkUrl(config, shortLinkIds[5]), conventionStatusLink: makeShortLinkUrl(config, shortLinkIds[2]), possibleRoleAction: "en considérer la validation", @@ -614,22 +614,22 @@ describe("NotifyConventionNeedsReview", () => { ]; shortLinkIdGeneratorGateway.addMoreShortLinkIds(shortLinkIds); - const conventionAcceptedByCounsellorWithPeAdvisor = + const conventionAcceptedByCounsellorWithFtAdvisor = new ConventionDtoBuilder(defaultConvention) .withStatus("ACCEPTED_BY_COUNSELLOR") - .withFederatedIdentity(peIdentity) + .withFederatedIdentity(ftIdentity) .build(); const userConventionAdvisor: ConventionFtUserAdvisorEntity = { _entityName: "ConventionFranceTravailAdvisor", advisor: { - email: peAdvisorEmail, + email: ftAdvisorEmail, firstName: "Elsa", lastName: "Oldenburg", type: "CAPEMPLOI", }, - peExternalId: peIdentity.token, - conventionId: conventionAcceptedByCounsellorWithPeAdvisor.id, + peExternalId: ftIdentity.token, + conventionId: conventionAcceptedByCounsellorWithFtAdvisor.id, }; uow.conventionFranceTravailAdvisorRepository.setConventionFranceTravailUsersAdvisor( @@ -637,47 +637,47 @@ describe("NotifyConventionNeedsReview", () => { ); await notifyNewConventionNeedsReview.execute({ - convention: conventionAcceptedByCounsellorWithPeAdvisor, + convention: conventionAcceptedByCounsellorWithFtAdvisor, }); expectToEqual(uow.shortLinkQuery.getShortLinks(), { [shortLinkIds[0]]: fakeGenerateMagicLinkUrlFn({ - id: conventionAcceptedByCounsellorWithPeAdvisor.id, + id: conventionAcceptedByCounsellorWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.conventionStatusDashboard, - email: peAdvisorEmail, + email: ftAdvisorEmail, now: timeGateway.now(), }), [shortLinkIds[1]]: fakeGenerateMagicLinkUrlFn({ - id: conventionAcceptedByCounsellorWithPeAdvisor.id, + id: conventionAcceptedByCounsellorWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.conventionStatusDashboard, email: validator1.email, now: timeGateway.now(), }), [shortLinkIds[2]]: fakeGenerateMagicLinkUrlFn({ - id: conventionAcceptedByCounsellorWithPeAdvisor.id, + id: conventionAcceptedByCounsellorWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.conventionStatusDashboard, email: validator2.email, now: timeGateway.now(), }), [shortLinkIds[3]]: fakeGenerateMagicLinkUrlFn({ - id: conventionAcceptedByCounsellorWithPeAdvisor.id, + id: conventionAcceptedByCounsellorWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.manageConvention, - email: peAdvisorEmail, + email: ftAdvisorEmail, now: timeGateway.now(), }), [shortLinkIds[4]]: fakeGenerateMagicLinkUrlFn({ - id: conventionAcceptedByCounsellorWithPeAdvisor.id, + id: conventionAcceptedByCounsellorWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.manageConvention, email: validator1.email, now: timeGateway.now(), }), [shortLinkIds[5]]: fakeGenerateMagicLinkUrlFn({ - id: conventionAcceptedByCounsellorWithPeAdvisor.id, + id: conventionAcceptedByCounsellorWithFtAdvisor.id, role: "validator", targetRoute: frontRoutes.manageConvention, email: validator2.email, @@ -689,19 +689,19 @@ describe("NotifyConventionNeedsReview", () => { emails: [ { kind: "NEW_CONVENTION_REVIEW_FOR_ELIGIBILITY_OR_VALIDATION", - recipients: [peAdvisorEmail], + recipients: [ftAdvisorEmail], params: { - conventionId: conventionAcceptedByCounsellorWithPeAdvisor.id, + conventionId: conventionAcceptedByCounsellorWithFtAdvisor.id, internshipKind: - conventionAcceptedByCounsellorWithPeAdvisor.internshipKind, + conventionAcceptedByCounsellorWithFtAdvisor.internshipKind, beneficiaryFirstName: - conventionAcceptedByCounsellorWithPeAdvisor.signatories + conventionAcceptedByCounsellorWithFtAdvisor.signatories .beneficiary.firstName, beneficiaryLastName: - conventionAcceptedByCounsellorWithPeAdvisor.signatories + conventionAcceptedByCounsellorWithFtAdvisor.signatories .beneficiary.lastName, businessName: - conventionAcceptedByCounsellorWithPeAdvisor.businessName, + conventionAcceptedByCounsellorWithFtAdvisor.businessName, magicLink: makeShortLinkUrl(config, shortLinkIds[3]), conventionStatusLink: makeShortLinkUrl(config, shortLinkIds[0]), possibleRoleAction: "en considérer la validation", @@ -718,17 +718,17 @@ describe("NotifyConventionNeedsReview", () => { kind: "NEW_CONVENTION_REVIEW_FOR_ELIGIBILITY_OR_VALIDATION", recipients: [validator1.email], params: { - conventionId: conventionAcceptedByCounsellorWithPeAdvisor.id, + conventionId: conventionAcceptedByCounsellorWithFtAdvisor.id, internshipKind: - conventionAcceptedByCounsellorWithPeAdvisor.internshipKind, + conventionAcceptedByCounsellorWithFtAdvisor.internshipKind, beneficiaryFirstName: - conventionAcceptedByCounsellorWithPeAdvisor.signatories + conventionAcceptedByCounsellorWithFtAdvisor.signatories .beneficiary.firstName, beneficiaryLastName: - conventionAcceptedByCounsellorWithPeAdvisor.signatories + conventionAcceptedByCounsellorWithFtAdvisor.signatories .beneficiary.lastName, businessName: - conventionAcceptedByCounsellorWithPeAdvisor.businessName, + conventionAcceptedByCounsellorWithFtAdvisor.businessName, magicLink: makeShortLinkUrl(config, shortLinkIds[4]), conventionStatusLink: makeShortLinkUrl(config, shortLinkIds[1]), possibleRoleAction: "en considérer la validation", @@ -745,17 +745,17 @@ describe("NotifyConventionNeedsReview", () => { kind: "NEW_CONVENTION_REVIEW_FOR_ELIGIBILITY_OR_VALIDATION", recipients: [validator2.email], params: { - conventionId: conventionAcceptedByCounsellorWithPeAdvisor.id, + conventionId: conventionAcceptedByCounsellorWithFtAdvisor.id, internshipKind: - conventionAcceptedByCounsellorWithPeAdvisor.internshipKind, + conventionAcceptedByCounsellorWithFtAdvisor.internshipKind, beneficiaryFirstName: - conventionAcceptedByCounsellorWithPeAdvisor.signatories + conventionAcceptedByCounsellorWithFtAdvisor.signatories .beneficiary.firstName, beneficiaryLastName: - conventionAcceptedByCounsellorWithPeAdvisor.signatories + conventionAcceptedByCounsellorWithFtAdvisor.signatories .beneficiary.lastName, businessName: - conventionAcceptedByCounsellorWithPeAdvisor.businessName, + conventionAcceptedByCounsellorWithFtAdvisor.businessName, magicLink: makeShortLinkUrl(config, shortLinkIds[5]), conventionStatusLink: makeShortLinkUrl(config, shortLinkIds[2]), possibleRoleAction: "en considérer la validation", diff --git a/back/src/domains/convention/use-cases/notifications/NotifyToAgencyConventionSubmitted.unit.test.ts b/back/src/domains/convention/use-cases/notifications/NotifyToAgencyConventionSubmitted.unit.test.ts index ba842926f0..c22d855c83 100644 --- a/back/src/domains/convention/use-cases/notifications/NotifyToAgencyConventionSubmitted.unit.test.ts +++ b/back/src/domains/convention/use-cases/notifications/NotifyToAgencyConventionSubmitted.unit.test.ts @@ -3,8 +3,8 @@ import { AgencyWithUsersRights, ConventionDto, ConventionDtoBuilder, + FtConnectIdentity, InclusionConnectedUserBuilder, - PeConnectIdentity, expectToEqual, frontRoutes, } from "shared"; @@ -89,7 +89,7 @@ describe("NotifyToAgencyConventionSubmitted", () => { }, }, ); - const agencyPeWithCouncellors = toAgencyWithRights( + const agencyFtWithCounsellors = toAgencyWithRights( AgencyDtoBuilder.create("agency-pe-with-councellors") .withKind("pole-emploi") @@ -134,7 +134,7 @@ describe("NotifyToAgencyConventionSubmitted", () => { uow.agencyRepository.agencies = [ agencyWithOnlyValidator, agencyWithConsellorsAndValidator, - agencyPeWithCouncellors, + agencyFtWithCounsellors, ]; uow.userRepository.users = [validator, councellor1, councellor2]; expectSavedNotificationsAndEvents = makeExpectSavedNotificationsAndEvents( @@ -299,20 +299,20 @@ describe("NotifyToAgencyConventionSubmitted", () => { "shortlink4", ]; shortLinkIdGeneratorGateway.addMoreShortLinkIds(shortLinkIds); - const peIdentity: PeConnectIdentity = { + const ftIdentity: FtConnectIdentity = { provider: "peConnect", token: "123", }; const validConvention = new ConventionDtoBuilder() - .withAgencyId(agencyPeWithCouncellors.id) - .withFederatedIdentity(peIdentity) + .withAgencyId(agencyFtWithCounsellors.id) + .withFederatedIdentity(ftIdentity) .build(); uow.conventionFranceTravailAdvisorRepository.setConventionFranceTravailUsersAdvisor( [ { conventionId: validConvention.id, - peExternalId: peIdentity.token, + peExternalId: ftIdentity.token, _entityName: "ConventionFranceTravailAdvisor", advisor: undefined, }, @@ -398,26 +398,26 @@ describe("NotifyToAgencyConventionSubmitted", () => { const shortLinkIds = ["shortlink1", "shortlink2"]; shortLinkIdGeneratorGateway.addMoreShortLinkIds(shortLinkIds); - const peAdvisorEmail = "pe-advisor@gmail.com"; - const peIdentity: PeConnectIdentity = { + const ftAdvisorEmail = "ft-advisor@gmail.com"; + const ftIdentity: FtConnectIdentity = { provider: "peConnect", token: "123", }; const validConvention = new ConventionDtoBuilder() - .withAgencyId(agencyPeWithCouncellors.id) - .withFederatedIdentity(peIdentity) + .withAgencyId(agencyFtWithCounsellors.id) + .withFederatedIdentity(ftIdentity) .build(); const userConventionAdvisor: ConventionFtUserAdvisorEntity = { _entityName: "ConventionFranceTravailAdvisor", advisor: { - email: peAdvisorEmail, + email: ftAdvisorEmail, firstName: "Elsa", lastName: "Oldenburg", type: "CAPEMPLOI", }, - peExternalId: peIdentity.token, + peExternalId: ftIdentity.token, conventionId: validConvention.id, }; @@ -434,14 +434,14 @@ describe("NotifyToAgencyConventionSubmitted", () => { id: validConvention.id, role: "validator", targetRoute: frontRoutes.manageConvention, - email: peAdvisorEmail, + email: ftAdvisorEmail, now: timeGateway.now(), }), [shortLinkIds[1]]: fakeGenerateMagicLinkUrlFn({ id: validConvention.id, role: "validator", targetRoute: frontRoutes.conventionStatusDashboard, - email: peAdvisorEmail, + email: ftAdvisorEmail, now: timeGateway.now(), }), }); @@ -450,7 +450,7 @@ describe("NotifyToAgencyConventionSubmitted", () => { emails: [ { kind: "NEW_CONVENTION_AGENCY_NOTIFICATION", - recipients: [peAdvisorEmail], + recipients: [ftAdvisorEmail], params: { internshipKind: validConvention.internshipKind, warning: undefined, diff --git a/back/src/domains/core/authentication/ft-connect/adapters/InMemoryConventionFranceTravailAdvisorRepository.ts b/back/src/domains/core/authentication/ft-connect/adapters/InMemoryConventionFranceTravailAdvisorRepository.ts index 097a906028..53c4d89436 100644 --- a/back/src/domains/core/authentication/ft-connect/adapters/InMemoryConventionFranceTravailAdvisorRepository.ts +++ b/back/src/domains/core/authentication/ft-connect/adapters/InMemoryConventionFranceTravailAdvisorRepository.ts @@ -67,7 +67,7 @@ export class InMemoryConventionFranceTravailAdvisorRepository ): Promise { const entity: ConventionFtUserAdvisorEntity | undefined = this.#conventionFranceTravailUsersAdvisors - .filter(matchPeExternalId(peExternalId)) + .filter(matchFtExternalId(peExternalId)) .find(isOpenEntity); if (entity) return entity; throw errors.convention.missingFTAdvisor({ ftExternalId: peExternalId }); @@ -86,10 +86,10 @@ export class InMemoryConventionFranceTravailAdvisorRepository export const CONVENTION_ID_DEFAULT_UUID = "00000000-0000-0000-0000-000000000000"; -const matchPeExternalId = - (peExternalId: string) => +const matchFtExternalId = + (ftExternalId: string) => (conventionFranceTravailUserAdvisor: ConventionFtUserAdvisorEntity) => - conventionFranceTravailUserAdvisor.peExternalId === peExternalId; + conventionFranceTravailUserAdvisor.peExternalId === ftExternalId; const matchConventionId = (conventionId: string) => diff --git a/back/src/domains/core/authentication/ft-connect/adapters/PgConventionFranceTravailAdvisorRepository.integration.test.ts b/back/src/domains/core/authentication/ft-connect/adapters/PgConventionFranceTravailAdvisorRepository.integration.test.ts index 78189128f0..11e5cc5c43 100644 --- a/back/src/domains/core/authentication/ft-connect/adapters/PgConventionFranceTravailAdvisorRepository.integration.test.ts +++ b/back/src/domains/core/authentication/ft-connect/adapters/PgConventionFranceTravailAdvisorRepository.integration.test.ts @@ -23,7 +23,7 @@ import { FtConnectUserDto } from "../dto/FtConnectUserDto"; import { PgConventionFranceTravailAdvisorRepository } from "./PgConventionFranceTravailAdvisorRepository"; const conventionId = "88401348-bad9-4933-87c6-405b8a8fe4cc"; -const userPeExternalId = "92f44bbf-103d-4312-bd74-217c7d79f618"; +const userFtExternalId = "92f44bbf-103d-4312-bd74-217c7d79f618"; const convention = new ConventionDtoBuilder().withId(conventionId).build(); @@ -32,7 +32,7 @@ const user: FtConnectUserDto = { firstName: "", isJobseeker: true, lastName: "", - peExternalId: userPeExternalId, + peExternalId: userFtExternalId, }; const placementAdvisor: FtConnectImmersionAdvisorDto = { firstName: "Jean", @@ -172,7 +172,7 @@ describe("PgConventionFranceTravailAdvisorRepository", () => { await expect( conventionFranceTravailAdvisorRepository.associateConventionAndUserAdvisor( conventionId, - userPeExternalId, + userFtExternalId, ), ).rejects.toThrow( new Error( @@ -187,7 +187,7 @@ describe("PgConventionFranceTravailAdvisorRepository", () => { ); await conventionFranceTravailAdvisorRepository.associateConventionAndUserAdvisor( conventionId, - userPeExternalId, + userFtExternalId, ); expectToEqual( @@ -223,7 +223,7 @@ describe("PgConventionFranceTravailAdvisorRepository", () => { ); await conventionFranceTravailAdvisorRepository.associateConventionAndUserAdvisor( conventionId, - userPeExternalId, + userFtExternalId, ); const conventionAdvisor: ConventionFtUserAdvisorEntity | undefined = @@ -245,7 +245,7 @@ describe("PgConventionFranceTravailAdvisorRepository", () => { ); await conventionFranceTravailAdvisorRepository.associateConventionAndUserAdvisor( conventionId, - userPeExternalId, + userFtExternalId, ); const conventionAdvisor: ConventionFtUserAdvisorEntity | undefined = diff --git a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway.manual.test.ts b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway.manual.test.ts index d27a8a39d7..e0efd1050b 100644 --- a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway.manual.test.ts +++ b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway.manual.test.ts @@ -16,24 +16,24 @@ import { ExternalFtConnectUser, } from "./ftConnectApi.dto"; import { - makePeConnectExternalRoutes, - toPeConnectAdvisorDto, - toPeConnectUserDto, + makeFtConnectExternalRoutes, + toFtConnectAdvisorDto, + toFtConnectUserDto, } from "./ftConnectApi.routes"; const unhandledStatusCode = 201; -describe("HttpPeConnectGateway", () => { - const routes = makePeConnectExternalRoutes({ - peApiUrl: "https://fake-pe.fr", - peAuthCandidatUrl: "https://fake-pe.fr/auth/candidat", +describe("HttpFtConnectGateway", () => { + const routes = makeFtConnectExternalRoutes({ + ftApiUrl: "https://fake-ft.fr", + ftAuthCandidatUrl: "https://fake-ft.fr/auth/candidat", }); const httpClient = createAxiosSharedClient(routes, axios, { skipResponseValidation: true, }); - const peConnectGateway = new HttpFtConnectGateway(httpClient, { + const ftConnectGateway = new HttpFtConnectGateway(httpClient, { immersionFacileBaseUrl: "https://fake-immersion.fr", franceTravailClientId: "pe-client-id", franceTravailClientSecret: "pe-client-secret", @@ -48,7 +48,7 @@ describe("HttpPeConnectGateway", () => { idIdentiteExterne: "617cd5a3-2cbd-477c-96a0-85d34381f815", sub: "617cd5a3-2cbd-477c-96a0-85d34381f815", }; - const peExternalAdvisorCapemploi: ExternalFtConnectAdvisor = { + const ftExternalAdvisorCapemploi: ExternalFtConnectAdvisor = { type: "CAPEMPLOI", civilite: "1", mail: "capEmploiAdvisor@pe.fr", @@ -62,13 +62,13 @@ describe("HttpPeConnectGateway", () => { nom: "prost", prenom: "alain", }; - const peConnectUser = (isUserJobseeker: boolean) => - toPeConnectUserDto({ ...peExternalUser, isUserJobseeker }); - const peConnectAdvisorPlacement = toPeConnectAdvisorDto( + const ftConnectUser = (isUserJobseeker: boolean) => + toFtConnectUserDto({ ...peExternalUser, isUserJobseeker }); + const ftConnectAdvisorPlacement = toFtConnectAdvisorDto( peExternalAdvisorPlacement, ); - const peConnectAdvisorCapEmploi = toPeConnectAdvisorDto( - peExternalAdvisorCapemploi, + const ftConnectAdvisorCapEmploi = toFtConnectAdvisorDto( + ftExternalAdvisorCapemploi, ); const accessToken = { @@ -86,7 +86,7 @@ describe("HttpPeConnectGateway", () => { mock .onPost(routes.exchangeCodeForAccessToken.url) .reply(200, expectedResponse); - expectObjectsToMatch(await peConnectGateway.getAccessToken(""), { + expectObjectsToMatch(await ftConnectGateway.getAccessToken(""), { expiresIn: expectedResponse.expires_in, value: expectedResponse.access_token, }); @@ -101,7 +101,7 @@ describe("HttpPeConnectGateway", () => { error: "invalid_grant", }); await expectPromiseToFailWithError( - peConnectGateway.getAccessToken(""), + ftConnectGateway.getAccessToken(""), new ManagedRedirectError( "peConnectInvalidGrant", new Error("Request failed with status code 400"), @@ -112,7 +112,7 @@ describe("HttpPeConnectGateway", () => { it("request aborted -> ManagedRedirectError kind peConnectConnectionAborted", async () => { mock.onPost(routes.exchangeCodeForAccessToken.url).abortRequest(); await testManagedRedirectError( - () => peConnectGateway.getAccessToken(""), + () => ftConnectGateway.getAccessToken(""), new ManagedRedirectError("peConnectConnectionAborted", new Error()), ); }); @@ -134,18 +134,18 @@ describe("HttpPeConnectGateway", () => { }); expectObjectsToMatch( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), { - advisors: [peConnectAdvisorPlacement], - user: peConnectUser(true), + advisors: [ftConnectAdvisorPlacement], + user: ftConnectUser(true), }, ); }); - it(`OK with ${peExternalUser.email} user and ${peExternalAdvisorCapemploi.mail} advisor`, async () => { + it(`OK with ${peExternalUser.email} user and ${ftExternalAdvisorCapemploi.mail} advisor`, async () => { mock .onGet(routes.getAdvisorsInfo.url) - .reply(200, [peExternalAdvisorCapemploi]) + .reply(200, [ftExternalAdvisorCapemploi]) .onGet(routes.getUserInfo.url) .reply(200, peExternalUser) .onGet(routes.getUserStatutInfo.url) @@ -155,10 +155,10 @@ describe("HttpPeConnectGateway", () => { }); expectObjectsToMatch( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), { - advisors: [peConnectAdvisorCapEmploi], - user: peConnectUser(true), + advisors: [ftConnectAdvisorCapEmploi], + user: ftConnectUser(true), }, ); }); @@ -174,10 +174,10 @@ describe("HttpPeConnectGateway", () => { }); expectObjectsToMatch( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), { advisors: [], - user: peConnectUser(false), + user: ftConnectUser(false), }, ); }); @@ -188,7 +188,7 @@ describe("HttpPeConnectGateway", () => { // it(`Timeout on getUserInfo -> Retry`, async () => { // mock // .onGet(peConnectTargets(appConfig).getAdvisorsInfo.url) - // .reply(200, [peExternalAdvisorCapemploi]) + // .reply(200, [ftExternalAdvisorCapemploi]) // .onGet(peConnectTargets(appConfig).getUserInfo.url) // .timeout() // /* .onGet(peConnectTargets(appConfig).getUserInfo.url) @@ -198,9 +198,9 @@ describe("HttpPeConnectGateway", () => { // codeStatutIndividu: "1", // libelleStatutIndividu: "Demandeur d’emploi", // }); - // expectObjectsToMatch(await peConnectGateway.getUserAndAdvisors(accessToken), { - // advisors: [peConnectAdvisorCapEmploi], - // user: peConnectUser(true), + // expectObjectsToMatch(await ftConnectGateway.getUserAndAdvisors(accessToken), { + // advisors: [ftConnectAdvisorCapEmploi], + // user: ftConnectUser(true), // }); // }); @@ -216,14 +216,14 @@ describe("HttpPeConnectGateway", () => { libelleStatutIndividu: "Demandeur d’emploi", }); expect( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), ).toBeUndefined(); }); it("Bad status code -> OK with undefined", async () => { mock .onGet(routes.getAdvisorsInfo.url) - .reply(200, [peExternalAdvisorCapemploi]) + .reply(200, [ftExternalAdvisorCapemploi]) .onGet(routes.getUserInfo.url) .reply(unhandledStatusCode, peExternalUser) .onGet(routes.getUserStatutInfo.url) @@ -232,7 +232,7 @@ describe("HttpPeConnectGateway", () => { libelleStatutIndividu: "Demandeur d’emploi", }); expect( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), ).toBeUndefined(); }); @@ -243,7 +243,7 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getUserInfo.url) .abortRequest(); await expectPromiseToFailWithError( - peConnectGateway.getUserAndAdvisors(accessToken), + ftConnectGateway.getUserAndAdvisors(accessToken), new ManagedRedirectError( "peConnectConnectionAborted", new Error("Request aborted"), @@ -258,7 +258,7 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getUserInfo.url) .networkError(); await testRawRedirectError( - () => peConnectGateway.getUserAndAdvisors(accessToken), + () => ftConnectGateway.getUserAndAdvisors(accessToken), new RawRedirectError( "Une erreur est survenue - Erreur réseau", "Nous n’avons pas réussi à joindre pôle emploi connect.", @@ -274,7 +274,7 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getUserInfo.url) .reply(401); await expectPromiseToFailWithError( - peConnectGateway.getUserAndAdvisors(accessToken), + ftConnectGateway.getUserAndAdvisors(accessToken), new ManagedRedirectError( "peConnectGetUserInfoForbiddenAccess", new Error("Request failed with status code 401"), @@ -289,7 +289,7 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getUserInfo.url) .reply(500); await testRawRedirectError( - () => peConnectGateway.getUserAndAdvisors(accessToken), + () => ftConnectGateway.getUserAndAdvisors(accessToken), new RawRedirectError( "Une erreur est survenue - 500", "Nous n’avons pas réussi à récupérer vos informations personnelles pôle emploi connect.", @@ -307,15 +307,15 @@ describe("HttpPeConnectGateway", () => { // /* .onGet(peConnectTargets(appConfig).getUserInfo.url) // .reply(200, peExternalUser)*/ // .onGet(peConnectTargets(appConfig).getAdvisorsInfo.url) - // .reply(200, [peExternalAdvisorCapemploi]) + // .reply(200, [ftExternalAdvisorCapemploi]) // .onGet(peConnectTargets(appConfig).getUserStatutInfo.url) // .reply(200, { // codeStatutIndividu: "1", // libelleStatutIndividu: "Demandeur d’emploi", // }); - // expectObjectsToMatch(await peConnectGateway.getUserAndAdvisors(accessToken), { - // advisors: [peConnectAdvisorCapEmploi], - // user: peConnectUser(true), + // expectObjectsToMatch(await ftConnectGateway.getUserAndAdvisors(accessToken), { + // advisors: [ftConnectAdvisorCapEmploi], + // user: ftConnectUser(true), // }); // }); @@ -331,10 +331,10 @@ describe("HttpPeConnectGateway", () => { libelleStatutIndividu: "Demandeur d’emploi", }); expectObjectsToMatch( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), { advisors: [], - user: peConnectUser(true), + user: ftConnectUser(true), }, ); }); @@ -342,7 +342,7 @@ describe("HttpPeConnectGateway", () => { it("Bad status code -> OK with No advisors", async () => { mock .onGet(routes.getAdvisorsInfo.url) - .reply(unhandledStatusCode, [peExternalAdvisorCapemploi]) + .reply(unhandledStatusCode, [ftExternalAdvisorCapemploi]) .onGet(routes.getUserInfo.url) .reply(200, peExternalUser) .onGet(routes.getUserStatutInfo.url) @@ -351,10 +351,10 @@ describe("HttpPeConnectGateway", () => { libelleStatutIndividu: "Demandeur d’emploi", }); expectObjectsToMatch( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), { advisors: [], - user: peConnectUser(true), + user: ftConnectUser(true), }, ); }); @@ -371,7 +371,7 @@ describe("HttpPeConnectGateway", () => { libelleStatutIndividu: "Demandeur d’emploi", }); await testManagedRedirectError( - () => peConnectGateway.getUserAndAdvisors(accessToken), + () => ftConnectGateway.getUserAndAdvisors(accessToken), new ManagedRedirectError("peConnectConnectionAborted", new Error()), ); }); @@ -388,7 +388,7 @@ describe("HttpPeConnectGateway", () => { libelleStatutIndividu: "Demandeur d’emploi", }); await testRawRedirectError( - () => peConnectGateway.getUserAndAdvisors(accessToken), + () => ftConnectGateway.getUserAndAdvisors(accessToken), new RawRedirectError( "Une erreur est survenue - Erreur réseau", "Nous n’avons pas réussi à joindre pôle emploi connect.", @@ -409,7 +409,7 @@ describe("HttpPeConnectGateway", () => { libelleStatutIndividu: "Demandeur d’emploi", }); await testManagedRedirectError( - () => peConnectGateway.getUserAndAdvisors(accessToken), + () => ftConnectGateway.getUserAndAdvisors(accessToken), new ManagedRedirectError( "peConnectAdvisorForbiddenAccess", new Error(), @@ -429,10 +429,10 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getAdvisorsInfo.url) .reply(500); await expectObjectsToMatch( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), { advisors: [], - user: peConnectUser(true), + user: ftConnectUser(true), }, ); }); @@ -448,10 +448,10 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getUserStatutInfo.url) .reply(200, "UNSUPPORTED RESPONSE"); expectObjectsToMatch( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), { advisors: [], - user: peConnectUser(false), + user: ftConnectUser(false), }, ); }); @@ -459,7 +459,7 @@ describe("HttpPeConnectGateway", () => { it("Bad status code -> OK with No advisors and not jobseeker", async () => { mock .onGet(routes.getAdvisorsInfo.url) - .reply(200, [peExternalAdvisorCapemploi]) + .reply(200, [ftExternalAdvisorCapemploi]) .onGet(routes.getUserInfo.url) .reply(200, peExternalUser) .onGet(routes.getUserStatutInfo.url) @@ -468,10 +468,10 @@ describe("HttpPeConnectGateway", () => { libelleStatutIndividu: "Demandeur d’emploi", }); expectObjectsToMatch( - await peConnectGateway.getUserAndAdvisors(accessToken), + await ftConnectGateway.getUserAndAdvisors(accessToken), { advisors: [], - user: peConnectUser(false), + user: ftConnectUser(false), }, ); }); @@ -485,7 +485,7 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getUserStatutInfo.url) .abortRequest(); await expectPromiseToFailWithError( - peConnectGateway.getUserAndAdvisors(accessToken), + ftConnectGateway.getUserAndAdvisors(accessToken), new ManagedRedirectError( "peConnectConnectionAborted", new Error("Request aborted"), @@ -502,7 +502,7 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getUserStatutInfo.url) .networkError(); await testRawRedirectError( - () => peConnectGateway.getUserAndAdvisors(accessToken), + () => ftConnectGateway.getUserAndAdvisors(accessToken), new RawRedirectError( "Une erreur est survenue - Erreur réseau", "Nous n’avons pas réussi à joindre pôle emploi connect.", @@ -520,7 +520,7 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getUserStatutInfo.url) .reply(401); await expectPromiseToFailWithError( - peConnectGateway.getUserAndAdvisors(accessToken), + ftConnectGateway.getUserAndAdvisors(accessToken), new ManagedRedirectError( "peConnectGetUserStatusInfoForbiddenAccess", new Error("Request failed with status code 401"), @@ -537,7 +537,7 @@ describe("HttpPeConnectGateway", () => { .onGet(routes.getUserStatutInfo.url) .reply(500); await testRawRedirectError( - () => peConnectGateway.getUserAndAdvisors(accessToken), + () => ftConnectGateway.getUserAndAdvisors(accessToken), new RawRedirectError( "Une erreur est survenue - 500", "Nous n’avons pas réussi à récupérer votre status pôle emploi connect.", diff --git a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway.ts b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway.ts index 1be4527d93..6ba94a102e 100644 --- a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway.ts +++ b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/HttpFtConnectGateway.ts @@ -22,17 +22,17 @@ import { FtConnectHeaders, FtConnectOauthConfig, } from "./ftConnectApi.dto"; -import { peConnectErrorStrategy as peConnectAxiosErrorStrategy } from "./ftConnectApi.error"; +import { ftConnectErrorStrategy } from "./ftConnectApi.error"; import { - PeConnectExternalRoutes, + FtConnectExternalRoutes, toAccessToken, - toPeConnectAdvisorDto, - toPeConnectUserDto, + toFtConnectAdvisorDto, + toFtConnectUserDto, } from "./ftConnectApi.routes"; import { - externalPeConnectAdvisorsSchema, - externalPeConnectUserSchema, - externalPeConnectUserStatutSchema, + externalFtConnectAdvisorsSchema, + externalFtConnectUserSchema, + externalFtConnectUserStatutSchema, } from "./ftConnectApi.schema"; const logger = createLogger(__filename); @@ -44,7 +44,7 @@ type CounterType = | "exchangeCodeForAccessToken"; const counterApiKind = "peConnect"; -const makePeConnectLogger = ( +const makeFtConnectLogger = ( logger: OpacifiedLogger, counterType: CounterType, ) => ({ @@ -68,16 +68,16 @@ const makePeConnectLogger = ( }), }); -const getUserStatutInfoLogger = makePeConnectLogger( +const getUserStatutInfoLogger = makeFtConnectLogger( logger, "getUserStatutInfo", ); -const getAdvisorsInfoLogger = makePeConnectLogger(logger, "getAdvisorsInfo"); +const getAdvisorsInfoLogger = makeFtConnectLogger(logger, "getAdvisorsInfo"); -const getUserInfoLogger = makePeConnectLogger(logger, "getUserInfo"); +const getUserInfoLogger = makeFtConnectLogger(logger, "getUserInfo"); -const exchangeCodeForAccessTokenLogger = makePeConnectLogger( +const exchangeCodeForAccessTokenLogger = makeFtConnectLogger( logger, "exchangeCodeForAccessToken", ); @@ -85,9 +85,9 @@ const exchangeCodeForAccessTokenLogger = makePeConnectLogger( const ftConnectMaxRequestsPerInterval = 1; const rate_ms = 1250; -// TODO GERER LE RETRY POUR L'ENSEMBLE DES APPELS PE +// TODO GERER LE RETRY POUR L'ENSEMBLE DES APPELS FT export class HttpFtConnectGateway implements FtConnectGateway { - // PE Connect limit rate at 1 call per 1.2s + // FT Connect limit rate at 1 call per 1.2s #limiter = new Bottleneck({ reservoir: ftConnectMaxRequestsPerInterval, reservoirRefreshInterval: rate_ms, // number of ms @@ -97,7 +97,7 @@ export class HttpFtConnectGateway implements FtConnectGateway { }); constructor( - private httpClient: HttpClient, + private httpClient: HttpClient, private configs: FtConnectOauthConfig, ) {} @@ -143,7 +143,7 @@ export class HttpFtConnectGateway implements FtConnectGateway { }, (payload) => notifyDiscordOnNotError(payload), ); - return managePeConnectError(error, "exchangeCodeForAccessToken", { + return manageFtConnectError(error, "exchangeCodeForAccessToken", { authorization: authorizationCode, }); } @@ -162,19 +162,19 @@ export class HttpFtConnectGateway implements FtConnectGateway { Authorization: `Bearer ${accessToken.value}`, }; - const externalPeUser = await this.#getUserInfo(headers); + const externalFtUser = await this.#getUserInfo(headers); const isUserJobseeker = await this.#userIsJobseeker( headers, - externalPeUser?.idIdentiteExterne, + externalFtUser?.idIdentiteExterne, ); - return externalPeUser + return externalFtUser ? { - user: toPeConnectUserDto({ ...externalPeUser, isUserJobseeker }), + user: toFtConnectUserDto({ ...externalFtUser, isUserJobseeker }), advisors: (isUserJobseeker ? await this.#getAdvisorsInfo(headers) : [] - ).map(toPeConnectAdvisorDto), + ).map(toFtConnectAdvisorDto), } : undefined; } @@ -199,13 +199,13 @@ export class HttpFtConnectGateway implements FtConnectGateway { }); return false; } - const externalPeConnectStatut = parseZodSchemaAndLogErrorOnParsingFailure( - externalPeConnectUserStatutSchema, + const externalFtConnectStatut = parseZodSchemaAndLogErrorOnParsingFailure( + externalFtConnectUserStatutSchema, response.body, logger, ); const isJobSeeker = isJobSeekerFromStatus( - externalPeConnectStatut.codeStatutIndividu, + externalFtConnectStatut.codeStatutIndividu, ); log.success({ ftConnect: { peExternalId, isJobSeeker } }); return isJobSeeker; @@ -219,7 +219,7 @@ export class HttpFtConnectGateway implements FtConnectGateway { ); return error instanceof ZodError ? false - : managePeConnectError(error, "getUserStatutInfo", { + : manageFtConnectError(error, "getUserStatutInfo", { authorization: headers.Authorization, }); } @@ -243,13 +243,13 @@ export class HttpFtConnectGateway implements FtConnectGateway { }); return undefined; } - const externalPeConnectUser = parseZodSchemaAndLogErrorOnParsingFailure( - externalPeConnectUserSchema, + const externalFtConnectUser = parseZodSchemaAndLogErrorOnParsingFailure( + externalFtConnectUserSchema, response.body, logger, ); log.success({}); - return externalPeConnectUser; + return externalFtConnectUser; } catch (error) { errorChecker( error, @@ -259,7 +259,7 @@ export class HttpFtConnectGateway implements FtConnectGateway { (payload) => notifyDiscordOnNotError(payload), ); if (error instanceof ZodError) return undefined; - return managePeConnectError(error, "getUserInfo", { + return manageFtConnectError(error, "getUserInfo", { authorization: headers.Authorization, }); } @@ -283,14 +283,14 @@ export class HttpFtConnectGateway implements FtConnectGateway { }); return []; } - const externalPeConnectAdvisors = + const externalFtConnectAdvisors = parseZodSchemaAndLogErrorOnParsingFailure( - externalPeConnectAdvisorsSchema, + externalFtConnectAdvisorsSchema, response.body, logger, ); log.success({}); - return externalPeConnectAdvisors; + return externalFtConnectAdvisors; } catch (error) { errorChecker( error, @@ -307,16 +307,16 @@ export class HttpFtConnectGateway implements FtConnectGateway { }); return []; } - return managePeConnectError(error, "getAdvisorsInfo", { + return manageFtConnectError(error, "getAdvisorsInfo", { authorization: headers.Authorization, }); } } } -const managePeConnectError = ( +const manageFtConnectError = ( error: unknown, - routeName: keyof PeConnectExternalRoutes, + routeName: keyof FtConnectExternalRoutes, context: Record, ): never => { if (!(error instanceof Error)) @@ -326,12 +326,10 @@ const managePeConnectError = ( ); if (axios.isAxiosError(error)) { logger.error({ - message: `PE CONNECT ERROR - ${routeName}`, + message: `FT CONNECT ERROR - ${routeName}`, error, }); - const handledError = peConnectAxiosErrorStrategy(error, routeName).get( - true, - ); + const handledError = ftConnectErrorStrategy(error, routeName).get(true); if (handledError) throw handledError; throw new UnhandledError("Erreur axios non gérée", error); } @@ -358,7 +356,7 @@ const notifyDiscordOnNotError = (payload: unknown): void => const isJobSeekerFromStatus = (codeStatutIndividu: "0" | "1"): boolean => codeStatutIndividu === "1"; -/** Should not occur if PE apis respect contract => a jobseeker OAuth should have advisors */ +/** Should not occur if FT apis respect contract => a jobseeker OAuth should have advisors */ const isJobseekerButNoAdvisorsResponse = (error: unknown) => axios.isAxiosError(error) && error.response?.status === HTTP_STATUS.INTERNAL_SERVER_ERROR; diff --git a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryPeConnectGateway.ts b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryFtConnectGateway.ts similarity index 84% rename from back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryPeConnectGateway.ts rename to back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryFtConnectGateway.ts index 994ff03e9e..657d947654 100644 --- a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryPeConnectGateway.ts +++ b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryFtConnectGateway.ts @@ -3,7 +3,7 @@ import { FtConnectAdvisorDto } from "../../dto/FtConnectAdvisor.dto"; import { FtConnectUserDto } from "../../dto/FtConnectUserDto"; import { FtConnectGateway } from "../../port/FtConnectGateway"; -export class InMemoryPeConnectGateway implements FtConnectGateway { +export class InMemoryFtConnectGateway implements FtConnectGateway { #accessToken: AccessTokenDto | undefined = undefined; #advisors: FtConnectAdvisorDto[] = []; @@ -24,14 +24,10 @@ export class InMemoryPeConnectGateway implements FtConnectGateway { | undefined > { if (!this.#user) return undefined; - const peUserAndAdvisor: { - user: FtConnectUserDto; - advisors: FtConnectAdvisorDto[]; - } = { + return { advisors: this.#advisors, user: this.#user, }; - return peUserAndAdvisor; } public setAccessToken(accessToken: AccessTokenDto) { diff --git a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.error.ts b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.error.ts index 2eb842d0a0..261398cb9e 100644 --- a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.error.ts +++ b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.error.ts @@ -1,9 +1,9 @@ import { AxiosError } from "axios"; import { HTTP_STATUS, ManagedRedirectError, RawRedirectError } from "shared"; import { UnhandledError } from "../../../../../../config/helpers/handleHttpJsonResponseError"; -import { PeConnectExternalRoutes } from "./ftConnectApi.routes"; +import { FtConnectExternalRoutes } from "./ftConnectApi.routes"; -type PeConnectTargetsKind = keyof PeConnectExternalRoutes; +type FtConnectTargetsKind = keyof FtConnectExternalRoutes; class ConnectionRefusedError extends Error { constructor( @@ -18,9 +18,9 @@ class ConnectionRefusedError extends Error { } // ! In a map the highest priority is given to the lasted entry -export const peConnectErrorStrategy = ( +export const ftConnectErrorStrategy = ( error: AxiosError, - context: PeConnectTargetsKind, + context: FtConnectTargetsKind, ) => new Map([ // Generic catch all Http errors @@ -102,7 +102,7 @@ export const peConnectErrorStrategy = ( ]); const isInvalidGrantError = ( - context: PeConnectTargetsKind, + context: FtConnectTargetsKind, error: AxiosError, ) => context === "exchangeCodeForAccessToken" && @@ -116,21 +116,21 @@ const rawRedirectTitle = (error: AxiosError) => `Une erreur est survenue - ${error.response?.status ?? error.code}`; const isGetUserInfoServerInternalError = ( - context: PeConnectTargetsKind, + context: FtConnectTargetsKind, error: AxiosError, ) => context === "getUserInfo" && error.response?.status === HTTP_STATUS.INTERNAL_SERVER_ERROR; const isGetUserStatusInfoServerInternalError = ( - context: PeConnectTargetsKind, + context: FtConnectTargetsKind, error: AxiosError, ) => context === "getUserStatutInfo" && error.response?.status === HTTP_STATUS.INTERNAL_SERVER_ERROR; const isAdvisorsServerInternalError = ( - context: PeConnectTargetsKind, + context: FtConnectTargetsKind, error: AxiosError, ) => context === "getAdvisorsInfo" && @@ -147,21 +147,21 @@ const makeRawRedirectError = ( const isAdvisorForbiddenError = ( error: AxiosError, - context: PeConnectTargetsKind, + context: FtConnectTargetsKind, ): boolean => error.response?.status === HTTP_STATUS.UNAUTHORIZED && context === "getAdvisorsInfo"; const isGetUserInfoForbiddenError = ( error: AxiosError, - context: PeConnectTargetsKind, + context: FtConnectTargetsKind, ): boolean => error.response?.status === HTTP_STATUS.UNAUTHORIZED && context === "getUserInfo"; const isGetUserStatusInfoForbiddenError = ( error: AxiosError, - context: PeConnectTargetsKind, + context: FtConnectTargetsKind, ): boolean => error.response?.status === HTTP_STATUS.UNAUTHORIZED && context === "getUserStatutInfo"; diff --git a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes.ts b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes.ts index 5f69746423..bb06f84671 100644 --- a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes.ts +++ b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.routes.ts @@ -12,9 +12,9 @@ import { ExternalFtConnectUser, ftConnectAccessTokenHeadersSchema, } from "./ftConnectApi.dto"; -import { peConnectHeadersSchema } from "./ftConnectApi.schema"; +import { ftConnectHeadersSchema } from "./ftConnectApi.schema"; -const peConnectNeededScopesForAllUsedApi = (clientId: string): string => +const ftConnectNeededScopesForAllUsedApi = (clientId: string): string => [ `application_${clientId}`, "api_peconnect-individuv1", @@ -27,13 +27,13 @@ const peConnectNeededScopesForAllUsedApi = (clientId: string): string => "statut", ].join(" "); -type PeConnectRoutesConfig = { - peApiUrl: AbsoluteUrl; - peAuthCandidatUrl: AbsoluteUrl; +type FtConnectRoutesConfig = { + ftApiUrl: AbsoluteUrl; + ftAuthCandidatUrl: AbsoluteUrl; }; -export type PeConnectExternalRoutes = ReturnType< - typeof makePeConnectExternalRoutes +export type FtConnectExternalRoutes = ReturnType< + typeof makeFtConnectExternalRoutes >; const _forceUnknownResponseBody = (responseBody: unknown): unknown => @@ -42,45 +42,45 @@ const _forceUnknownResponseBody = (responseBody: unknown): unknown => // TODO : move the validation here, and adapt the gateways // explicitely : replace forceUnknownResponseBody by validation code made actually on adapter -export const makePeConnectExternalRoutes = ({ - peApiUrl, - peAuthCandidatUrl, -}: PeConnectRoutesConfig) => +export const makeFtConnectExternalRoutes = ({ + ftApiUrl, + ftAuthCandidatUrl, +}: FtConnectRoutesConfig) => defineRoutes({ getAdvisorsInfo: defineRoute({ method: "get", - url: `${peApiUrl}/partenaire/peconnect-conseillers/v1/contactspe/conseillers`, - headersSchema: peConnectHeadersSchema, + url: `${ftApiUrl}/partenaire/peconnect-conseillers/v1/contactspe/conseillers`, + headersSchema: ftConnectHeadersSchema, responses: { 200: z.any() }, }), getUserInfo: defineRoute({ method: "get", - url: `${peApiUrl}/partenaire/peconnect-individu/v1/userinfo`, - headersSchema: peConnectHeadersSchema, + url: `${ftApiUrl}/partenaire/peconnect-individu/v1/userinfo`, + headersSchema: ftConnectHeadersSchema, responses: { 200: z.any() }, }), getUserStatutInfo: defineRoute({ method: "get", - url: `${peApiUrl}/partenaire/peconnect-statut/v1/statut`, - headersSchema: peConnectHeadersSchema, + url: `${ftApiUrl}/partenaire/peconnect-statut/v1/statut`, + headersSchema: ftConnectHeadersSchema, responses: { 200: z.any() }, }), exchangeCodeForAccessToken: defineRoute({ method: "post", - url: `${peAuthCandidatUrl}/connexion/oauth2/access_token?realm=%2Findividu`, + url: `${ftAuthCandidatUrl}/connexion/oauth2/access_token?realm=%2Findividu`, requestBodySchema: z.string(), headersSchema: ftConnectAccessTokenHeadersSchema, responses: { 200: z.any() }, }), }); -export const makePeConnectLoginPageUrl = (appConfig: AppConfig): AbsoluteUrl => +export const makeFtConnectLoginPageUrl = (appConfig: AppConfig): AbsoluteUrl => makeOauthGetAuthorizationCodeRedirectUrl(appConfig.ftAuthCandidatUrl, { response_type: "code", client_id: appConfig.franceTravailClientId, realm: "/individu", redirect_uri: `${appConfig.immersionFacileBaseUrl}/api/pe-connect`, - scope: peConnectNeededScopesForAllUsedApi(appConfig.franceTravailClientId), + scope: ftConnectNeededScopesForAllUsedApi(appConfig.franceTravailClientId), }); const makeOauthGetAuthorizationCodeRedirectUrl = ( @@ -91,7 +91,7 @@ const makeOauthGetAuthorizationCodeRedirectUrl = ( authorizationCodePayload, )}`; -export const toPeConnectAdvisorDto = ( +export const toFtConnectAdvisorDto = ( fromApi: ExternalFtConnectAdvisor, ): FtConnectAdvisorDto => ({ email: fromApi.mail, @@ -100,14 +100,14 @@ export const toPeConnectAdvisorDto = ( type: fromApi.type, }); -export const toPeConnectUserDto = ( - externalPeConnectUser: ExternalFtConnectUser & { isUserJobseeker: boolean }, +export const toFtConnectUserDto = ( + externalFtConnectUser: ExternalFtConnectUser & { isUserJobseeker: boolean }, ): FtConnectUserDto => ({ - isJobseeker: externalPeConnectUser.isUserJobseeker, - email: externalPeConnectUser.email, - firstName: externalPeConnectUser.given_name, - lastName: externalPeConnectUser.family_name, - peExternalId: externalPeConnectUser.idIdentiteExterne, + isJobseeker: externalFtConnectUser.isUserJobseeker, + email: externalFtConnectUser.email, + firstName: externalFtConnectUser.given_name, + lastName: externalFtConnectUser.family_name, + peExternalId: externalFtConnectUser.idIdentiteExterne, }); export const toAccessToken = ( diff --git a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.schema.ts b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.schema.ts index 2143390284..987fc34531 100644 --- a/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.schema.ts +++ b/back/src/domains/core/authentication/ft-connect/adapters/ft-connect-gateway/ftConnectApi.schema.ts @@ -12,7 +12,7 @@ import { FtConnectHeaders, } from "./ftConnectApi.dto"; -export const externalPeConnectUserSchema: z.Schema = +export const externalFtConnectUserSchema: z.Schema = z.object({ email: emailSchema.optional(), family_name: zStringMinLength1, @@ -22,7 +22,7 @@ export const externalPeConnectUserSchema: z.Schema = sub: zStringMinLength1, }); -export const externalPeConnectUserStatutSchema: z.Schema = +export const externalFtConnectUserStatutSchema: z.Schema = z.object({ codeStatutIndividu: z.enum(["0", "1"]), libelleStatutIndividu: z.enum([ @@ -31,25 +31,25 @@ export const externalPeConnectUserStatutSchema: z.Schema = +const ftAdvisorKindSchema: z.Schema = z.enum(ftAdvisorKinds); -const externalPeConnectAdvisorSchema: z.Schema = +const externalftConnectAdvisorSchema: z.Schema = z.object({ nom: zStringMinLength1, prenom: zStringMinLength1, civilite: z.enum(["1", "2"]), mail: emailSchema, - type: peAdvisorKindSchema, + type: ftAdvisorKindSchema, }); -export const externalPeConnectAdvisorsSchema: z.Schema< +export const externalFtConnectAdvisorsSchema: z.Schema< ExternalFtConnectAdvisor[] -> = z.array(externalPeConnectAdvisorSchema); +> = z.array(externalftConnectAdvisorSchema); const bearerSchema = z.string().regex(/^Bearer .+$/) as z.Schema; -export const peConnectHeadersSchema: z.Schema = z +export const ftConnectHeadersSchema: z.Schema = z .object({ "Content-Type": z.literal("application/json"), Accept: z.literal("application/json"), diff --git a/back/src/domains/core/authentication/ft-connect/dto/FtConnect.dto.ts b/back/src/domains/core/authentication/ft-connect/dto/FtConnect.dto.ts index be419b347a..4a32c5dec3 100644 --- a/back/src/domains/core/authentication/ft-connect/dto/FtConnect.dto.ts +++ b/back/src/domains/core/authentication/ft-connect/dto/FtConnect.dto.ts @@ -36,7 +36,7 @@ export type FtUserAndAdvisor = { user: FtConnectUserDto; }; -export const toPartialConventionDtoWithPeIdentity = ( +export const toPartialConventionDtoWithFtIdentity = ( ftConnectUserInfo: FtConnectUserDto, ): ConventionFtConnectFields => ({ email: ftConnectUserInfo.email || "", diff --git a/back/src/domains/core/authentication/ft-connect/use-cases/BindConventionToFederatedIdentity.ts b/back/src/domains/core/authentication/ft-connect/use-cases/BindConventionToFederatedIdentity.ts index 2097a1867a..d7881b3bda 100644 --- a/back/src/domains/core/authentication/ft-connect/use-cases/BindConventionToFederatedIdentity.ts +++ b/back/src/domains/core/authentication/ft-connect/use-cases/BindConventionToFederatedIdentity.ts @@ -1,9 +1,9 @@ import { ConventionDto, - PeConnectIdentity, + FtConnectIdentity, WithConventionDto, authFailed, - isPeConnectIdentity, + isFtConnectIdentity, withConventionSchema, } from "shared"; import { TransactionalUseCase } from "../../../UseCase"; @@ -32,7 +32,7 @@ export class BindConventionToFederatedIdentity extends TransactionalUseCase { try { diff --git a/back/src/domains/core/authentication/ft-connect/use-cases/BindConventionToFederatedIdentity.unit.test.ts b/back/src/domains/core/authentication/ft-connect/use-cases/BindConventionToFederatedIdentity.unit.test.ts index 393ae9b092..62a1f99ec6 100644 --- a/back/src/domains/core/authentication/ft-connect/use-cases/BindConventionToFederatedIdentity.unit.test.ts +++ b/back/src/domains/core/authentication/ft-connect/use-cases/BindConventionToFederatedIdentity.unit.test.ts @@ -21,8 +21,8 @@ import { FtUserAndAdvisor } from "../dto/FtConnect.dto"; import { conventionFranceTravailUserAdvisorFromDto } from "../entities/ConventionFranceTravailAdvisorEntity"; import { BindConventionToFederatedIdentity } from "./BindConventionToFederatedIdentity"; -describe("AssociatePeConnectFederatedIdentity", () => { - let associatePeConnectFederatedIdentity: BindConventionToFederatedIdentity; +describe("AssociateFtConnectFederatedIdentity", () => { + let associateFtConnectFederatedIdentity: BindConventionToFederatedIdentity; let uowPerformer: InMemoryUowPerformer; let conventionFranceTravailAdvisorRepo: InMemoryConventionFranceTravailAdvisorRepository; let outboxRepo: InMemoryOutboxRepository; @@ -40,7 +40,7 @@ describe("AssociatePeConnectFederatedIdentity", () => { uuidGenerator, }); - associatePeConnectFederatedIdentity = new BindConventionToFederatedIdentity( + associateFtConnectFederatedIdentity = new BindConventionToFederatedIdentity( uowPerformer, createNewEvent, ); @@ -55,7 +55,7 @@ describe("AssociatePeConnectFederatedIdentity", () => { topic: "FederatedIdentityNotBoundToConvention", payload: { convention: conventionDtoFromEvent, triggeredBy: null }, }); - await associatePeConnectFederatedIdentity.execute({ + await associateFtConnectFederatedIdentity.execute({ convention: conventionDtoFromEvent, }); @@ -71,7 +71,7 @@ describe("AssociatePeConnectFederatedIdentity", () => { .withFederatedIdentity({ provider: "peConnect", token: authFailed }) .build(); - await associatePeConnectFederatedIdentity.execute({ + await associateFtConnectFederatedIdentity.execute({ convention: conventionDtoFromEvent, }); @@ -97,10 +97,10 @@ describe("AssociatePeConnectFederatedIdentity", () => { const conventionDtoFromEvent = new ConventionDtoBuilder() .withId(conventionId) - .withFederatedIdentity({ provider: "peConnect", token: userPeExternalId }) + .withFederatedIdentity({ provider: "peConnect", token: userFtExternalId }) .build(); - await associatePeConnectFederatedIdentity.execute({ + await associateFtConnectFederatedIdentity.execute({ convention: conventionDtoFromEvent, }); @@ -114,7 +114,7 @@ describe("AssociatePeConnectFederatedIdentity", () => { ).toBe(conventionId); }); - it("should save event PeConnectFederatedIdentityAssociated", async () => { + it("should save event FtConnectFederatedIdentityAssociated", async () => { conventionFranceTravailAdvisorRepo.setConventionFranceTravailUsersAdvisor([ conventionFranceTravailUserAdvisorFromDto( userAdvisorDto, @@ -124,10 +124,10 @@ describe("AssociatePeConnectFederatedIdentity", () => { const conventionDtoFromEvent = new ConventionDtoBuilder() .withId(conventionId) - .withFederatedIdentity({ provider: "peConnect", token: userPeExternalId }) + .withFederatedIdentity({ provider: "peConnect", token: userFtExternalId }) .build(); - await associatePeConnectFederatedIdentity.execute({ + await associateFtConnectFederatedIdentity.execute({ convention: conventionDtoFromEvent, }); @@ -156,10 +156,10 @@ describe("AssociatePeConnectFederatedIdentity", () => { const conventionDtoFromEvent = new ConventionDtoBuilder() .withId(conventionId) - .withFederatedIdentity({ provider: "peConnect", token: userPeExternalId }) + .withFederatedIdentity({ provider: "peConnect", token: userFtExternalId }) .build(); - await associatePeConnectFederatedIdentity.execute({ + await associateFtConnectFederatedIdentity.execute({ convention: conventionDtoFromEvent, }); @@ -182,10 +182,10 @@ describe("AssociatePeConnectFederatedIdentity", () => { const conventionDtoFromEvent = new ConventionDtoBuilder() .withId(conventionId) - .withFederatedIdentity({ provider: "peConnect", token: userPeExternalId }) + .withFederatedIdentity({ provider: "peConnect", token: userFtExternalId }) .build(); - await associatePeConnectFederatedIdentity.execute({ + await associateFtConnectFederatedIdentity.execute({ convention: conventionDtoFromEvent, }); @@ -204,7 +204,7 @@ describe("AssociatePeConnectFederatedIdentity", () => { }); const conventionId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; -const userPeExternalId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; +const userFtExternalId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; const userAdvisorDto: FtUserAndAdvisor = { advisor: { email: "elsa.oldenburg@pole-emploi.net", @@ -213,7 +213,7 @@ const userAdvisorDto: FtUserAndAdvisor = { type: "CAPEMPLOI", }, user: { - peExternalId: userPeExternalId, + peExternalId: userFtExternalId, email: "", firstName: "", isJobseeker: true, diff --git a/back/src/domains/core/authentication/ft-connect/use-cases/LinkFranceTravailAdvisorAndRedirectToConvention.ts b/back/src/domains/core/authentication/ft-connect/use-cases/LinkFranceTravailAdvisorAndRedirectToConvention.ts index d7abf585a6..0faebe3527 100644 --- a/back/src/domains/core/authentication/ft-connect/use-cases/LinkFranceTravailAdvisorAndRedirectToConvention.ts +++ b/back/src/domains/core/authentication/ft-connect/use-cases/LinkFranceTravailAdvisorAndRedirectToConvention.ts @@ -12,7 +12,7 @@ import { AccessTokenDto } from "../dto/AccessToken.dto"; import { ConventionFtConnectFields, FtUserAndAdvisor, - toPartialConventionDtoWithPeIdentity, + toPartialConventionDtoWithFtIdentity, } from "../dto/FtConnect.dto"; import { chooseValidAdvisor } from "../entities/ConventionFranceTravailAdvisorEntity"; import { FtConnectGateway } from "../port/FtConnectGateway"; @@ -29,13 +29,13 @@ export class LinkFranceTravailAdvisorAndRedirectToConvention extends Transaction constructor( uowPerformer: UnitOfWorkPerformer, - peConnectGateway: FtConnectGateway, + ftConnectGateway: FtConnectGateway, baseUrlForRedirect: AbsoluteUrl, ) { super(uowPerformer); this.#baseUrlForRedirect = baseUrlForRedirect; - this.#ftConnectGateway = peConnectGateway; + this.#ftConnectGateway = ftConnectGateway; } protected async _execute( @@ -80,6 +80,6 @@ export class LinkFranceTravailAdvisorAndRedirectToConvention extends Transaction peUserAndAdvisor, ); - return this.#makeRedirectUrl(toPartialConventionDtoWithPeIdentity(user)); + return this.#makeRedirectUrl(toPartialConventionDtoWithFtIdentity(user)); } } diff --git a/back/src/domains/core/authentication/ft-connect/use-cases/LinkFranceTravailAdvisorAndRedirectToConvention.unit.test.ts b/back/src/domains/core/authentication/ft-connect/use-cases/LinkFranceTravailAdvisorAndRedirectToConvention.unit.test.ts index c36874a0f9..a6d6d3e507 100644 --- a/back/src/domains/core/authentication/ft-connect/use-cases/LinkFranceTravailAdvisorAndRedirectToConvention.unit.test.ts +++ b/back/src/domains/core/authentication/ft-connect/use-cases/LinkFranceTravailAdvisorAndRedirectToConvention.unit.test.ts @@ -5,7 +5,7 @@ import { createInMemoryUow, } from "../../../unit-of-work/adapters/createInMemoryUow"; import { CONVENTION_ID_DEFAULT_UUID } from "../adapters/InMemoryConventionFranceTravailAdvisorRepository"; -import { InMemoryPeConnectGateway } from "../adapters/ft-connect-gateway/InMemoryPeConnectGateway"; +import { InMemoryFtConnectGateway } from "../adapters/ft-connect-gateway/InMemoryFtConnectGateway"; import { AccessTokenDto } from "../dto/AccessToken.dto"; import { FtConnectAdvisorDto, @@ -18,15 +18,15 @@ import { LinkFranceTravailAdvisorAndRedirectToConvention } from "./LinkFranceTra describe("LinkFranceTravailAdvisorAndRedirectToConvention", () => { let uow: InMemoryUnitOfWork; let linkFtAdvisorAndRedirectToConvention: LinkFranceTravailAdvisorAndRedirectToConvention; - let ftConnectGateway: InMemoryPeConnectGateway; + let ftConnectGateway: InMemoryFtConnectGateway; const baseurl = "https://plop"; - const userPeExternalId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; + const userFtExternalId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; const authorizationCode = "123"; beforeEach(() => { uow = createInMemoryUow(); - ftConnectGateway = new InMemoryPeConnectGateway(); + ftConnectGateway = new InMemoryFtConnectGateway(); linkFtAdvisorAndRedirectToConvention = new LinkFranceTravailAdvisorAndRedirectToConvention( new InMemoryUowPerformer(uow), @@ -35,7 +35,7 @@ describe("LinkFranceTravailAdvisorAndRedirectToConvention", () => { ); }); - describe("Pe Connect correctly identify OAuth", () => { + describe("Ft Connect correctly identify OAuth", () => { it("the returned conventionAdvisor gets stored", async () => { ftConnectGateway.setAccessToken(accessToken); ftConnectGateway.setUser(ftJobseekerUser); @@ -96,13 +96,13 @@ describe("LinkFranceTravailAdvisorAndRedirectToConvention", () => { await linkFtAdvisorAndRedirectToConvention.execute(authorizationCode); expect(urlWithQueryParams).toBe( - `${baseurl}/demande-immersion?email=john.doe@gmail.com&firstName=John&lastName=Doe&fedId=${userPeExternalId}&fedIdProvider=peConnect`, + `${baseurl}/demande-immersion?email=john.doe@gmail.com&firstName=John&lastName=Doe&fedId=${userFtExternalId}&fedIdProvider=peConnect`, ); }); }); describe("Wrong path", () => { - it("On PeConnect auth failure", async () => { + it("On FtConnect auth failure", async () => { const urlWithQueryParams = await linkFtAdvisorAndRedirectToConvention.execute(authorizationCode); @@ -116,7 +116,7 @@ describe("LinkFranceTravailAdvisorAndRedirectToConvention", () => { ); }); - it("On PeConnect not user info", async () => { + it("On FtConnect not user info", async () => { ftConnectGateway.setAccessToken(accessToken); ftConnectGateway.setUser(undefined); ftConnectGateway.setAdvisors([ftPlacementAdvisor]); @@ -133,7 +133,7 @@ describe("LinkFranceTravailAdvisorAndRedirectToConvention", () => { ); }); - it("On PeConnected and is not jobseeker should not open slot and provide convention url with notJobSeeker peConnect mode", async () => { + it("On FtConnected and is not jobseeker should not open slot and provide convention url with notJobSeeker peConnect mode", async () => { ftConnectGateway.setAccessToken(accessToken); ftConnectGateway.setUser(ftNotJobseekerUser); @@ -151,7 +151,7 @@ describe("LinkFranceTravailAdvisorAndRedirectToConvention", () => { }); }); - it("On PeConnected and is jobseeker but no advisors should open slot", async () => { + it("On FtConnected and is jobseeker but no advisors should open slot", async () => { ftConnectGateway.setAccessToken(accessToken); ftConnectGateway.setUser(ftJobseekerUser); diff --git a/back/src/domains/core/authentication/ft-connect/use-cases/NotifyFranceTravailUserAdvisorOnConventionFullySigned.ts b/back/src/domains/core/authentication/ft-connect/use-cases/NotifyFranceTravailUserAdvisorOnConventionFullySigned.ts index 67668b26c2..b7c26ebee4 100644 --- a/back/src/domains/core/authentication/ft-connect/use-cases/NotifyFranceTravailUserAdvisorOnConventionFullySigned.ts +++ b/back/src/domains/core/authentication/ft-connect/use-cases/NotifyFranceTravailUserAdvisorOnConventionFullySigned.ts @@ -32,7 +32,7 @@ export class NotifyFranceTravailUserAdvisorOnConventionFullySigned extends Trans { convention: conventionFromEvent }: WithConventionDto, uow: UnitOfWork, ): Promise { - const [conventionPeAdvisor, convention] = await Promise.all([ + const [conventionFtAdvisor, convention] = await Promise.all([ uow.conventionFranceTravailAdvisorRepository.getByConventionId( conventionFromEvent.id, ), @@ -43,15 +43,15 @@ export class NotifyFranceTravailUserAdvisorOnConventionFullySigned extends Trans const [agency] = await uow.agencyRepository.getByIds([convention.agencyId]); - if (conventionPeAdvisor?.advisor && agency) + if (conventionFtAdvisor?.advisor && agency) await this.#saveNotificationAndRelatedEvent(uow, { kind: "email", templatedContent: { kind: "POLE_EMPLOI_ADVISOR_ON_CONVENTION_FULLY_SIGNED", - recipients: [conventionPeAdvisor.advisor.email], + recipients: [conventionFtAdvisor.advisor.email], params: { - advisorFirstName: conventionPeAdvisor.advisor.firstName, - advisorLastName: conventionPeAdvisor.advisor.lastName, + advisorFirstName: conventionFtAdvisor.advisor.firstName, + advisorLastName: conventionFtAdvisor.advisor.lastName, agencyLogoUrl: agency.logoUrl ?? undefined, beneficiaryFirstName: convention.signatories.beneficiary.firstName, beneficiaryLastName: convention.signatories.beneficiary.lastName, @@ -65,7 +65,7 @@ export class NotifyFranceTravailUserAdvisorOnConventionFullySigned extends Trans id: convention.id, role: "validator", targetRoute: frontRoutes.manageConvention, - email: conventionPeAdvisor.advisor.email, + email: conventionFtAdvisor.advisor.email, now: this.#timeGateway.now(), }), }, diff --git a/back/src/domains/core/authentication/ft-connect/use-cases/NotifyFranceTravailUserAdvisorOnConventionFullySigned.unit.test.ts b/back/src/domains/core/authentication/ft-connect/use-cases/NotifyFranceTravailUserAdvisorOnConventionFullySigned.unit.test.ts index 672b03f42e..20b5906fdf 100644 --- a/back/src/domains/core/authentication/ft-connect/use-cases/NotifyFranceTravailUserAdvisorOnConventionFullySigned.unit.test.ts +++ b/back/src/domains/core/authentication/ft-connect/use-cases/NotifyFranceTravailUserAdvisorOnConventionFullySigned.unit.test.ts @@ -24,7 +24,7 @@ import { NotifyFranceTravailUserAdvisorOnConventionFullySigned } from "./NotifyF describe("NotifyFranceTravailUserAdvisorOnConventionFullySigned", () => { const conventionId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; - const userPeExternalId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; + const userFtExternalId = "749dd14f-c82a-48b1-b1bb-fffc5467e4d4"; const advisor: FtConnectImmersionAdvisorDto = { email: "elsa.oldenburg@pole-emploi.net", firstName: "Elsa", @@ -34,7 +34,7 @@ describe("NotifyFranceTravailUserAdvisorOnConventionFullySigned", () => { const userAdvisorDto: FtUserAndAdvisor = { advisor, user: { - peExternalId: userPeExternalId, + peExternalId: userFtExternalId, email: "", firstName: "", isJobseeker: true, @@ -87,7 +87,7 @@ describe("NotifyFranceTravailUserAdvisorOnConventionFullySigned", () => { const conventionDtoFromEvent = new ConventionDtoBuilder() .withId(conventionId) .withAgencyId(agency.id) - .withFederatedIdentity({ provider: "peConnect", token: userPeExternalId }) + .withFederatedIdentity({ provider: "peConnect", token: userFtExternalId }) .withBeneficiaryFirstName("John") .withBeneficiaryLastName("Doe") .withBeneficiaryEmail("john.doe@plop.fr") @@ -154,7 +154,7 @@ describe("NotifyFranceTravailUserAdvisorOnConventionFullySigned", () => { const conventionDtoFromEvent = new ConventionDtoBuilder() .withId(conventionId) .withAgencyId(agency.id) - .withFederatedIdentity({ provider: "peConnect", token: userPeExternalId }) + .withFederatedIdentity({ provider: "peConnect", token: userFtExternalId }) .withBeneficiaryFirstName("John") .withBeneficiaryLastName("Doe") .withBeneficiaryEmail("john.doe@plop.fr") diff --git a/back/src/domains/establishment/adapters/la-bonne-boite/HttpLaBonneBoiteGateway.manual.test.ts b/back/src/domains/establishment/adapters/la-bonne-boite/HttpLaBonneBoiteGateway.manual.test.ts index 559b25c795..d5587e1cfc 100644 --- a/back/src/domains/establishment/adapters/la-bonne-boite/HttpLaBonneBoiteGateway.manual.test.ts +++ b/back/src/domains/establishment/adapters/la-bonne-boite/HttpLaBonneBoiteGateway.manual.test.ts @@ -4,7 +4,7 @@ import { AccessTokenResponse, AppConfig, } from "../../../../config/bootstrap/appConfig"; -import { createPeFetchSharedClient } from "../../../../config/helpers/createFetchSharedClients"; +import { createFtFetchSharedClient } from "../../../../config/helpers/createFetchSharedClients"; import { HttpFranceTravailGateway } from "../../../convention/adapters/france-travail-gateway/HttpFranceTravailGateway"; import { InMemoryCachingGateway } from "../../../core/caching-gateway/adapters/InMemoryCachingGateway"; import { noRetries } from "../../../core/retry-strategy/ports/RetryStrategy"; @@ -51,7 +51,7 @@ describe("HttpLaBonneBoiteGateway", () => { beforeEach(() => { const config = AppConfig.createFromEnv(); - const peFetchSharedClient = createPeFetchSharedClient(config); + const peFetchSharedClient = createFtFetchSharedClient(config); laBonneBoiteGateway = new HttpLaBonneBoiteGateway( createFetchSharedClient(createLbbRoutes(config.ftApiUrl), fetch), new HttpFranceTravailGateway( diff --git a/back/src/domains/establishment/ports/PeAgenciesReferential.ts b/back/src/domains/establishment/ports/FtAgenciesReferential.ts similarity index 76% rename from back/src/domains/establishment/ports/PeAgenciesReferential.ts rename to back/src/domains/establishment/ports/FtAgenciesReferential.ts index 30148e32f5..f10ab619f9 100644 --- a/back/src/domains/establishment/ports/PeAgenciesReferential.ts +++ b/back/src/domains/establishment/ports/FtAgenciesReferential.ts @@ -1,8 +1,8 @@ -export interface PeAgenciesReferential { - getPeAgencies: () => Promise; +export interface FtAgenciesReferential { + getFtAgencies: () => Promise; } -export type PeAgencyFromReferenciel = { +export type FtAgencyFromReferential = { code: string; codeSafir: string; libelle: string; diff --git a/back/src/scripts/triggerResyncOldConventionsToPe.ts b/back/src/scripts/triggerResyncOldConventionsToPe.ts index 40787b835b..a99d9e9aeb 100644 --- a/back/src/scripts/triggerResyncOldConventionsToPe.ts +++ b/back/src/scripts/triggerResyncOldConventionsToPe.ts @@ -1,6 +1,6 @@ import { AccessTokenResponse, AppConfig } from "../config/bootstrap/appConfig"; import { createGetPgPoolFn } from "../config/bootstrap/createGateways"; -import { createPeAxiosSharedClient } from "../config/helpers/createAxiosSharedClients"; +import { createFtAxiosSharedClient } from "../config/helpers/createAxiosSharedClients"; import { HttpFranceTravailGateway } from "../domains/convention/adapters/france-travail-gateway/HttpFranceTravailGateway"; import { ResyncOldConventionsToFt } from "../domains/convention/use-cases/ResyncOldConventionsToFt"; import { InMemoryCachingGateway } from "../domains/core/caching-gateway/adapters/InMemoryCachingGateway"; @@ -16,7 +16,7 @@ const config = AppConfig.createFromEnv(); const executeUsecase = async () => { const timeGateway = new RealTimeGateway(); - const peAxiosHttpClient = createPeAxiosSharedClient(config); + const peAxiosHttpClient = createFtAxiosSharedClient(config); const httpFranceTravailGateway = new HttpFranceTravailGateway( peAxiosHttpClient, diff --git a/back/src/scripts/triggerUpdateLegacyRomeV3.ts b/back/src/scripts/triggerUpdateLegacyRomeV3.ts index 861b32680d..d413aba232 100644 --- a/back/src/scripts/triggerUpdateLegacyRomeV3.ts +++ b/back/src/scripts/triggerUpdateLegacyRomeV3.ts @@ -5,7 +5,7 @@ import { map, splitEvery } from "ramda"; import { AppellationCode, RomeCode, pipeWithValue } from "shared"; import { createAxiosSharedClient } from "shared-routes/axios"; import { AccessTokenResponse, AppConfig } from "../config/bootstrap/appConfig"; -import { createPeAxiosSharedClient } from "../config/helpers/createAxiosSharedClients"; +import { createFtAxiosSharedClient } from "../config/helpers/createAxiosSharedClients"; import { KyselyDb, makeKyselyDb, @@ -14,7 +14,7 @@ import { import { HttpRome3Gateway, makeRome3Routes, -} from "../domains/agency/adapters/pe-agencies-referential/HttpRome3Gateway"; +} from "../domains/agency/adapters/ft-agencies-referential/HttpRome3Gateway"; import { HttpFranceTravailGateway } from "../domains/convention/adapters/france-travail-gateway/HttpFranceTravailGateway"; import { InMemoryCachingGateway } from "../domains/core/caching-gateway/adapters/InMemoryCachingGateway"; import { noRetries } from "../domains/core/retry-strategy/ports/RetryStrategy"; @@ -38,7 +38,7 @@ const main = async () => { ); const franceTravailGateway = new HttpFranceTravailGateway( - createPeAxiosSharedClient(config), + createFtAxiosSharedClient(config), cachingGateway, config.ftApiUrl, config.franceTravailAccessTokenConfig, diff --git a/back/src/scripts/triggerUpdateRomeData.ts b/back/src/scripts/triggerUpdateRomeData.ts index f591378d1c..653b7acc45 100644 --- a/back/src/scripts/triggerUpdateRomeData.ts +++ b/back/src/scripts/triggerUpdateRomeData.ts @@ -5,13 +5,13 @@ import { map, splitEvery } from "ramda"; import { pipeWithValue, removeDiacritics, sleep } from "shared"; import { createAxiosSharedClient } from "shared-routes/axios"; import { AccessTokenResponse, AppConfig } from "../config/bootstrap/appConfig"; -import { createPeAxiosSharedClient } from "../config/helpers/createAxiosSharedClients"; +import { createFtAxiosSharedClient } from "../config/helpers/createAxiosSharedClients"; import { KyselyDb, makeKyselyDb } from "../config/pg/kysely/kyselyUtils"; import { AppellationWithShortLabel, HttpRome4Gateway, makeRome4Routes, -} from "../domains/agency/adapters/pe-agencies-referential/HttpRome4Gateway"; +} from "../domains/agency/adapters/ft-agencies-referential/HttpRome4Gateway"; import { HttpFranceTravailGateway } from "../domains/convention/adapters/france-travail-gateway/HttpFranceTravailGateway"; import { InMemoryCachingGateway } from "../domains/core/caching-gateway/adapters/InMemoryCachingGateway"; import { noRetries } from "../domains/core/retry-strategy/ports/RetryStrategy"; @@ -38,7 +38,7 @@ const main = async () => { ); const franceTravailGateway = new HttpFranceTravailGateway( - createPeAxiosSharedClient(config), + createFtAxiosSharedClient(config), cachingGateway, config.ftApiUrl, config.franceTravailAccessTokenConfig, diff --git a/back/src/utils/buildTestApp.ts b/back/src/utils/buildTestApp.ts index e5a9e42bf8..7d67bc1ca5 100644 --- a/back/src/utils/buildTestApp.ts +++ b/back/src/utils/buildTestApp.ts @@ -6,7 +6,7 @@ import { createApp } from "../config/bootstrap/server"; import { InMemoryFranceTravailGateway } from "../domains/convention/adapters/france-travail-gateway/InMemoryFranceTravailGateway"; import { InMemoryAddressGateway } from "../domains/core/address/adapters/InMemoryAddressGateway"; import { InMemorySubscribersGateway } from "../domains/core/api-consumer/adapters/InMemorySubscribersGateway"; -import { InMemoryPeConnectGateway } from "../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryPeConnectGateway"; +import { InMemoryFtConnectGateway } from "../domains/core/authentication/ft-connect/adapters/ft-connect-gateway/InMemoryFtConnectGateway"; import { InMemoryOAuthGateway } from "../domains/core/authentication/inclusion-connect/adapters/oauth-gateway/InMemoryOAuthGateway"; import { StubDashboardGateway } from "../domains/core/dashboard/adapters/StubDashboardGateway"; import { InMemoryEmailValidationGateway } from "../domains/core/email-validation/adapters/InMemoryEmailValidationGateway"; @@ -35,7 +35,7 @@ import { toAgencyWithRights } from "./agency"; export type InMemoryGateways = { disconnectCache: () => Promise; notification: InMemoryNotificationGateway; - peConnectGateway: InMemoryPeConnectGateway; + ftConnectGateway: InMemoryFtConnectGateway; siret: InMemorySiretGateway; pdfGeneratorGateway: InMemoryPdfGeneratorGateway; laBonneBoiteGateway: InMemoryLaBonneBoiteGateway; diff --git a/back/src/utils/logger.ts b/back/src/utils/logger.ts index beb4001b0e..a60c31d9bf 100644 --- a/back/src/utils/logger.ts +++ b/back/src/utils/logger.ts @@ -223,7 +223,7 @@ export const createLogger = (filename: string): OpacifiedLogger => { events: sanitizeEvents(events), nodeProcessReport, notificationId, - ftConnect: ftConnect, + ftConnect, reportContent, request, requestId, diff --git a/front/src/app/components/forms/convention/ConventionForm.tsx b/front/src/app/components/forms/convention/ConventionForm.tsx index 1a711d6f46..4089d2193b 100644 --- a/front/src/app/components/forms/convention/ConventionForm.tsx +++ b/front/src/app/components/forms/convention/ConventionForm.tsx @@ -33,7 +33,7 @@ import { hasBeneficiaryCurrentEmployer, isBeneficiaryMinor, isEstablishmentTutorIsEstablishmentRepresentative, - isPeConnectIdentity, + isFtConnectIdentity, keys, notJobSeeker, } from "shared"; @@ -291,7 +291,7 @@ export const ConventionForm = ({ const shouldLockToPeAgencies = !!( route.name === "conventionImmersion" && route.params.jwt && - isPeConnectIdentity( + isFtConnectIdentity( conventionValues?.signatories.beneficiary.federatedIdentity, ) ); @@ -612,7 +612,7 @@ const makeListAgencyOptionsKindFilter = ({ }): AgencyKindFilter => { if (internshipKind === "mini-stage-cci") return "miniStageOnly"; if (shouldListAll) return "miniStageExcluded"; - return federatedIdentity && isPeConnectIdentity(federatedIdentity) + return federatedIdentity && isFtConnectIdentity(federatedIdentity) ? "immersionPeOnly" : "miniStageExcluded"; }; @@ -623,7 +623,7 @@ const makeInitialBenefiaryForm = ( ): Beneficiary<"immersion" | "mini-stage-cci"> => { const { federatedIdentity, ...beneficiaryOtherProperties } = beneficiary; const peConnectIdentity = - federatedIdentityWithUser && isPeConnectIdentity(federatedIdentityWithUser) + federatedIdentityWithUser && isFtConnectIdentity(federatedIdentityWithUser) ? federatedIdentityWithUser : undefined; const federatedIdentityValue = federatedIdentity ?? peConnectIdentity; diff --git a/front/src/app/pages/convention/ConventionImmersionPage.tsx b/front/src/app/pages/convention/ConventionImmersionPage.tsx index 325f18acf0..37dd13497f 100644 --- a/front/src/app/pages/convention/ConventionImmersionPage.tsx +++ b/front/src/app/pages/convention/ConventionImmersionPage.tsx @@ -4,7 +4,7 @@ import { keys } from "ramda"; import React, { useEffect, useMemo, useRef, useState } from "react"; import { Loader, MainWrapper, PageHeader } from "react-design-system"; import { useDispatch } from "react-redux"; -import { FederatedIdentityProvider, loginPeConnect } from "shared"; +import { FederatedIdentityProvider, loginFtConnect } from "shared"; import { Breadcrumbs } from "src/app/components/Breadcrumbs"; import { ConventionFormMode, @@ -215,7 +215,7 @@ const SharedConventionMessage = ({

{/* biome-ignore lint/a11y/useValidAnchor: This is a trusted source */} { storeConventionRouteParamsOnDevice(route.params); }} diff --git a/front/src/app/pages/convention/InitiateConventionPage.tsx b/front/src/app/pages/convention/InitiateConventionPage.tsx index 32e256e5de..d508f8dd40 100644 --- a/front/src/app/pages/convention/InitiateConventionPage.tsx +++ b/front/src/app/pages/convention/InitiateConventionPage.tsx @@ -1,7 +1,7 @@ import { fr } from "@codegouvfr/react-dsfr/fr"; import { useState } from "react"; import { MainWrapper, NavCard, PageHeader } from "react-design-system"; -import { domElementIds, loginPeConnect } from "shared"; +import { domElementIds, loginFtConnect } from "shared"; import { Breadcrumbs } from "src/app/components/Breadcrumbs"; import { HeaderFooterLayout } from "src/app/components/layout/HeaderFooterLayout"; import { routes, useRoute } from "src/app/routes/routes"; @@ -120,7 +120,7 @@ export const InitiateConventionPage = () => { total={1} id={domElementIds.initiateConvention.ftConnectButton} link={{ - href: `/api/${loginPeConnect}`, + href: `/api/${loginFtConnect}`, }} alternateTitle="Je suis accompagné(e) par mon conseiller France Travail et je peux me connecter via FranceConnect" withBorder diff --git a/front/src/app/routes/routeParams/convention.ts b/front/src/app/routes/routeParams/convention.ts index 3dd7e7b06b..effa1cf94c 100644 --- a/front/src/app/routes/routeParams/convention.ts +++ b/front/src/app/routes/routeParams/convention.ts @@ -6,10 +6,10 @@ import { BeneficiaryCurrentEmployer, BeneficiaryRepresentative, ConventionDto, + FtConnectIdentity, ImmersionObjective, InternshipKind, LevelOfEducation, - PeConnectIdentity, ScheduleDto, addressDtoToString, addressStringToDto, @@ -440,7 +440,7 @@ const conventionPresentationFromParams = ( ...(params.fedId && params.fedIdProvider ? { federatedIdentity: { - provider: params.fedIdProvider as PeConnectIdentity["provider"], + provider: params.fedIdProvider as FtConnectIdentity["provider"], token: params.fedId, }, } diff --git a/shared/src/convention/ConventionDtoBuilder.ts b/shared/src/convention/ConventionDtoBuilder.ts index b7ff8723d3..73740873ec 100644 --- a/shared/src/convention/ConventionDtoBuilder.ts +++ b/shared/src/convention/ConventionDtoBuilder.ts @@ -1,7 +1,7 @@ import { Builder } from "../Builder"; import { WithAcquisition } from "../acquisition.dto"; import { AgencyId } from "../agency/agency.dto"; -import { PeConnectIdentity } from "../federatedIdentities/federatedIdentity.dto"; +import { FtConnectIdentity } from "../federatedIdentities/federatedIdentity.dto"; import { AppellationAndRomeDto } from "../romeAndAppellationDtos/romeAndAppellation.dto"; import { DateIntervalDto, @@ -543,7 +543,7 @@ export class ConventionDtoBuilder implements Builder { } public withFederatedIdentity( - federatedIdentity: PeConnectIdentity | undefined, + federatedIdentity: FtConnectIdentity | undefined, ): ConventionDtoBuilder { return this.withBeneficiary({ ...this.#beneficiary, diff --git a/shared/src/convention/convention.dto.ts b/shared/src/convention/convention.dto.ts index 57e589f347..3a18604596 100644 --- a/shared/src/convention/convention.dto.ts +++ b/shared/src/convention/convention.dto.ts @@ -3,7 +3,7 @@ import { WithAcquisition } from "../acquisition.dto"; import { AddressDto, Postcode } from "../address/address.dto"; import { AgencyId, AgencyKind } from "../agency/agency.dto"; import { Email } from "../email/email.dto"; -import { PeConnectIdentity } from "../federatedIdentities/federatedIdentity.dto"; +import { FtConnectIdentity } from "../federatedIdentities/federatedIdentity.dto"; import { AgencyRole, InclusionConnectedUser, @@ -236,7 +236,7 @@ export type Beneficiary = emergencyContact?: string; emergencyContactPhone?: string; emergencyContactEmail?: Email; - federatedIdentity?: PeConnectIdentity; + federatedIdentity?: FtConnectIdentity; financiaryHelp?: string; birthdate: string; // Date iso string isRqth?: boolean; diff --git a/shared/src/federatedIdentities/federatedIdentity.dto.ts b/shared/src/federatedIdentities/federatedIdentity.dto.ts index de050317c1..b958e5380c 100644 --- a/shared/src/federatedIdentities/federatedIdentity.dto.ts +++ b/shared/src/federatedIdentities/federatedIdentity.dto.ts @@ -30,9 +30,9 @@ type GenericFederatedIdentity< export const authFailed = "AuthFailed"; export const notJobSeeker = "NotJobSeeker"; -export type FtExternalId = Flavor; +export type FtExternalId = Flavor; -type PeConnectAdvisorForBeneficiary = { +type FtConnectAdvisorForBeneficiary = { advisor: { email: string; firstName: string; @@ -46,14 +46,14 @@ export type FtConnectToken = | typeof authFailed | typeof notJobSeeker; -export type PeConnectIdentity = GenericFederatedIdentity< +export type FtConnectIdentity = GenericFederatedIdentity< "peConnect", FtConnectToken, - PeConnectAdvisorForBeneficiary + FtConnectAdvisorForBeneficiary >; -export const isPeConnectIdentity = ( +export const isFtConnectIdentity = ( federatedIdentity: FederatedIdentity | undefined, -): federatedIdentity is PeConnectIdentity => +): federatedIdentity is FtConnectIdentity => federatedIdentity?.provider === "peConnect"; export type InclusionConnectIdentity = GenericFederatedIdentity< @@ -61,4 +61,4 @@ export type InclusionConnectIdentity = GenericFederatedIdentity< InclusionConnectJwt >; -export type FederatedIdentity = InclusionConnectIdentity | PeConnectIdentity; +export type FederatedIdentity = InclusionConnectIdentity | FtConnectIdentity; diff --git a/shared/src/federatedIdentities/federatedIdentity.schema.ts b/shared/src/federatedIdentities/federatedIdentity.schema.ts index f692512b49..92c5f5508a 100644 --- a/shared/src/federatedIdentities/federatedIdentity.schema.ts +++ b/shared/src/federatedIdentities/federatedIdentity.schema.ts @@ -1,7 +1,7 @@ import { z } from "zod"; -import { PeConnectIdentity } from "./federatedIdentity.dto"; +import { FtConnectIdentity } from "./federatedIdentity.dto"; -export const peConnectIdentitySchema: z.Schema = z.object({ +export const peConnectIdentitySchema: z.Schema = z.object({ provider: z.literal("peConnect"), token: z.string(), payload: z diff --git a/shared/src/routes/routes.ts b/shared/src/routes/routes.ts index 1cff41b1a6..e76e12e7fe 100644 --- a/shared/src/routes/routes.ts +++ b/shared/src/routes/routes.ts @@ -41,7 +41,7 @@ export const frontRoutes = { unsubscribeEstablishmentLead: "desinscription-prospect", }; -export const loginPeConnect = "login-pe-connect"; -export const peConnect = "pe-connect"; +export const loginFtConnect = "login-pe-connect"; +export const ftConnect = "pe-connect"; export const uploadFileRoute = "upload-file";