Skip to content

Commit

Permalink
Merge pull request #1350 from appsembler/main
Browse files Browse the repository at this point in the history
Update from `main` (production)
  • Loading branch information
bryanlandia authored Jun 30, 2023
2 parents d49c84d + 4dcd91f commit f1a3a0d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions openedx/core/djangoapps/appsembler/tahoe_idp/tests/patches.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand Down Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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]))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down Expand Up @@ -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'),
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/appsembler.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.0
tahoe-sites==1.3.2
tahoe-lti==0.3.0
site-configuration-client==0.2.3
Expand Down

0 comments on commit f1a3a0d

Please sign in to comment.