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

#2844 - ProConnect par défaut en vue de supprimer les références à Inclusion Connect #2899

Merged
merged 3 commits into from
Jan 31, 2025
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
15 changes: 15 additions & 0 deletions .github/workflows/fullcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ on:
required: true
IC_USERNAME:
required: true
PC_ADMIN_PASSWORD:
required: true
PC_PASSWORD:
required: true
PC_USERNAME:
required: true
SIRENE_INSEE_CLIENT_ID:
required: true
SIRENE_INSEE_CLIENT_SECRET:
Expand All @@ -23,6 +29,8 @@ on:
required: true
INCLUSION_CONNECT_CLIENT_SECRET:
required: true
PRO_CONNECT_CLIENT_SECRET:
required: true

jobs:
validation:
Expand Down Expand Up @@ -107,10 +115,17 @@ jobs:
IC_USERNAME: ${{ secrets.IC_USERNAME }}
IC_PASSWORD: ${{ secrets.IC_PASSWORD }}
IC_ADMIN_PASSWORD: ${{ secrets.IC_ADMIN_PASSWORD }}
PC_USERNAME: ${{ secrets.PC_USERNAME }}
PC_PASSWORD: ${{ secrets.PC_PASSWORD }}
PC_ADMIN_PASSWORD: ${{ secrets.PC_ADMIN_PASSWORD }}
INCLUSION_CONNECT_GATEWAY: "HTTPS"
INCLUSION_CONNECT_CLIENT_ID: local_inclusion_connect
INCLUSION_CONNECT_CLIENT_SECRET: ${{ secrets.INCLUSION_CONNECT_CLIENT_SECRET }}
INCLUSION_CONNECT_BASE_URI: "https://recette.connect.inclusion.beta.gouv.fr/auth"
PRO_CONNECT_GATEWAY: "HTTPS"
PRO_CONNECT_CLIENT_ID: 449e24c6-b5aa-4435-bb8c-728d4a3c1c94
PRO_CONNECT_CLIENT_SECRET: ${{ secrets.PRO_CONNECT_CLIENT_SECRET }}
PRO_CONNECT_BASE_URI: "https://fca.integ01.dev-agentconnect.fr/api/v2"
API_KEY_OPEN_CAGE_DATA_GEOCODING: ${{ secrets.API_KEY_OPEN_CAGE_DATA_GEOCODING }}
API_KEY_OPEN_CAGE_DATA_GEOSEARCH: ${{ secrets.API_KEY_OPEN_CAGE_DATA_GEOSEARCH }}
POLE_EMPLOI_GATEWAY: IN_MEMORY
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/validation-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ jobs:
IC_ADMIN_PASSWORD: ${{ secrets.IC_ADMIN_PASSWORD }}
IC_PASSWORD: ${{ secrets.IC_PASSWORD }}
IC_USERNAME: ${{ secrets.IC_USERNAME }}
PC_USERNAME: ${{ secrets.PC_USERNAME }}
PC_PASSWORD: ${{ secrets.PC_PASSWORD }}
PC_ADMIN_PASSWORD: ${{ secrets.PC_ADMIN_PASSWORD }}
SIRENE_INSEE_CLIENT_ID: ${{ secrets.SIRENE_INSEE_CLIENT_ID }}
SIRENE_INSEE_CLIENT_SECRET: ${{ secrets.SIRENE_INSEE_CLIENT_SECRET }}
SIRENE_INSEE_USERNAME: ${{ secrets.SIRENE_INSEE_USERNAME }}
SIRENE_INSEE_PASSWORD: ${{ secrets.SIRENE_INSEE_PASSWORD }}
INCLUSION_CONNECT_CLIENT_SECRET: ${{ secrets.INCLUSION_CONNECT_CLIENT_SECRET }}
PRO_CONNECT_CLIENT_SECRET: ${{ secrets.PRO_CONNECT_CLIENT_SECRET}}

verify-migration-order:
name: "Verify migration order"
Expand Down
2 changes: 1 addition & 1 deletion back/src/scripts/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const featureFlagsSeed = async (uow: UnitOfWork) => {
severity: "warning",
}),
enableSearchByScore: makeBooleanFeatureFlag(true),
enableProConnect: makeBooleanFeatureFlag(false),
enableProConnect: makeBooleanFeatureFlag(true),
enableBroadcastOfConseilDepartementalToFT: makeBooleanFeatureFlag(false),
enableBroadcastOfCapEmploiToFT: makeBooleanFeatureFlag(false),
enableBroadcastOfMissionLocaleToFT: makeBooleanFeatureFlag(false),
Expand Down
10 changes: 10 additions & 0 deletions playwright/custom.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { makeThrowIfNotDefinedOrDefault } from "shared";

