Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use tahoe-idp 2.4.2 #1348

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -64,18 +65,23 @@ def deactivate_user(self, color, username=None):
})
return response

@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})
def test_disallow_email_reuse_after_deactivate(
self, mock_deactivate_user, mock_get_tahoe_idp_id_by_user
self, mock_deactivate_user, mock_get_tahoe_idp_id_by_user, mock_user_sync_to_idp
):
"""
Test the account deletion with Tahoe IdP support.
"""
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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from django.conf import settings
from django.core import mail
from django.test import TestCase
from django.test import override_settings, TestCase
from django.urls import reverse
from unittest.mock import patch

Expand Down Expand Up @@ -37,6 +37,7 @@ def test_successful_email_change_without_idp(self, mock_update_user_email):
'Should not use idp unless explicitly enabled via ENABLE_TAHOE_IDP'
)

@override_settings(TAHOE_IDP_CONFIGS={'API_KEY':'fake', 'BASE_URL': 'http://localhost'})
@patch('tahoe_idp.api.update_user_email')
def test_successful_email_change_with_idp(self, mock_update_user_email):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,6 +17,7 @@

@ddt.ddt
@skip_unless_lms
@patch('tahoe_idp.receivers.user_sync_to_idp') # no-op
@patch('tahoe_idp.api.request_password_reset')
class TahoeIdpResetPasswordTests(TestCase):
"""
Expand All @@ -31,7 +33,7 @@ class TahoeIdpResetPasswordTests(TestCase):
'enable_tahoe_idp': True,
'message': 'Tahoe 2.0 logic: should NOT send email via Open edX, `tahoe_idp` takes care of that',
})
def test_reset_password_with_tahoe_idp(self, mock_request_password_reset, enable_tahoe_idp, message):
def test_reset_password_with_tahoe_idp(self, mock_request_password_reset, mock_user_sync_to_idp, enable_tahoe_idp, message):
"""
Tests Tahoe IdP/non-idp password reset.
"""
Expand All @@ -41,6 +43,11 @@ def test_reset_password_with_tahoe_idp(self, mock_request_password_reset, enable
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,15 +52,20 @@ 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.user_sync_to_idp') # no-op
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_TAHOE_IDP': True})
@ddt.data(
reverse_lazy('tahoe-api:v1:registrations-list'),
reverse_lazy('tahoe-api:v2:registrations-list'),
)
def test_api_wit_tahoe_idp(self, url):
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')
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.4.2
tahoe-sites==1.3.2
tahoe-lti==0.3.0
site-configuration-client==0.2.3
Expand Down