Skip to content

Commit

Permalink
Merge pull request numerique-gouv#53 from yaal-coop/issue-47-case
Browse files Browse the repository at this point in the history
Correction de la casse des noms d'utilisateurs
  • Loading branch information
klorydryk authored Mar 11, 2024
2 parents 30fbaa0 + 9903304 commit e026371
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions web/b3desk/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def has_user_session():
def get_authenticated_attendee_fullname():
attendee_session = UserSession(session)
attendee_info = attendee_session.userinfo
given_name = attendee_info.get("given_name", "")
family_name = attendee_info.get("family_name", "")
given_name = attendee_info.get("given_name", "").title()
family_name = attendee_info.get("family_name", "").title()
fullname = f"{given_name} {family_name}".strip()
return fullname

Expand Down
30 changes: 30 additions & 0 deletions web/tests/meeting/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,36 @@ def test_join_meeting_as_authenticated_attendee(
assert response.form["fullname"].value == "Bob Dylan"


def test_fix_authenticated_attendee_name_case(client_app, meeting, user):
"""The user names coming from the identity provider might be uppercase. In
such cases b3desk should correct the display.
https://github.com/numerique-gouv/b3desk/issues/47
"""

user.given_name = "JOHN"
user.family_name = "LENNON"
user.email = "[email protected]"
with client_app.session_transaction() as session:
session["current_provider"] = "attendee"
session["last_authenticated"] = "true"
session["userinfo"] = {
"given_name": user.given_name,
"family_name": user.family_name,
"email": user.email,
}

url = f"/meeting/join/{meeting.id}/authenticated"
response = client_app.get(url, status=302)

assert "/meeting/wait/1/creator/1/hash/" in response.location
assert "John%20Lennon" in response.location

response = response.follow()

assert response.form["fullname"].value == "John Lennon"


def test_join_meeting_as_authenticated_attendee_with_fullname_suffix(
client_app, meeting, authenticated_attendee, bbb_response
):
Expand Down

0 comments on commit e026371

Please sign in to comment.