From 9acb4ef6c5d75fef54af927fbe809fc7bc97dd30 Mon Sep 17 00:00:00 2001 From: Laurent Bossavit Date: Mon, 23 Dec 2024 17:09:43 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85(e2e)=20change=20accounts=20to=20facil?= =?UTF-8?q?itate=20SIRET=20and=20add=20e2e=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We also add registration ID info to the /me endpoint, via serializers --- CHANGELOG.md | 4 ++++ docker/auth/realm.json | 4 ++-- src/backend/core/api/client/serializers.py | 4 ++-- src/backend/people/settings.py | 2 ++ .../apps/e2e/__tests__/app-desk/siret.spec.ts | 23 +++++++++++++++++++ src/helm/env.d/dev/values.desk.yaml.gotmpl | 1 + 6 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 src/frontend/apps/e2e/__tests__/app-desk/siret.spec.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index e18c2283c..e9664bdd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to ## [Unreleased] +### Added + +- 🧑‍💻(oidc) add ability to pull registration ID (e.g. SIRET) from OIDC #577 + ### Fixed - 🧑‍💻(user) fix the User.language infinite migration #611 diff --git a/docker/auth/realm.json b/docker/auth/realm.json index f14d9e837..5d6bd381a 100644 --- a/docker/auth/realm.json +++ b/docker/auth/realm.json @@ -59,7 +59,7 @@ "realmRoles": ["user"] }, { - "username": "marie", + "username": "jean.marie", "email": "marie.varzy@gmail.com", "firstName": "Marie", "lastName": "Devarzy", @@ -70,7 +70,7 @@ "credentials": [ { "type": "password", - "value": "people" + "value": "password-e2e-jean.marie" } ], "realmRoles": ["user"] diff --git a/src/backend/core/api/client/serializers.py b/src/backend/core/api/client/serializers.py index 9236b7833..df0410193 100644 --- a/src/backend/core/api/client/serializers.py +++ b/src/backend/core/api/client/serializers.py @@ -88,8 +88,8 @@ class UserOrganizationSerializer(serializers.ModelSerializer): class Meta: model = models.Organization - fields = ["id", "name"] - read_only_fields = ["id", "name"] + fields = ["id", "name", "registration_id_list"] + read_only_fields = ["id", "name", "registration_id_list"] class UserSerializer(DynamicFieldsModelSerializer): diff --git a/src/backend/people/settings.py b/src/backend/people/settings.py index 6c1bb41bd..f1f5e7a34 100755 --- a/src/backend/people/settings.py +++ b/src/backend/people/settings.py @@ -639,6 +639,8 @@ class Development(Base): # this is a dev credentials for mail provisioning API MAIL_PROVISIONING_API_CREDENTIALS = "bGFfcmVnaWU6cGFzc3dvcmQ=" + OIDC_ORGANIZATION_REGISTRATION_ID_FIELD = "siret" + def __init__(self): """In dev, force installs needed for Swagger API.""" # pylint: disable=invalid-name diff --git a/src/frontend/apps/e2e/__tests__/app-desk/siret.spec.ts b/src/frontend/apps/e2e/__tests__/app-desk/siret.spec.ts new file mode 100644 index 000000000..6ce3bde44 --- /dev/null +++ b/src/frontend/apps/e2e/__tests__/app-desk/siret.spec.ts @@ -0,0 +1,23 @@ +import { expect, test } from '@playwright/test'; + +import { keyCloakSignIn } from './common'; + +test.beforeEach(async ({ page, browserName }) => { + await page.goto('/'); + await keyCloakSignIn(page, browserName, 'marie'); +}); + +test.describe('OIDC interop with SIRET', () => { + test('it checks the SIRET is displayed in /me endpoint', async ({ + page, + browserName, + }) => { + const response = await page.request.get( + 'http://localhost:8071/api/v1.0/users/me/', + ); + expect(response.ok()).toBeTruthy(); + expect(await response.json()).toMatchObject({ + organization: { registration_id_list: ['21580304000017'] }, + }); + }); +}); \ No newline at end of file diff --git a/src/helm/env.d/dev/values.desk.yaml.gotmpl b/src/helm/env.d/dev/values.desk.yaml.gotmpl index fc5354233..eaac1d125 100644 --- a/src/helm/env.d/dev/values.desk.yaml.gotmpl +++ b/src/helm/env.d/dev/values.desk.yaml.gotmpl @@ -26,6 +26,7 @@ backend: OIDC_OP_TOKEN_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/token OIDC_OP_USER_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/userinfo OIDC_OP_LOGOUT_ENDPOINT: https://fca.integ01.dev-agentconnect.fr/api/v2/session/end + OIDC_ORGANIZATION_REGISTRATION_ID_FIELD: "siret" OIDC_RP_CLIENT_ID: secretKeyRef: name: backend