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 e97d242a235..197e9cf6aa5 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 @@ -6,6 +6,7 @@ import pytest from social_django.models import UserSocialAuth +from django.db.models.signals import post_save from django.urls import reverse from django.contrib.auth import get_user_model from rest_framework.test import APITestCase @@ -64,7 +65,7 @@ def deactivate_user(self, color, username=None): }) return response - @patch('tahoe_idp.receivers.user_sync_to_idp') # no-op + @patch('tahoe_idp.receivers.user_sync_to_idp') @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}) @@ -77,6 +78,10 @@ def test_disallow_email_reuse_after_deactivate( social_auth_uid = 'e1ede4d8-f6f6-11ec-9eb7-f778f1c67e22' mock_get_tahoe_idp_id_by_user.return_value = social_auth_uid + # mock out receivers which rely on a real Tenant Id + post_save.connect(mock_user_sync_to_idp, sender=User, dispatch_uid='tahoe_idp.receivers.user_sync_to_idp') + post_save.connect(mock_user_sync_to_idp, sender=UserProfile, dispatch_uid='tahoe_idp.receivers.user_sync_to_idp') + with with_organization_context(site_color=self.RED): register_res = self.register_user(self.RED) assert register_res.status_code == status.HTTP_200_OK, register_res.content.decode('utf-8') 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 54481de702f..4a0593a0363 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 @@ -6,6 +6,7 @@ from django.conf import settings from django.core import mail +from django.db.models.signals import post_save from django.test import RequestFactory, TestCase from unittest.mock import Mock, patch from openedx.core.djangoapps.user_authn.views.password_reset import password_reset @@ -42,6 +43,11 @@ def test_reset_password_with_tahoe_idp(self, mock_request_password_reset, mock_u req.site = Mock(domain='example.com') req.user = user + # mock out receivers which rely on a real Tenant Id + post_save.connect(mock_user_sync_to_idp, sender=User, dispatch_uid='tahoe_idp.receivers.user_sync_to_idp') + post_save.connect(mock_user_sync_to_idp, sender=UserProfile, dispatch_uid='tahoe_idp.receivers.user_sync_to_idp') + + with patch.dict(settings.FEATURES, {'ENABLE_TAHOE_IDP': enable_tahoe_idp}): with patch('crum.get_current_request', return_value=req): response = password_reset(req) 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 b41f19c4580..40358b17632 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 @@ -4,6 +4,7 @@ import ddt from mock import patch +from django.db.models.signals import post_save from django.urls import reverse_lazy from rest_framework import status from rest_framework.test import APITestCase @@ -61,6 +62,10 @@ def test_api_wit_tahoe_idp(self, mock_user_sync_to_idp, url): """ Both v1 and v2 API shouldn't work with Tahoe IdP. """ + + post_save.connect(mock_user_sync_to_idp, sender=User, dispatch_uid='tahoe_idp.receivers.user_sync_to_idp') + post_save.connect(mock_user_sync_to_idp, sender=UserProfile, dispatch_uid='tahoe_idp.receivers.user_sync_to_idp') + color1 = 'red1' with with_organization_context(site_color=color1): response = self.register_user(url, 'red_learner')