Commit 3fb07280 authored by Barry Warsaw's avatar Barry Warsaw

Fix the error code for a corner case.

I.e. when the URL is good, but the request dictionary contains a bogus
attribute, you should get a 400 error, not a 404.

Also, fix some comments.
parent bb1d8bfb
Pipeline #566725 passed with stage
......@@ -218,9 +218,9 @@ class ListConfiguration:
def on_patch(self, request, response):
"""Patch the configuration (i.e. partial update)."""
if self._attribute is None:
# We're PATCHing one more attributes on the list's configuration
# resource, so all the writable attributes are valid candidates
# for updating.
# We're PATCHing one or more of the attributes on the list's
# configuration resource, so all the writable attributes are valid
# candidates for updating.
converters = ATTRIBUTES
else:
# We're PATCHing a specific list configuration attribute
......@@ -247,7 +247,7 @@ class ListConfiguration:
# This is the case where the URL points to the list's entire
# configuration resource, but the request dictionary contains a
# nonexistent attribute.
not_found(
bad_request(
response, 'Unknown attribute: {}'.format(error.attribute))
return
except ReadOnlyPATCHRequestError as error:
......
......@@ -33,8 +33,8 @@ from mailman.testing.layers import RESTLayer
from urllib.error import HTTPError
# The representation of the listconf resource as a dictionary. This is
# required when PUTting to the list's configuration resource.
# The representation of the listconf resource as a dictionary. This is used
# when PUTting to the list's configuration resource.
RESOURCE = dict(
acceptable_aliases=[
'[email protected]',
......@@ -212,7 +212,7 @@ class TestConfiguration(unittest.TestCase):
call_api('http://localhost:9001/3.0/lists/ant.example.com/config',
dict(bogus=1),
'PATCH')
self.assertEqual(cm.exception.code, 404)
self.assertEqual(cm.exception.code, 400)
self.assertEqual(cm.exception.reason, b'Unknown attribute: bogus')
def test_read_only_patch_attribute(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment