Skip to content

Commit

Permalink
rename Pe to Ft
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeBu committed Jan 16, 2025
1 parent cc91262 commit 2168a81
Show file tree
Hide file tree
Showing 29 changed files with 242 additions and 248 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -35,5 +35,5 @@ export const createPeConnectRouter = (deps: AppDependencies) => {
),
);

return peConnectRouter;
return ftConnectRouter;
};
16 changes: 8 additions & 8 deletions back/src/config/bootstrap/createGateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
}),
}),
{
Expand All @@ -204,7 +204,7 @@ export const createGateways = async (
franceTravailClientSecret: config.franceTravailClientSecret,
},
)
: new InMemoryPeConnectGateway();
: new InMemoryFtConnectGateway();

const oAuthGateway: OAuthGateway =
config.inclusionConnectGateway === "HTTPS"
Expand Down Expand Up @@ -412,7 +412,7 @@ export const createGateways = async (
? new HttpPassEmploiGateway(config.passEmploiUrl, config.passEmploiKey)
: new InMemoryPassEmploiGateway(),
pdfGeneratorGateway: createPdfGeneratorGateway(),
peConnectGateway,
ftConnectGateway,
franceTravailGateway,
timeGateway,
establishmentMarketingGateway:
Expand Down
2 changes: 1 addition & 1 deletion back/src/config/bootstrap/createUseCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export const createUseCases = (
linkFranceTravailAdvisorAndRedirectToConvention:
new LinkFranceTravailAdvisorAndRedirectToConvention(
uowPerformer,
gateways.peConnectGateway,
gateways.ftConnectGateway,
config.immersionFacileBaseUrl,
),

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
4 changes: 2 additions & 2 deletions back/src/config/pg/kysely/model/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -276,7 +276,7 @@ interface Actors {
id: Generated<number>;
}

interface PartnersPeConnect {
interface PartnersFtConnect {
user_pe_external_id: string;
convention_id: Generated<string>;
firstname: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,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: "[email protected]",
Expand All @@ -444,7 +444,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: "[email protected]",
firstname: "John",
Expand Down
12 changes: 6 additions & 6 deletions back/src/domains/convention/use-cases/GetConvention.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,25 +443,25 @@ describe("Get Convention", () => {
});

it("user is a PeAdvisor", async () => {
const peAdvisorEmail = "[email protected]";
const peConnectedConvention = new ConventionDtoBuilder(convention)
const ftAdvisorEmail = "[email protected]";
const ftConnectedConvention = new ConventionDtoBuilder(convention)
.withFederatedIdentity({
provider: "peConnect",
token: "some-id",
payload: {
advisor: {
email: peAdvisorEmail,
email: ftAdvisorEmail,
firstName: "john",
lastName: "doe",
type: "PLACEMENT",
},
},
})
.build();
uow.conventionRepository.setConventions([peConnectedConvention]);
uow.conventionRepository.setConventions([ftConnectedConvention]);
const payload: ConventionJwtPayload = {
role: "validator",
emailHash: stringToMd5(peAdvisorEmail),
emailHash: stringToMd5(ftAdvisorEmail),
applicationId: convention.id,
iat: 1,
version: 1,
Expand All @@ -473,7 +473,7 @@ describe("Get Convention", () => {
);

expectToEqual(conventionResult, {
...peConnectedConvention,
...ftConnectedConvention,
agencyName: agency.name,
agencyDepartment: agency.address.departmentCode,
agencyKind: agency.kind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
AgencyDtoBuilder,
ConventionDto,
ConventionDtoBuilder,
FtConnectIdentity,
InclusionConnectedUserBuilder,
PeConnectIdentity,
expectToEqual,
frontRoutes,
} from "shared";
Expand Down Expand Up @@ -70,8 +70,8 @@ describe("NotifyConventionNeedsReview", () => {
},
);

const peAdvisorEmail = "[email protected]";
const peIdentity: PeConnectIdentity = {
const ftAdvisorEmail = "[email protected]";
const ftIdentity: FtConnectIdentity = {
provider: "peConnect",
token: "123",
};
Expand Down Expand Up @@ -273,7 +273,7 @@ describe("NotifyConventionNeedsReview", () => {
defaultConvention,
)
.withStatus("IN_REVIEW")
.withFederatedIdentity(peIdentity)
.withFederatedIdentity(ftIdentity)
.build();

const shortLinkIds = [
Expand All @@ -287,12 +287,12 @@ describe("NotifyConventionNeedsReview", () => {
const userConventionAdvisor: ConventionFtUserAdvisorEntity = {
_entityName: "ConventionFranceTravailAdvisor",
advisor: {
email: peAdvisorEmail,
email: ftAdvisorEmail,
firstName: "Elsa",
lastName: "Oldenburg",
type: "CAPEMPLOI",
},
peExternalId: peIdentity.token,
peExternalId: ftIdentity.token,
conventionId: conventionInReviewWithPeAdvisor.id,
};

Expand Down Expand Up @@ -348,18 +348,18 @@ describe("NotifyConventionNeedsReview", () => {
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,
peExternalId: ftIdentity.token,
conventionId: conventionInReviewWithPeAdvisor.id,
};

Expand All @@ -376,7 +376,7 @@ describe("NotifyConventionNeedsReview", () => {
id: conventionInReviewWithPeAdvisor.id,
role: "validator",
targetRoute: frontRoutes.conventionStatusDashboard,
email: peAdvisorEmail,
email: ftAdvisorEmail,
now: timeGateway.now(),
}),
[shortLinkIds[1]]: fakeGenerateMagicLinkUrlFn({
Expand All @@ -397,7 +397,7 @@ describe("NotifyConventionNeedsReview", () => {
id: conventionInReviewWithPeAdvisor.id,
role: "validator",
targetRoute: frontRoutes.manageConvention,
email: peAdvisorEmail,
email: ftAdvisorEmail,
now: timeGateway.now(),
}),
[shortLinkIds[4]]: fakeGenerateMagicLinkUrlFn({
Expand All @@ -420,7 +420,7 @@ describe("NotifyConventionNeedsReview", () => {
emails: [
{
kind: "NEW_CONVENTION_REVIEW_FOR_ELIGIBILITY_OR_VALIDATION",
recipients: [peAdvisorEmail],
recipients: [ftAdvisorEmail],
params: {
conventionId: conventionInReviewWithPeAdvisor.id,
internshipKind: conventionInReviewWithPeAdvisor.internshipKind,
Expand Down Expand Up @@ -617,18 +617,18 @@ describe("NotifyConventionNeedsReview", () => {
const conventionAcceptedByCounsellorWithPeAdvisor =
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,
peExternalId: ftIdentity.token,
conventionId: conventionAcceptedByCounsellorWithPeAdvisor.id,
};

Expand All @@ -645,7 +645,7 @@ describe("NotifyConventionNeedsReview", () => {
id: conventionAcceptedByCounsellorWithPeAdvisor.id,
role: "validator",
targetRoute: frontRoutes.conventionStatusDashboard,
email: peAdvisorEmail,
email: ftAdvisorEmail,
now: timeGateway.now(),
}),
[shortLinkIds[1]]: fakeGenerateMagicLinkUrlFn({
Expand All @@ -666,7 +666,7 @@ describe("NotifyConventionNeedsReview", () => {
id: conventionAcceptedByCounsellorWithPeAdvisor.id,
role: "validator",
targetRoute: frontRoutes.manageConvention,
email: peAdvisorEmail,
email: ftAdvisorEmail,
now: timeGateway.now(),
}),
[shortLinkIds[4]]: fakeGenerateMagicLinkUrlFn({
Expand All @@ -689,7 +689,7 @@ describe("NotifyConventionNeedsReview", () => {
emails: [
{
kind: "NEW_CONVENTION_REVIEW_FOR_ELIGIBILITY_OR_VALIDATION",
recipients: [peAdvisorEmail],
recipients: [ftAdvisorEmail],
params: {
conventionId: conventionAcceptedByCounsellorWithPeAdvisor.id,
internshipKind:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
AgencyWithUsersRights,
ConventionDto,
ConventionDtoBuilder,
FtConnectIdentity,
InclusionConnectedUserBuilder,
PeConnectIdentity,
expectToEqual,
frontRoutes,
} from "shared";
Expand Down Expand Up @@ -299,7 +299,7 @@ describe("NotifyToAgencyConventionSubmitted", () => {
"shortlink4",
];
shortLinkIdGeneratorGateway.addMoreShortLinkIds(shortLinkIds);
const peIdentity: PeConnectIdentity = {
const peIdentity: FtConnectIdentity = {
provider: "peConnect",
token: "123",
};
Expand Down Expand Up @@ -399,7 +399,7 @@ describe("NotifyToAgencyConventionSubmitted", () => {
shortLinkIdGeneratorGateway.addMoreShortLinkIds(shortLinkIds);

const peAdvisorEmail = "[email protected]";
const peIdentity: PeConnectIdentity = {
const peIdentity: FtConnectIdentity = {
provider: "peConnect",
token: "123",
};
Expand Down
Loading

0 comments on commit 2168a81

Please sign in to comment.