ENT-729
This commit is contained in:
@@ -10,6 +10,8 @@ If true, it:
|
||||
b) calls apply_settings(), passing in the Django settings
|
||||
"""
|
||||
|
||||
from openedx.features.enterprise_support.api import insert_enterprise_pipeline_elements
|
||||
|
||||
_FIELDS_STORED_IN_SESSION = ['auth_entry', 'next']
|
||||
_MIDDLEWARE_CLASSES = ['third_party_auth.middleware.ExceptionMiddleware']
|
||||
_SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/dashboard'
|
||||
@@ -59,6 +61,9 @@ def apply_settings(django_settings):
|
||||
'third_party_auth.pipeline.login_analytics',
|
||||
]
|
||||
|
||||
# Add enterprise pipeline elements if the enterprise app is installed
|
||||
insert_enterprise_pipeline_elements(django_settings.SOCIAL_AUTH_PIPELINE)
|
||||
|
||||
# Required so that we can use unmodified PSA OAuth2 backends:
|
||||
django_settings.SOCIAL_AUTH_STRATEGY = 'third_party_auth.strategy.ConfigurationModelStrategy'
|
||||
|
||||
|
||||
@@ -547,3 +547,20 @@ def get_dashboard_consent_notification(request, user, course_enrollments):
|
||||
}
|
||||
)
|
||||
return ''
|
||||
|
||||
|
||||
def insert_enterprise_pipeline_elements(pipeline):
|
||||
"""
|
||||
If the enterprise app is enabled, insert additional elements into the
|
||||
pipeline related to enterprise.
|
||||
"""
|
||||
if not enterprise_enabled():
|
||||
return
|
||||
|
||||
additional_elements = (
|
||||
'enterprise.tpa_pipeline.handle_enterprise_logistration',
|
||||
)
|
||||
|
||||
insert_point = pipeline.index('social_core.pipeline.social_auth.load_extra_data')
|
||||
for index, element in enumerate(additional_elements):
|
||||
pipeline.insert(insert_point + index, element)
|
||||
|
||||
@@ -25,6 +25,8 @@ from openedx.features.enterprise_support.api import (
|
||||
enterprise_customer_for_request,
|
||||
get_dashboard_consent_notification,
|
||||
get_enterprise_consent_url,
|
||||
insert_enterprise_pipeline_elements,
|
||||
enterprise_enabled,
|
||||
)
|
||||
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin
|
||||
from openedx.features.enterprise_support.utils import get_cache_key
|
||||
@@ -428,3 +430,25 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
|
||||
self.assertIn(substr, notification_string)
|
||||
else:
|
||||
self.assertEqual(notification_string, '')
|
||||
|
||||
@override_settings(FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=False))
|
||||
def test_utils_with_enterprise_disabled(self):
|
||||
"""
|
||||
Test that disabling the enterprise integration flag causes
|
||||
the utilities to return the expected default values.
|
||||
"""
|
||||
self.assertFalse(enterprise_enabled())
|
||||
self.assertEqual(insert_enterprise_pipeline_elements(None), None)
|
||||
|
||||
def test_utils_with_enterprise_enabled(self):
|
||||
"""
|
||||
Test that enabling enterprise integration (which is currently on by default) causes the
|
||||
the utilities to return the expected values.
|
||||
"""
|
||||
self.assertTrue(enterprise_enabled())
|
||||
pipeline = ['abc', 'social_core.pipeline.social_auth.load_extra_data', 'def']
|
||||
insert_enterprise_pipeline_elements(pipeline)
|
||||
self.assertEqual(pipeline, ['abc',
|
||||
'enterprise.tpa_pipeline.handle_enterprise_logistration',
|
||||
'social_core.pipeline.social_auth.load_extra_data',
|
||||
'def'])
|
||||
|
||||
@@ -47,7 +47,7 @@ edx-lint==0.4.3
|
||||
astroid==1.3.8
|
||||
edx-django-oauth2-provider==1.2.5
|
||||
edx-django-sites-extensions==2.3.0
|
||||
edx-enterprise==0.53.13
|
||||
edx-enterprise==0.53.14
|
||||
edx-oauth2-provider==1.2.2
|
||||
edx-opaque-keys==0.4.0
|
||||
edx-organizations==0.4.7
|
||||
|
||||
Reference in New Issue
Block a user