Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2771 - TECH - éliminer les occurences de pole emploi au profit de france travail (première partie) #2816

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.poleEmploiGateway.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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ describe("convention e2e", () => {

await eventCrawler.processNewEvents();

expectToEqual(gateways.poleEmploiGateway.notifications, [
expectToEqual(gateways.franceTravailGateway.notifications, [
{
activitesObservees: convention.immersionActivities,
adresseImmersion: convention.immersionAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
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/pe-connect/adapters/pe-connect-gateway/peConnectApi.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,
async () => {
if (!req?.query?.code)
throw new ManagedRedirectError("peConnectNoAuthorisation");

return deps.useCases.linkPoleEmploiAdvisorAndRedirectToConvention.execute(
return deps.useCases.linkFranceTravailAdvisorAndRedirectToConvention.execute(
req.query.code as string,
);
},
Expand All @@ -35,5 +35,5 @@ export const createPeConnectRouter = (deps: AppDependencies) => {
),
);

return peConnectRouter;
return ftConnectRouter;
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { AppConfig } from "../../../../config/bootstrap/appConfig";
import { Gateways } from "../../../../config/bootstrap/createGateways";
import { BasicEventCrawler } from "../../../../domains/core/events/adapters/EventCrawlerImplementations";
import { GenerateInclusionConnectJwt } from "../../../../domains/core/jwt";
import { broadcastToPeServiceName } from "../../../../domains/core/saved-errors/ports/BroadcastFeedbacksRepository";
import { broadcastToFtServiceName } from "../../../../domains/core/saved-errors/ports/BroadcastFeedbacksRepository";
import { InMemoryUnitOfWork } from "../../../../domains/core/unit-of-work/adapters/createInMemoryUow";
import { toAgencyWithRights } from "../../../../utils/agency";
import { buildTestApp } from "../../../../utils/buildTestApp";
Expand Down Expand Up @@ -353,7 +353,7 @@ describe("InclusionConnectedAllowedRoutes", () => {
];
inMemoryUow.conventionRepository.setConventions([convention]);
await inMemoryUow.broadcastFeedbacksRepository.save({
serviceName: broadcastToPeServiceName,
serviceName: broadcastToFtServiceName,
consumerName: "France Travail",
consumerId: null,
subscriberErrorFeedback: { message: "Some message" },
Expand All @@ -376,7 +376,7 @@ describe("InclusionConnectedAllowedRoutes", () => {
inMemoryUow.broadcastFeedbacksRepository.broadcastFeedbacks,
[
{
serviceName: broadcastToPeServiceName,
serviceName: broadcastToFtServiceName,
consumerName: "France Travail",
consumerId: null,
subscriberErrorFeedback: {
Expand Down
34 changes: 17 additions & 17 deletions back/src/config/bootstrap/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { S3Params } from "../../domains/core/file-storage/adapters/S3DocumentGat

export type AccessTokenConfig = {
immersionFacileBaseUrl: AbsoluteUrl;
peApiUrl: AbsoluteUrl;
peAuthCandidatUrl: AbsoluteUrl;
peEnterpriseUrl: AbsoluteUrl;
ftApiUrl: AbsoluteUrl;
ftAuthCandidatUrl: AbsoluteUrl;
ftEnterpriseUrl: AbsoluteUrl;
clientId: string;
clientSecret: string;
};
Expand Down Expand Up @@ -445,53 +445,53 @@ export class AppConfig {
});
}

public get peApiUrl(): AbsoluteUrl {
public get ftApiUrl(): AbsoluteUrl {
return this.#throwIfNotAbsoluteUrl("POLE_EMPLOI_API_URL");
}

public get peAuthCandidatUrl(): AbsoluteUrl {
public get ftAuthCandidatUrl(): AbsoluteUrl {
return this.#throwIfNotAbsoluteUrl(
"POLE_EMPLOI_AUTHENTIFICATION_CANDIDAT_URL",
);
}

// == PE Connect gateway ==
public get peConnectGateway() {
// == France Travail Connect gateway ==
public get ftConnectGateway() {
return this.#throwIfNotInArray({
variableName: "PE_CONNECT_GATEWAY",
authorizedValues: ["IN_MEMORY", "HTTPS"],
defaultValue: "IN_MEMORY",
});
}

public get peEnterpriseUrl(): AbsoluteUrl {
public get ftEnterpriseUrl(): AbsoluteUrl {
return this.#throwIfNotAbsoluteUrl("POLE_EMPLOI_ENTREPRISE_URL");
}

public get pgImmersionDbUrl() {
return this.#throwIfNotDefinedOrDefault("DATABASE_URL");
}

public get poleEmploiAccessTokenConfig(): AccessTokenConfig {
public get franceTravailAccessTokenConfig(): AccessTokenConfig {
return {
immersionFacileBaseUrl: this.immersionFacileBaseUrl,
peApiUrl: this.peApiUrl,
peAuthCandidatUrl: this.peAuthCandidatUrl,
peEnterpriseUrl: this.peEnterpriseUrl,
clientId: this.poleEmploiClientId,
clientSecret: this.poleEmploiClientSecret,
ftApiUrl: this.ftApiUrl,
ftAuthCandidatUrl: this.ftAuthCandidatUrl,
ftEnterpriseUrl: this.ftEnterpriseUrl,
clientId: this.franceTravailClientId,
clientSecret: this.franceTravailClientSecret,
};
}

public get poleEmploiClientId() {
public get franceTravailClientId() {
return this.#throwIfNotDefinedOrDefault("POLE_EMPLOI_CLIENT_ID");
}

public get poleEmploiClientSecret() {
public get franceTravailClientSecret() {
return this.#throwIfNotDefinedOrDefault("POLE_EMPLOI_CLIENT_SECRET");
}

public get poleEmploiGateway() {
public get franceTravailGateway() {
return this.#throwIfNotInArray({
variableName: "POLE_EMPLOI_GATEWAY",
authorizedValues: ["IN_MEMORY", "HTTPS"],
Expand Down
56 changes: 28 additions & 28 deletions back/src/config/bootstrap/createGateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import { exhaustiveCheck, immersionFacileNoReplyEmailSender } from "shared";
import type { UnknownSharedRoute } from "shared-routes";
import { createAxiosSharedClient } from "shared-routes/axios";
import { createFetchSharedClient } from "shared-routes/fetch";
import { HttpPoleEmploiGateway } from "../../domains/convention/adapters/pole-emploi-gateway/HttpPoleEmploiGateway";
import { InMemoryPoleEmploiGateway } from "../../domains/convention/adapters/pole-emploi-gateway/InMemoryPoleEmploiGateway";
import { createPoleEmploiRoutes } from "../../domains/convention/adapters/pole-emploi-gateway/PoleEmploiRoutes";
import { createFranceTravailRoutes } from "../../domains/convention/adapters/france-travail-gateway/FrancetTravailRoutes";
import { HttpFranceTravailGateway } from "../../domains/convention/adapters/france-travail-gateway/HttpFranceTravailGateway";
import { InMemoryFranceTravailGateway } from "../../domains/convention/adapters/france-travail-gateway/InMemoryFranceTravailGateway";
import { HttpAddressGateway } from "../../domains/core/address/adapters/HttpAddressGateway";
import { addressesExternalRoutes } from "../../domains/core/address/adapters/HttpAddressGateway.routes";
import { InMemoryAddressGateway } from "../../domains/core/address/adapters/InMemoryAddressGateway";
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 { 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";
import { makeInclusionConnectRoutes } from "../../domains/core/authentication/inclusion-connect/adapters/oauth-gateway/inclusionConnect.routes";
import { makeProConnectRoutes } from "../../domains/core/authentication/inclusion-connect/adapters/oauth-gateway/proConnect.routes";
import { OAuthGateway } from "../../domains/core/authentication/inclusion-connect/port/OAuthGateway";
import { HttpPeConnectGateway } from "../../domains/core/authentication/pe-connect/adapters/pe-connect-gateway/HttpPeConnectGateway";
import { InMemoryPeConnectGateway } from "../../domains/core/authentication/pe-connect/adapters/pe-connect-gateway/InMemoryPeConnectGateway";
import { makePeConnectExternalRoutes } from "../../domains/core/authentication/pe-connect/adapters/pe-connect-gateway/peConnectApi.routes";
import { PeConnectGateway } from "../../domains/core/authentication/pe-connect/port/PeConnectGateway";
import { InMemoryCachingGateway } from "../../domains/core/caching-gateway/adapters/InMemoryCachingGateway";
import { MetabaseDashboardGateway } from "../../domains/core/dashboard/adapters/MetabaseDashboardGateway";
import { StubDashboardGateway } from "../../domains/core/dashboard/adapters/StubDashboardGateway";
Expand Down Expand Up @@ -168,43 +168,43 @@ export const createGateways = async (
? new CustomTimeGateway()
: new RealTimeGateway();

const poleEmploiGateway =
config.poleEmploiGateway === "HTTPS"
? new HttpPoleEmploiGateway(
const franceTravailGateway =
config.franceTravailGateway === "HTTPS"
? new HttpFranceTravailGateway(
createLegacyAxiosHttpClientForExternalAPIs({
partnerName: partnerNames.franceTravailApi,
routes: createPoleEmploiRoutes(config.peApiUrl),
routes: createFranceTravailRoutes(config.ftApiUrl),
}),
new InMemoryCachingGateway<AccessTokenResponse>(
timeGateway,
"expires_in",
),
config.peApiUrl,
config.poleEmploiAccessTokenConfig,
config.ftApiUrl,
config.franceTravailAccessTokenConfig,
noRetries,
config.envType === "dev",
)
: new InMemoryPoleEmploiGateway();
: new InMemoryFranceTravailGateway();

const { withCache, disconnectCache } = await getWithCache(config);

const peConnectGateway: PeConnectGateway =
config.peConnectGateway === "HTTPS"
? new HttpPeConnectGateway(
const ftConnectGateway: FtConnectGateway =
config.ftConnectGateway === "HTTPS"
? new HttpFtConnectGateway(
createLegacyAxiosHttpClientForExternalAPIs({
partnerName: partnerNames.franceTravailConnect,
routes: makePeConnectExternalRoutes({
peApiUrl: config.peApiUrl,
peAuthCandidatUrl: config.peAuthCandidatUrl,
routes: makeFtConnectExternalRoutes({
ftApiUrl: config.ftApiUrl,
ftAuthCandidatUrl: config.ftAuthCandidatUrl,
}),
}),
{
immersionFacileBaseUrl: config.immersionFacileBaseUrl,
poleEmploiClientId: config.poleEmploiClientId,
poleEmploiClientSecret: config.poleEmploiClientSecret,
franceTravailClientId: config.franceTravailClientId,
franceTravailClientSecret: config.franceTravailClientSecret,
},
)
: new InMemoryPeConnectGateway();
: new InMemoryFtConnectGateway();

const oAuthGateway: OAuthGateway =
config.inclusionConnectGateway === "HTTPS"
Expand Down Expand Up @@ -393,10 +393,10 @@ export const createGateways = async (
? new HttpLaBonneBoiteGateway(
createFetchHttpClientForExternalAPIs({
partnerName: partnerNames.laBonneBoite,
routes: createLbbRoutes(config.peApiUrl),
routes: createLbbRoutes(config.ftApiUrl),
}),
poleEmploiGateway,
config.poleEmploiClientId,
franceTravailGateway,
config.franceTravailClientId,
)
: new InMemoryLaBonneBoiteGateway(),
subscribersGateway:
Expand All @@ -412,8 +412,8 @@ export const createGateways = async (
? new HttpPassEmploiGateway(config.passEmploiUrl, config.passEmploiKey)
: new InMemoryPassEmploiGateway(),
pdfGeneratorGateway: createPdfGeneratorGateway(),
peConnectGateway,
poleEmploiGateway,
ftConnectGateway,
franceTravailGateway,
timeGateway,
establishmentMarketingGateway:
config.establishmentMarketingGateway === "BREVO"
Expand Down
20 changes: 10 additions & 10 deletions back/src/config/bootstrap/createUseCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ import { DeleteSubscription } from "../../domains/core/api-consumer/use-cases/De
import { makeListActiveSubscriptions } from "../../domains/core/api-consumer/use-cases/ListActiveSubscriptions";
import { SaveApiConsumer } from "../../domains/core/api-consumer/use-cases/SaveApiConsumer";
import { SubscribeToWebhook } from "../../domains/core/api-consumer/use-cases/SubscribeToWebhook";
import { BindConventionToFederatedIdentity } from "../../domains/core/authentication/ft-connect/use-cases/BindConventionToFederatedIdentity";
import { LinkFranceTravailAdvisorAndRedirectToConvention } from "../../domains/core/authentication/ft-connect/use-cases/LinkFranceTravailAdvisorAndRedirectToConvention";
import { NotifyFranceTravailUserAdvisorOnConventionFullySigned } from "../../domains/core/authentication/ft-connect/use-cases/NotifyFranceTravailUserAdvisorOnConventionFullySigned";
import { AuthenticateWithInclusionCode } from "../../domains/core/authentication/inclusion-connect/use-cases/AuthenticateWithInclusionCode";
import { makeGetInclusionConnectLogoutUrl } from "../../domains/core/authentication/inclusion-connect/use-cases/GetInclusionConnectLogoutUrl";
import { InitiateInclusionConnect } from "../../domains/core/authentication/inclusion-connect/use-cases/InitiateInclusionConnect";
import { BindConventionToFederatedIdentity } from "../../domains/core/authentication/pe-connect/use-cases/BindConventionToFederatedIdentity";
import { LinkPoleEmploiAdvisorAndRedirectToConvention } from "../../domains/core/authentication/pe-connect/use-cases/LinkPoleEmploiAdvisorAndRedirectToConvention";
import { NotifyPoleEmploiUserAdvisorOnConventionFullySigned } from "../../domains/core/authentication/pe-connect/use-cases/NotifyPoleEmploiUserAdvisorOnConventionFullySigned";
import { DashboardGateway } from "../../domains/core/dashboard/port/DashboardGateway";
import { GetDashboardUrl } from "../../domains/core/dashboard/useCases/GetDashboardUrl";
import { ValidateEmail } from "../../domains/core/email-validation/use-cases/ValidateEmail";
Expand Down Expand Up @@ -278,10 +278,10 @@ export const createUseCases = (
getConventionsForApiConsumer: new GetConventionsForApiConsumer(
uowPerformer,
),
linkPoleEmploiAdvisorAndRedirectToConvention:
new LinkPoleEmploiAdvisorAndRedirectToConvention(
linkFranceTravailAdvisorAndRedirectToConvention:
new LinkFranceTravailAdvisorAndRedirectToConvention(
uowPerformer,
gateways.peConnectGateway,
gateways.ftConnectGateway,
config.immersionFacileBaseUrl,
),

Expand Down Expand Up @@ -535,8 +535,8 @@ export const createUseCases = (
saveNotificationAndRelatedEvent,
config.immersionFacileDomain,
),
notifyPoleEmploiUserAdvisorOnConventionFullySigned:
new NotifyPoleEmploiUserAdvisorOnConventionFullySigned(
notifyFranceTravailUserAdvisorOnConventionFullySigned:
new NotifyFranceTravailUserAdvisorOnConventionFullySigned(
uowPerformer,
saveNotificationAndRelatedEvent,
generateConventionMagicLinkUrl,
Expand All @@ -551,10 +551,10 @@ export const createUseCases = (
uowPerformer,
saveNotificationAndRelatedEvent,
),
broadcastToPoleEmploiOnConventionUpdates:
broadcastToFranceTravailOnConventionUpdates:
new BroadcastToFranceTravailOnConventionUpdates(
uowPerformer,
gateways.poleEmploiGateway,
gateways.franceTravailGateway,
gateways.timeGateway,
{ resyncMode: false },
),
Expand Down
4 changes: 2 additions & 2 deletions back/src/config/bootstrap/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
Expand Down
Loading
Loading