Skip to content

Commit

Permalink
fix: return 404 for inactive csod configs (#2076)
Browse files Browse the repository at this point in the history
  • Loading branch information
sameenfatima78 authored Apr 19, 2024
1 parent d382a0d commit 5648d58
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.15.8"
__version__ = "4.15.9"
19 changes: 15 additions & 4 deletions integrated_channels/cornerstone/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
14 changes: 14 additions & 0 deletions tests/test_integrated_channels/test_cornerstone/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5648d58

Please sign in to comment.