Include cookies in the Request validation

This commit is contained in:
Gavin M. Roy 2021-01-18 13:23:31 -05:00
parent 2b57d71113
commit 4896a5d5e0
2 changed files with 7 additions and 3 deletions

View file

@ -124,7 +124,9 @@ class TestRequestFactory(unittest.TestCase):
expected = OpenAPIRequest(
full_url_pattern=url,
method="get",
parameters=RequestParameters(query=ImmutableMultiDict(parameters)),
parameters=RequestParameters(
query=ImmutableMultiDict(parameters), path={}, cookie={}
),
body=b"",
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 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 .util import parse_mimetype
@ -43,7 +43,9 @@ class TornadoRequestFactory:
full_url_pattern=path,
method=request.method.lower() if request.method else "get",
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"",
mimetype=parse_mimetype(