From 0fd06ef6c04e36a2c44049c321872f4d76e0fab4 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Wed, 13 Nov 2024 12:13:17 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(backend)=20isolate=20authent?= =?UTF-8?q?ication=20tests=20when=20dealing=20only=20with=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor a test to narrow down its scope to email-related updates. --- src/backend/core/tests/authentication/test_backends.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/core/tests/authentication/test_backends.py b/src/backend/core/tests/authentication/test_backends.py index c2a65d24..73600f43 100644 --- a/src/backend/core/tests/authentication/test_backends.py +++ b/src/backend/core/tests/authentication/test_backends.py @@ -62,15 +62,14 @@ def test_authentication_getter_new_user_no_email(monkeypatch): def test_authentication_getter_new_user_with_email(monkeypatch): """ If no user matches, a user should be created. - User's email and name should be set on the identity. - The "email" field on the User model should not be set as it is reserved for staff users. + User's info contains an email, created user's email should be filled. """ klass = OIDCAuthenticationBackend() email = "meet@example.com" def get_userinfo_mocked(*args): - return {"sub": "123", "email": email, "first_name": "John", "last_name": "Doe"} + return {"sub": "123", "email": email} monkeypatch.setattr(OIDCAuthenticationBackend, "get_userinfo", get_userinfo_mocked) @@ -80,6 +79,8 @@ def test_authentication_getter_new_user_with_email(monkeypatch): assert user.sub == "123" assert user.email == email + assert user.full_name is None + assert user.short_name is None assert user.password == "!" assert models.User.objects.count() == 1