mirror of
https://github.com/correl/tornado-openapi3.git
synced 2024-11-14 19:19:32 +00:00
Do not validate test requests using absolute URLs
The response validation in the fetch method of AsyncOpenAPITestCase is intended for requests made to the application under test only, and must not be executed on requests made to other services using absolute URLs.
This commit is contained in:
parent
c804381b15
commit
118c23e704
2 changed files with 9 additions and 0 deletions
|
@ -106,6 +106,9 @@ class IncorrectResponseTests(BaseTestCase):
|
|||
self.fetch("/resource")
|
||||
self.assertEqual("400", context.exception.http_status)
|
||||
|
||||
def test_errors_not_raised_when_using_absolute_url(self) -> None:
|
||||
self.fetch(self.get_url("/resource"))
|
||||
|
||||
|
||||
class RaiseErrorTests(BaseTestCase):
|
||||
spec_dict = spec(
|
||||
|
|
|
@ -87,7 +87,13 @@ class AsyncOpenAPITestCase(tornado.testing.AsyncHTTPTestCase):
|
|||
fails, an :class:`openapi_core.exceptions.OpenAPIError` will be raised
|
||||
describing the failure.
|
||||
|
||||
If the path begins with http:// or https://, it will be treated as a
|
||||
full URL and will be fetched as-is, and no validation will occur.
|
||||
|
||||
"""
|
||||
if path.lower().startswith(("http://", "https://")):
|
||||
return super().fetch(path, raise_error=raise_error, **kwargs)
|
||||
|
||||
response = super().fetch(path, raise_error=False, **kwargs)
|
||||
result = self.validator.validate(response)
|
||||
result.raise_for_errors()
|
||||
|
|
Loading…
Reference in a new issue