Skip to content

Commit

Permalink
cookies get key hotfix (#1076)
Browse files Browse the repository at this point in the history
Co-authored-by: peterstone2017 <[email protected]>
  • Loading branch information
YunchuWang and peterstone2017 authored Jul 26, 2022
1 parent 7afe38f commit 068fbf8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion azure_functions_worker/bindings/datumdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def datum_as_proto(datum: Datum) -> protos.TypedData:
k: v.value
for k, v in datum.value['headers'].items()
},
cookies=parse_to_rpc_http_cookie_list(datum.value['cookies']),
cookies=parse_to_rpc_http_cookie_list(datum.value.get('cookies')),
enable_content_negotiation=False,
body=datum_as_proto(datum.value['body']),
))
Expand Down
15 changes: 14 additions & 1 deletion tests/unittests/test_datumref.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from azure_functions_worker import protos
from azure_functions_worker.bindings.datumdef import \
parse_cookie_attr_expires, \
parse_cookie_attr_same_site, parse_to_rpc_http_cookie_list
parse_cookie_attr_same_site, parse_to_rpc_http_cookie_list, Datum
from azure_functions_worker.bindings.nullable_converters import \
to_nullable_bool, to_nullable_string, to_nullable_double, \
to_nullable_timestamp
Expand Down Expand Up @@ -127,3 +127,16 @@ def test_parse_to_rpc_http_cookie_list_valid(self):
rpc_cookies = parse_to_rpc_http_cookie_list([cookies])
self.assertEqual(cookie1, rpc_cookies[0])
self.assertEqual(cookie2, rpc_cookies[1])

def test_parse_to_rpc_http_cookie_list_no_cookie(self):
datum = Datum(
type='http',
value=dict(
status_code=None,
headers=None,
body=None,
)
)

self.assertIsNone(
parse_to_rpc_http_cookie_list(datum.value.get('cookies')))

0 comments on commit 068fbf8

Please sign in to comment.