-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only accept known locations in request.errors.add() (fixes #99) #374
Conversation
From what I see in #376, it should probably also support |
3527260
to
df488a4
Compare
@Natim r? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently this tests need to be fixed: test_validated_querystring_and_schema_from_same_schema (cornice.tests.test_validation.TestServiceDefinition)
|
||
def test_raises_an_exception_when_location_is_unsupported(self): | ||
with self.assertRaises(ValueError): | ||
self.errors.add('something') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add tests for each accepted parameters?
@@ -18,7 +18,7 @@ def add(self, location, name=None, description=None, **kw): | |||
"""Registers a new error.""" | |||
allowed = ('body', 'querystring', 'url', 'header', 'path', | |||
'cookies', 'method') | |||
if location not in allowed: | |||
if location != '' and location not in allowed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really want to accept empty location?
@@ -16,6 +16,11 @@ def __init__(self, status=400): | |||
|
|||
def add(self, location, name=None, description=None, **kw): | |||
"""Registers a new error.""" | |||
allowed = ('body', 'querystring', 'url', 'header', 'path', | |||
'cookies', 'method') | |||
if location != '' and location not in allowed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really want to accept empty location?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what colander gives when you raise a validation error that is not related to a specific node (eg. provide param either via header or querystring
)
If this conflicts with your PR @tarekziade, do not take it into account, I'll rebase it later.
r?