Skip to content

Commit

Permalink
fix: add utf-8 encoding for user fields
Browse files Browse the repository at this point in the history
  • Loading branch information
alangsto committed May 30, 2024
1 parent 2efe2bb commit ce038d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lti_consumer/lti_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ def extract_real_user_data(self):
user_data = {
'user_email': None,
'user_username': None,
'user_full_name': user.full_name,
'user_full_name': user.full_name.encode(),
'user_language': None,
}

Expand Down
9 changes: 5 additions & 4 deletions lti_consumer/tests/unit/test_lti_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,8 @@ def setUp(self):
fake_user_email = '[email protected]'
fake_user.emails = [fake_user_email]

full_name_mock = PropertyMock(return_value='fake_full_name')
fake_name = 'fáke fǔll ñamë'
full_name_mock = PropertyMock(return_value=fake_name)
type(fake_user).full_name = full_name_mock

fake_username = 'fake'
Expand Down Expand Up @@ -1077,7 +1078,7 @@ def test_lti_launch_pii_sharing(

set_user_data_kwargs['person_sourcedid'] = 'fake' if pii_sharing_enabled and ask_to_send_username else None
set_user_data_kwargs['person_name_full'] = (
'fake_full_name' if pii_sharing_enabled and ask_to_send_full_name else None
'fáke fǔll ñamë'.encode() if pii_sharing_enabled and ask_to_send_full_name else None
)
set_user_data_kwargs['person_contact_email_primary'] = (
'[email protected]' if pii_sharing_enabled and ask_to_send_email else None
Expand Down Expand Up @@ -1814,7 +1815,7 @@ def test_get_lti_1p3_launch_data(
fake_user_email = '[email protected]'
fake_username = 'fake_username'

fake_name = 'fake_full_name'
fake_name = 'fáke fǔll ñamë'
full_name_mock = PropertyMock(return_value=fake_name)
type(fake_user).full_name = full_name_mock

Expand Down Expand Up @@ -1866,7 +1867,7 @@ def test_get_lti_1p3_launch_data(
expected_launch_data_kwargs["preferred_username"] = fake_username

if ask_to_send_full_name:
expected_launch_data_kwargs["name"] = fake_name
expected_launch_data_kwargs["name"] = fake_name.encode()

if ask_to_send_email:
expected_launch_data_kwargs["email"] = fake_user_email
Expand Down

0 comments on commit ce038d4

Please sign in to comment.