Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def parse_to_rpc_http_cookie_list(cookies: Optional[List[SimpleCookie]], protos)
protos.RpcHttpCookie(name=name,
value=cookie_entity.value,
domain=to_nullable_string(
cookie_entity['domain'],
cookie_entity['domain'] or None,
'cookie.domain',
protos),
path=to_nullable_string(
Expand Down
10 changes: 10 additions & 0 deletions runtimes/v1/tests/unittests/test_datumdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ def test_parse_cookie_attr_same_site_explicit_none(self):
def test_parse_to_rpc_http_cookie_list_none(self):
self.assertEqual(parse_to_rpc_http_cookie_list(None, protos), None)

def test_host_only_cookie_omits_domain(self):
cookie = SimpleCookie()
cookie.load('__Host-test=value; Path=/; Secure; HttpOnly; SameSite=Lax')

rpc_cookie = parse_to_rpc_http_cookie_list([cookie], protos)[0]

self.assertFalse(rpc_cookie.HasField('domain'))
self.assertEqual(rpc_cookie.path.value, '/')
self.assertTrue(rpc_cookie.secure.value)

def test_parse_to_rpc_http_cookie_list_valid(self):
headers = [
'foo=bar; Path=/some/path; Secure; HttpOnly; Domain=123; '
Expand Down
2 changes: 1 addition & 1 deletion runtimes/v2/azure_functions_runtime/bindings/datumdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def parse_to_rpc_http_cookie_list(cookies: Optional[List[SimpleCookie]], protos)
protos.RpcHttpCookie(name=name,
value=cookie_entity.value,
domain=to_nullable_string(
cookie_entity['domain'],
cookie_entity['domain'] or None,
'cookie.domain',
protos),
path=to_nullable_string(
Expand Down
10 changes: 10 additions & 0 deletions runtimes/v2/tests/unittests/test_datumdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ def test_parse_cookie_attr_same_site_explicit_none(self):
def test_parse_to_rpc_http_cookie_list_none(self):
self.assertEqual(parse_to_rpc_http_cookie_list(None, protos), None)

def test_host_only_cookie_omits_domain(self):
cookie = SimpleCookie()
cookie.load('__Host-test=value; Path=/; Secure; HttpOnly; SameSite=Lax')

rpc_cookie = parse_to_rpc_http_cookie_list([cookie], protos)[0]

self.assertFalse(rpc_cookie.HasField('domain'))
self.assertEqual(rpc_cookie.path.value, '/')
self.assertTrue(rpc_cookie.secure.value)

def test_parse_to_rpc_http_cookie_list_valid(self):
headers = [
'foo=bar; Path=/some/path; Secure; HttpOnly; Domain=123; '
Expand Down
2 changes: 1 addition & 1 deletion workers/azure_functions_worker/bindings/datumdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def parse_to_rpc_http_cookie_list(cookies: Optional[List[SimpleCookie]]):
protos.RpcHttpCookie(name=name,
value=cookie_entity.value,
domain=to_nullable_string(
cookie_entity['domain'],
cookie_entity['domain'] or None,
'cookie.domain'),
path=to_nullable_string(
cookie_entity['path'], 'cookie.path'),
Expand Down
10 changes: 10 additions & 0 deletions workers/tests/unittests/test_datumref.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ def test_parse_cookie_attr_same_site_explicit_none(self):
def test_parse_to_rpc_http_cookie_list_none(self):
self.assertEqual(parse_to_rpc_http_cookie_list(None), None)

def test_host_only_cookie_omits_domain(self):
cookie = SimpleCookie()
cookie.load('__Host-test=value; Path=/; Secure; HttpOnly; SameSite=Lax')

rpc_cookie = parse_to_rpc_http_cookie_list([cookie])[0]

self.assertFalse(rpc_cookie.HasField('domain'))
self.assertEqual(rpc_cookie.path.value, '/')
self.assertTrue(rpc_cookie.secure.value)

def test_parse_to_rpc_http_cookie_list_valid(self):
headers = [
'foo=bar; Path=/some/path; Secure; HttpOnly; Domain=123; '
Expand Down
2 changes: 1 addition & 1 deletion workers/tests/unittests/test_http_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def test_set_cookie_header_in_response_default_value(self):
'set_cookie_resp_header_default_values')
self.assertEqual(r.status_code, 200)
self.assertEqual(r.headers.get('Set-Cookie'),
'foo=bar; domain=; path=')
'foo=bar; path=')

def test_response_cookie_header_nullable_timestamp_err(self):
r = self.webhost.request(
Expand Down