Skip to content

Commit

Permalink
feat: not submitting sso orchestrator records if no changes occur
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-sheehan-edx committed Dec 7, 2023
1 parent 774ceba commit 7e5c312
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Change Log
Unreleased
----------
[4.8.10]
--------
feat: not submitting sso orchestrator records if no changes occur

[4.8.9]
-------
feat: adding timeouts to sso orchestrator configurations and api cleanup
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.8.9"
__version__ = "4.8.10"
18 changes: 15 additions & 3 deletions enterprise/api/v1/views/enterprise_customer_sso_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,22 @@ def update(self, request, *args, **kwargs):
return Response(status=HTTP_403_FORBIDDEN)
try:
with transaction.atomic():
needs_submitting = False
for request_key in request_data.keys():
# If the requested data to update includes a field that is locked while configuring
if request_key in EnterpriseCustomerSsoConfiguration.fields_locked_while_configuring:
# If any of the provided values differ from the existing value
existing_value = getattr(sso_configuration_record, request_key, request_data[request_key])
if existing_value != request_data[request_key]:
# Indicate that the record needs to be submitted for configuration to the orchestrator
needs_submitting = True

sso_configuration_record.update(**request_data)
sp_metadata_url = sso_configuration_record.first().submit_for_configuration(
updating_existing_record=True
)

if needs_submitting:
sp_metadata_url = sso_configuration_record.first().submit_for_configuration(
updating_existing_record=True
)
except (TypeError, FieldDoesNotExist, ValidationError, SsoOrchestratorClientError) as e:
LOGGER.error(f'{CONFIG_UPDATE_ERROR} {e}')
return Response({'error': f'{CONFIG_UPDATE_ERROR} {e}'}, status=HTTP_400_BAD_REQUEST)
Expand Down
4 changes: 2 additions & 2 deletions enterprise/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4110,9 +4110,9 @@ def submit_for_configuration(self, updating_existing_record=False):
for field in self.base_saml_config_fields:
if field == "active":
if not updating_existing_record:
config_data['enable'] = True
config_data['enabled'] = True
else:
config_data['enable'] = getattr(self, field)
config_data['enabled'] = getattr(self, field)
elif field_value := getattr(self, field):
config_data[utils.camelCase(field)] = field_value

Expand Down

0 comments on commit 7e5c312

Please sign in to comment.