diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ca933841d0..dac8d10c77 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,11 @@ Change Log Unreleased ---------- +[4.15.9] +-------- +* fix: return a 404 response for inactive CSOD customers while fetching courses + + [4.15.8] -------- * fix: SSO self-serve tool invalid entityId parsing diff --git a/enterprise/__init__.py b/enterprise/__init__.py index b2ccb8aee4..98b31ee5eb 100644 --- a/enterprise/__init__.py +++ b/enterprise/__init__.py @@ -2,4 +2,4 @@ Your project description goes here. """ -__version__ = "4.15.8" +__version__ = "4.15.9" diff --git a/integrated_channels/cornerstone/views.py b/integrated_channels/cornerstone/views.py index d55715715d..7ad228ce36 100644 --- a/integrated_channels/cornerstone/views.py +++ b/integrated_channels/cornerstone/views.py @@ -14,6 +14,7 @@ from rest_framework.response import Response from django.apps import apps +from django.core.exceptions import ObjectDoesNotExist from django.utils.http import parse_http_date_safe from enterprise.api.throttles import ServiceUserThrottle @@ -126,10 +127,20 @@ def get(self, request, *args, **kwargs): }) worker_user = get_enterprise_worker_user() - enterprise_config = CornerstoneEnterpriseCustomerConfiguration.objects.get( - enterprise_customer=enterprise_customer, - active=True - ) + try: + enterprise_config = CornerstoneEnterpriseCustomerConfiguration.objects.get( + enterprise_customer=enterprise_customer, + active=True + ) + except ObjectDoesNotExist: + return Response( + status=status.HTTP_404_NOT_FOUND, + data={ + "message": ( + "No active Cornerstone configuration found for given ciid." + ) + }) + exporter = enterprise_config.get_content_metadata_exporter(worker_user) transmitter = enterprise_config.get_content_metadata_transmitter() diff --git a/tests/test_integrated_channels/test_cornerstone/test_views.py b/tests/test_integrated_channels/test_cornerstone/test_views.py index b39d55cb32..865ae5bdf2 100644 --- a/tests/test_integrated_channels/test_cornerstone/test_views.py +++ b/tests/test_integrated_channels/test_cornerstone/test_views.py @@ -69,6 +69,20 @@ def test_course_list_invalid_ciid(self): response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + @responses.activate + def test_course_list_invalid_ciid(self): + """ + Test courses list with ciid of existing customer but with a non-active config + """ + self.config.active = False + self.config.save() + url = '{path}?ciid={customer_uuid}'.format( + path=self.course_list_url, + customer_uuid=self.enterprise_customer_catalog.enterprise_customer.uuid + ) + response = self.client.get(url) + self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + def test_course_list_with_skip_key_if_none_false(self): """ Test courses list view produces desired json when SKIP_KEY_IF_NONE is set to False