From 20bac3a99fe18948b1e9cc49485209f331afe3f9 Mon Sep 17 00:00:00 2001 From: Bryan Wilson Date: Mon, 26 Jun 2023 11:16:44 -0700 Subject: [PATCH 1/5] use tahoe-idp 2.4.2 Syncs first, last, full names back to IdP --- requirements/edx/appsembler.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/edx/appsembler.txt b/requirements/edx/appsembler.txt index acbbe794624..0e9e6e6d068 100644 --- a/requirements/edx/appsembler.txt +++ b/requirements/edx/appsembler.txt @@ -23,7 +23,7 @@ https://github.com/appsembler/edx-proctoring/archive/v2.4.0-appsembler1.tar.gz django-tiers==0.2.7 fusionauth-client==1.36.0 google-cloud-storage==1.32.0 -tahoe-idp==2.3.0 +tahoe-idp==2.4.2 tahoe-sites==1.3.2 tahoe-lti==0.3.0 site-configuration-client==0.2.3 From 118c1322bc7da3669d2acd5c7c4ab51875858fff Mon Sep 17 00:00:00 2001 From: Bryan Wilson Date: Mon, 26 Jun 2023 18:22:37 -0700 Subject: [PATCH 2/5] Mock out tahoe-idp package receiver code in tests using ENABLE_TAHOE_IDP It relies on configuration that we don't set up in test --- .../djangoapps/appsembler/tahoe_idp/tests/patches.py | 10 ++++++++++ .../tahoe_idp/tests/test_tahoe_idp_account_deletion.py | 4 ++++ .../tahoe_idp/tests/test_tahoe_idp_email_change.py | 4 ++++ .../tahoe_idp/tests/test_tahoe_idp_reset_password.py | 3 +++ .../tahoe_idp/tests/test_tahoe_registration_api.py | 4 ++++ 5 files changed, 25 insertions(+) create mode 100644 openedx/core/djangoapps/appsembler/tahoe_idp/tests/patches.py diff --git a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/patches.py b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/patches.py new file mode 100644 index 00000000000..0fd4d15f2b2 --- /dev/null +++ b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/patches.py @@ -0,0 +1,10 @@ +""" +patching helpers +""" + +from mock import Mock + + +# Keep Signal receivers in tahoe_idp from executing fully when not explicitly testing +dummy_receivers_idp_not_enabled = Mock() +dummy_receivers_idp_not_enabled.return_value = False diff --git a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_account_deletion.py b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_account_deletion.py index 513cf3169fa..80b50bcfdd5 100644 --- a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_account_deletion.py +++ b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_account_deletion.py @@ -8,6 +8,7 @@ from django.urls import reverse from django.contrib.auth import get_user_model + from rest_framework.test import APITestCase from rest_framework import status @@ -18,6 +19,8 @@ setup_retirement_states, # pylint: disable=unused-import ) +from . import patches + @patch.dict('django.conf.settings.FEATURES', {'SKIP_EMAIL_VALIDATION': True}) @pytest.mark.usefixtures("setup_retirement_states") @@ -64,6 +67,7 @@ def deactivate_user(self, color, username=None): }) return response + @patch('tahoe_idp.receivers.helpers.is_tahoe_idp_enabled', new=patches.dummy_receivers_idp_not_enabled) @patch('tahoe_idp.api.get_tahoe_idp_id_by_user') @patch('tahoe_idp.api.deactivate_user') @patch.dict('django.conf.settings.FEATURES', {'ENABLE_TAHOE_IDP': True}) diff --git a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_email_change.py b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_email_change.py index a240b4db7f3..0228f3e47c7 100644 --- a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_email_change.py +++ b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_email_change.py @@ -12,6 +12,8 @@ from student.models import PendingEmailChange from student.tests.factories import PendingEmailChangeFactory, UserFactory +from . import patches + @skip_unless_lms class EmailChangeWithIdpTests(TestCase): @@ -37,11 +39,13 @@ def test_successful_email_change_without_idp(self, mock_update_user_email): 'Should not use idp unless explicitly enabled via ENABLE_TAHOE_IDP' ) + @patch('tahoe_idp.receivers.helpers.is_tahoe_idp_enabled', new=patches.dummy_receivers_idp_not_enabled) @patch('tahoe_idp.api.update_user_email') def test_successful_email_change_with_idp(self, mock_update_user_email): """ Test `confirm_email_change` with ENABLE_TAHOE_IDP = True. """ + with patch.dict(settings.FEATURES, {'ENABLE_TAHOE_IDP': True}): response = self.client.get(reverse('confirm_email_change', args=[self.key])) diff --git a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_reset_password.py b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_reset_password.py index b2ab7fe5264..aedb06bd0a1 100644 --- a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_reset_password.py +++ b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_idp_reset_password.py @@ -13,9 +13,12 @@ from student.tests.factories import UserFactory +from . import patches + @ddt.ddt @skip_unless_lms +@patch('tahoe_idp.receivers.helpers.is_tahoe_idp_enabled', new=patches.dummy_receivers_idp_not_enabled) @patch('tahoe_idp.api.request_password_reset') class TahoeIdpResetPasswordTests(TestCase): """ diff --git a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_registration_api.py b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_registration_api.py index 4cabca20b69..9ad24c21101 100644 --- a/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_registration_api.py +++ b/openedx/core/djangoapps/appsembler/tahoe_idp/tests/test_tahoe_registration_api.py @@ -12,6 +12,8 @@ from ...multi_tenant_emails.tests.test_utils import with_organization_context +from . import patches + APPSEMBLER_API_VIEWS_MODULE = 'openedx.core.djangoapps.appsembler.api.v1.views' @@ -51,6 +53,7 @@ def test_api_without_tahoe_idp(self, url): content = response.content.decode('utf-8') assert response.status_code == status.HTTP_200_OK, '{} {}'.format(color1, content) + @patch('tahoe_idp.receivers.helpers.is_tahoe_idp_enabled', new=patches.dummy_receivers_idp_not_enabled) @patch.dict('django.conf.settings.FEATURES', {'ENABLE_TAHOE_IDP': True}) @ddt.data( reverse_lazy('tahoe-api:v1:registrations-list'), @@ -60,6 +63,7 @@ def test_api_wit_tahoe_idp(self, url): """ Both v1 and v2 API shouldn't work with Tahoe IdP. """ + color1 = 'red1' with with_organization_context(site_color=color1): response = self.register_user(url, 'red_learner') From 1f6b2c99c348997010b7c051e0a6e3a3c6809e47 Mon Sep 17 00:00:00 2001 From: Bryan Wilson Date: Wed, 28 Jun 2023 12:49:38 -0700 Subject: [PATCH 3/5] Use tahoe-idp 2.4.3 (test fixes) --- requirements/edx/appsembler.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/edx/appsembler.txt b/requirements/edx/appsembler.txt index 0e9e6e6d068..7103d4d82b8 100644 --- a/requirements/edx/appsembler.txt +++ b/requirements/edx/appsembler.txt @@ -23,7 +23,7 @@ https://github.com/appsembler/edx-proctoring/archive/v2.4.0-appsembler1.tar.gz django-tiers==0.2.7 fusionauth-client==1.36.0 google-cloud-storage==1.32.0 -tahoe-idp==2.4.2 +tahoe-idp==2.4.3 tahoe-sites==1.3.2 tahoe-lti==0.3.0 site-configuration-client==0.2.3 From 18c2c99b9c7c06d3e36082e122d9c62ee5bb1259 Mon Sep 17 00:00:00 2001 From: Bryan Wilson Date: Wed, 28 Jun 2023 17:40:42 -0700 Subject: [PATCH 4/5] Use tahoe-idp 2.4.4 --- requirements/edx/appsembler.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/edx/appsembler.txt b/requirements/edx/appsembler.txt index 7103d4d82b8..285032f316d 100644 --- a/requirements/edx/appsembler.txt +++ b/requirements/edx/appsembler.txt @@ -23,7 +23,7 @@ https://github.com/appsembler/edx-proctoring/archive/v2.4.0-appsembler1.tar.gz django-tiers==0.2.7 fusionauth-client==1.36.0 google-cloud-storage==1.32.0 -tahoe-idp==2.4.3 +tahoe-idp==2.4.4 tahoe-sites==1.3.2 tahoe-lti==0.3.0 site-configuration-client==0.2.3 From 9b072a4502d1a61519cf81571de12d0e49e675fc Mon Sep 17 00:00:00 2001 From: Bryan Wilson Date: Fri, 30 Jun 2023 11:22:05 -0700 Subject: [PATCH 5/5] Use tahoe-idp 2.5.0 Handles edge case with remaining Users without an IdP UserSocialAuth --- requirements/edx/appsembler.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/edx/appsembler.txt b/requirements/edx/appsembler.txt index 285032f316d..1db50b37640 100644 --- a/requirements/edx/appsembler.txt +++ b/requirements/edx/appsembler.txt @@ -23,7 +23,7 @@ https://github.com/appsembler/edx-proctoring/archive/v2.4.0-appsembler1.tar.gz django-tiers==0.2.7 fusionauth-client==1.36.0 google-cloud-storage==1.32.0 -tahoe-idp==2.4.4 +tahoe-idp==2.5.0 tahoe-sites==1.3.2 tahoe-lti==0.3.0 site-configuration-client==0.2.3