Skip to content

Commit

Permalink
fix: add utf-8 encoding for user fields (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
alangsto authored May 30, 2024
1 parent 2efe2bb commit 83384f0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ Please See the `releases tab <https://github.com/openedx/xblock-lti-consumer/rel
Unreleased
~~~~~~~~~~

9.11.1 - 2024-04-24
-------------------
* Add utf-8 encoding for user full name

9.11.0 - 2024-04-24
-------------------
* Remove lxml pin


9.10.0 - 2024-02-29
------------------
* Remove Transifex calls and bundled translation files for the OEP-58 proposal.
Expand Down
2 changes: 1 addition & 1 deletion lti_consumer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .apps import LTIConsumerApp
from .lti_xblock import LtiConsumerXBlock

__version__ = '9.11.0'
__version__ = '9.11.1'
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 83384f0

Please sign in to comment.