Merge pull request #2 from gmr/include-cookies

Include cookies in the Request validation
This commit is contained in:
Correl Roush 2021-01-18 13:32:18 -05:00 committed by GitHub
commit ecd5709a87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -124,7 +124,9 @@ class TestRequestFactory(unittest.TestCase):
expected = OpenAPIRequest( expected = OpenAPIRequest(
full_url_pattern=url, full_url_pattern=url,
method="get", method="get",
parameters=RequestParameters(query=ImmutableMultiDict(parameters)), parameters=RequestParameters(
query=ImmutableMultiDict(parameters), path={}, cookie={}
),
body=b"", body=b"",
mimetype="application/x-www-form-urlencoded", mimetype="application/x-www-form-urlencoded",
) )

View file

@ -9,7 +9,7 @@ from openapi_core.validation.request.datatypes import ( # type: ignore
) )
from openapi_core.validation.request import validators # type: ignore from openapi_core.validation.request import validators # type: ignore
from tornado.httpclient import HTTPRequest # type: ignore from tornado.httpclient import HTTPRequest # type: ignore
from tornado.httputil import HTTPServerRequest # type: ignore from tornado.httputil import HTTPServerRequest, parse_cookie # type: ignore
from werkzeug.datastructures import ImmutableMultiDict, Headers from werkzeug.datastructures import ImmutableMultiDict, Headers
from .util import parse_mimetype from .util import parse_mimetype
@ -43,7 +43,9 @@ class TornadoRequestFactory:
full_url_pattern=path, full_url_pattern=path,
method=request.method.lower() if request.method else "get", method=request.method.lower() if request.method else "get",
parameters=RequestParameters( parameters=RequestParameters(
query=query_arguments, header=Headers(request.headers.get_all()) query=query_arguments,
header=Headers(request.headers.get_all()),
cookie=parse_cookie(request.headers.get("Cookie", "")),
), ),
body=request.body if request.body else b"", body=request.body if request.body else b"",
mimetype=parse_mimetype( mimetype=parse_mimetype(