const throwIfNotDefinedOrDefault = makeThrowIfNotDefinedOrDefault(process.env);
export const testConfig = {
timeForDebounce: 600, // debounce time value * 2 for safety
timeForEventCrawler: 2000, // event crawler time interval + 1s for safety
proConnect: {
baseUrl: "https://fca.integ01.dev-agentconnect.fr/api/v2",
username: throwIfNotDefinedOrDefault("PC_USERNAME"),
password: throwIfNotDefinedOrDefault("PC_PASSWORD"),
adminUsername: "admin+playwright@immersion-facile.beta.gouv.fr",
adminPassword: throwIfNotDefinedOrDefault("PC_ADMIN_PASSWORD"),
},
inclusionConnect: {
baseUrl: "https://recette.connect.inclusion.beta.gouv.fr",
username: process.env.IC_USERNAME ?? "",
Expand Down
108 changes: 70 additions & 38 deletions playwright/tests/auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,38 @@ const { adminAuthFile, establishmentAuthFile, agencyAuthFile } = testConfig;
setup("authenticate as admin", async ({ page }) => {
await page.goto("/");
const adminButton = await page.locator("#fr-header-main-navigation-button-4");
await loginWithInclusionConnect(page, "admin");
await loginWithIdentityProvider(page, "admin", "ProConnect");
await expect(adminButton).toBeVisible();
await page.context().storageState({ path: adminAuthFile });
});

setup("authenticate as IC user establishment", async ({ page }) => {
await page.goto("/");
await loginWithInclusionConnect(page, "establishmentDashboard");
await loginWithIdentityProvider(page, "establishmentDashboard", "ProConnect");
await expect(page.locator(".fr-tabs__list")).toBeVisible();
await page.context().storageState({ path: establishmentAuthFile });
});

setup("authenticate as IC user agency", async ({ page }) => {
await page.goto("/");
await loginWithInclusionConnect(page, "agencyDashboard");

await loginWithIdentityProvider(page, "agencyDashboard", "ProConnect");
await expect(
page.locator(`#${domElementIds.agencyDashboard.registerAgencies.search}`),
).toBeVisible();

await page.context().storageState({ path: agencyAuthFile });
});

const loginWithInclusionConnect = async (
type ProviderMode = "ProConnect" | "InclusionConnect";

const loginWithIdentityProvider = async (
page: Page,
routeName: "agencyDashboard" | "establishmentDashboard" | "admin",
identityProviderMode: ProviderMode,
) => {
const { loginButtonId, navLink, username, password, headerNavLink } =
buttonByRouteName[routeName];
buttonByRouteName(identityProviderMode)[routeName];

if (routeName === "admin") {
await page.goto("/admin");
Expand All @@ -47,21 +50,36 @@ const loginWithInclusionConnect = async (
await expect(page.url()).toContain(frontRoutes[routeName]);
}

const inclusionConnectButton = await page.locator(`#${loginButtonId}`);
await expect(inclusionConnectButton).toBeVisible();
const authButton = await page.locator(`#${loginButtonId}`);
await expect(authButton).toBeVisible();

await inclusionConnectButton.click();
await page.waitForURL(`${testConfig.inclusionConnect.baseUrl}/**`);
await authButton.click();
await page.waitForURL(
`${getAuthEnvVarByIdentityProviderMode(identityProviderMode).baseUrl}/**`,
);
await page.waitForLoadState("domcontentloaded");
await page.waitForSelector("input[name=email]");
await page.fill("input[name=email]", username);

if (identityProviderMode === "ProConnect")
await page
.locator("button[type='submit']")
.getByText("Continuer", {
exact: false,
})
.click();

await page.fill("input[name=password]", password);
await page
.locator("button[type='submit']")
.getByText("Connexion", {
exact: false,
})
.click();

identityProviderMode === "ProConnect"
? await page.getByRole("button", { name: /identifier/ }).click()
: await page
.locator("button[type='submit']")
.getByText("Connexion", {
exact: false,
})
.click();

await page.waitForURL(`${frontRoutes[routeName]}**`);
expect(page.url()).toContain(frontRoutes[routeName]);
};
Expand All @@ -71,7 +89,9 @@ type InclusionConnectRoute =
| "establishmentDashboard"
| "admin";

const buttonByRouteName: Record<
const buttonByRouteName = (
identityProviderMode: ProviderMode,
): Record<
InclusionConnectRoute,
{
loginButtonId: string;
Expand All @@ -80,26 +100,38 @@ const buttonByRouteName: Record<
password: string;
headerNavLink?: string;
}
> = {
agencyDashboard: {
loginButtonId: domElementIds.agencyDashboard.login.inclusionConnectButton,
navLink: domElementIds.header.navLinks.agency.dashboard,
username: testConfig.inclusionConnect.username,
password: testConfig.inclusionConnect.password,
headerNavLink: "fr-header-main-navigation-button-3",
},
establishmentDashboard: {
loginButtonId:
domElementIds.establishmentDashboard.login.inclusionConnectButton,
navLink: domElementIds.header.navLinks.establishment.dashboard,
username: testConfig.inclusionConnect.username,
password: testConfig.inclusionConnect.password,
headerNavLink: "fr-header-main-navigation-button-2",
},
admin: {
loginButtonId: domElementIds.admin.login.inclusionConnectButton,
navLink: domElementIds.header.navLinks.admin.backOffice,
username: testConfig.inclusionConnect.adminUsername,
password: testConfig.inclusionConnect.adminPassword,
},
> => {
const { username, password, adminUsername, adminPassword } =
getAuthEnvVarByIdentityProviderMode(identityProviderMode);

return {
agencyDashboard: {
loginButtonId: domElementIds.agencyDashboard.login.inclusionConnectButton,
navLink: domElementIds.header.navLinks.agency.dashboard,
username,
password,
headerNavLink: "fr-header-main-navigation-button-3",
},
establishmentDashboard: {
loginButtonId:
domElementIds.establishmentDashboard.login.inclusionConnectButton,
navLink: domElementIds.header.navLinks.establishment.dashboard,
username,
password,
headerNavLink: "fr-header-main-navigation-button-2",
},
admin: {
loginButtonId: domElementIds.admin.login.inclusionConnectButton,
navLink: domElementIds.header.navLinks.admin.backOffice,
username: adminUsername,
password: adminPassword,
},
};
};

const getAuthEnvVarByIdentityProviderMode = (identityProviderMode: string) =>
testConfig[
identityProviderMode === "InclusionConnect"
? "inclusionConnect"
: "proConnect"
];
Loading