Skip to content

Commit

Permalink
feat(pro_connect): update family_name key in user_info_mapping_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Aug 27, 2024
1 parent e76ef97 commit ef138d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lacommunaute/openid_connect/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def user_info_mapping_dict(user_info: dict):
return {
"username": user_info["sub"],
"first_name": user_info["given_name"],
"last_name": user_info["family_name"],
"last_name": user_info["usual_name"],
"email": user_info["email"],
}

Expand Down
8 changes: 4 additions & 4 deletions lacommunaute/openid_connect/tests/tests_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

OIDC_USERINFO = {
"given_name": "Michel",
"family_name": "AUDIARD",
"usual_name": "AUDIARD",
"email": "[email protected]",
"sub": "af6b26f9-85cd-484e-beb9-bea5be13e30f",
}
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_create_user_from_user_info(self):
user, created = proc_user_data.create_or_update_user()
self.assertTrue(created)
self.assertEqual(user.email, OIDC_USERINFO["email"])
self.assertEqual(user.last_name, OIDC_USERINFO["family_name"])
self.assertEqual(user.last_name, OIDC_USERINFO["usual_name"])
self.assertEqual(user.first_name, OIDC_USERINFO["given_name"])
self.assertEqual(user.username, OIDC_USERINFO["sub"])

Expand All @@ -92,7 +92,7 @@ def test_update_user_from_user_info(self):

user = User.objects.get(username=USERINFO["username"])
self.assertEqual(user.first_name, OIDC_USERINFO["given_name"])
self.assertEqual(user.last_name, OIDC_USERINFO["family_name"])
self.assertEqual(user.last_name, OIDC_USERINFO["usual_name"])
self.assertEqual(user.email, OIDC_USERINFO["email"])
self.assertNotEqual(user.email, USERINFO["email"])

Expand All @@ -113,6 +113,6 @@ def test_get_existing_user_with_existing_email(self):
)
user, created = proc_user_data.create_or_update_user()
self.assertFalse(created)
self.assertEqual(user.last_name, OIDC_USERINFO["family_name"])
self.assertEqual(user.last_name, OIDC_USERINFO["usual_name"])
self.assertEqual(user.first_name, OIDC_USERINFO["given_name"])
self.assertEqual(user.username, OIDC_USERINFO["sub"])
8 changes: 4 additions & 4 deletions lacommunaute/openid_connect/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

OIDC_USERINFO = {
"given_name": "Michel",
"family_name": "AUDIARD",
"usual_name": "AUDIARD",
"email": "[email protected]",
"sub": "af6b26f9-85cd-484e-beb9-bea5be13e30f",
}
Expand Down Expand Up @@ -113,23 +113,23 @@ def test_callback_user_created(self):
self.assertEqual(User.objects.count(), 1)
user = User.objects.get(email=OIDC_USERINFO["email"])
self.assertEqual(user.first_name, OIDC_USERINFO["given_name"])
self.assertEqual(user.last_name, OIDC_USERINFO["family_name"])
self.assertEqual(user.last_name, OIDC_USERINFO["usual_name"])
self.assertEqual(user.username, OIDC_USERINFO["sub"])

@respx.mock
def test_callback_existing_user(self):
# User already exists.
UserFactory(
first_name=OIDC_USERINFO["given_name"],
last_name=OIDC_USERINFO["family_name"],
last_name=OIDC_USERINFO["usual_name"],
username=OIDC_USERINFO["sub"],
email=OIDC_USERINFO["email"],
)
mock_oauth_dance(self)
self.assertEqual(User.objects.count(), 1)
user = User.objects.get(email=OIDC_USERINFO["email"])
self.assertEqual(user.first_name, OIDC_USERINFO["given_name"])
self.assertEqual(user.last_name, OIDC_USERINFO["family_name"])
self.assertEqual(user.last_name, OIDC_USERINFO["usual_name"])
self.assertEqual(user.username, OIDC_USERINFO["sub"])


Expand Down

0 comments on commit ef138d7

Please sign in to comment.