ENT-2518 Fix Enterprise Login Page not showing to the user (#22602)
This commit is contained in:
@@ -371,7 +371,7 @@ def enterprise_customer_from_cache(request=None, uuid=None):
|
||||
enterprise_customer = cache.get(cache_key)
|
||||
|
||||
# Check if it's cached in the session.
|
||||
if not enterprise_customer and request and request.user.is_authenticated:
|
||||
if not enterprise_customer and request:
|
||||
enterprise_customer = request.session.get('enterprise_customer')
|
||||
|
||||
return enterprise_customer
|
||||
|
||||
@@ -318,6 +318,22 @@ class TestEnterpriseApi(EnterpriseServiceMockMixin, CacheIsolationTestCase):
|
||||
self.assertEqual(mock_enterprise_customer_from_api.called, False)
|
||||
self.assertEqual(mock_enterprise_customer_from_cache.called, True)
|
||||
|
||||
# Verify enterprise customer data fetched from session for subsequent calls
|
||||
# with unauthenticated user in SAML case
|
||||
del dummy_request.user
|
||||
|
||||
with mock.patch(
|
||||
'openedx.features.enterprise_support.api.enterprise_customer_from_api',
|
||||
return_value=enterprise_data
|
||||
) as mock_enterprise_customer_from_api, mock.patch(
|
||||
'openedx.features.enterprise_support.api.enterprise_customer_from_cache',
|
||||
return_value=enterprise_data
|
||||
) as mock_enterprise_customer_from_cache:
|
||||
enterprise_customer = enterprise_customer_for_request(dummy_request)
|
||||
self.assertEqual(enterprise_customer, enterprise_data)
|
||||
self.assertEqual(mock_enterprise_customer_from_api.called, False)
|
||||
self.assertEqual(mock_enterprise_customer_from_cache.called, True)
|
||||
|
||||
def check_data_sharing_consent(self, consent_required=False, consent_url=None):
|
||||
"""
|
||||
Used to test the data_sharing_consent_required view decorator.
|
||||
|
||||
Reference in New Issue
Block a user