mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Only allow update service to modify named attrs
To prevent typos and inadvertently updating something we shouldn’t, this adds some filtering to the update_service method to make sure it is only allowed to update certain attributes of a service.
This commit is contained in:
@@ -81,6 +81,21 @@ class ServiceAPIClient(NotificationsAPIClient):
|
||||
"""
|
||||
Update a service.
|
||||
"""
|
||||
disallowed_attributes = set(kwargs.keys()) - {
|
||||
'name',
|
||||
'users',
|
||||
'message_limit',
|
||||
'active',
|
||||
'restricted',
|
||||
'email_from',
|
||||
'reply_to_email_address',
|
||||
'sms_sender'
|
||||
}
|
||||
if disallowed_attributes:
|
||||
raise TypeError('Not allowed to update service attributes: {}'.format(
|
||||
", ".join(disallowed_attributes)
|
||||
))
|
||||
|
||||
_attach_current_user(kwargs)
|
||||
endpoint = "/service/{0}".format(service_id)
|
||||
return self.post(endpoint, data)
|
||||
|
||||
Reference in New Issue
Block a user