Skip to content

Commit 27cd252

Browse files
committed
Update gateway cookie test to reproduce #1557
1 parent cafd263 commit 27cd252

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/test_gateway.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,16 +397,20 @@ def test_gateway_request_with_expiring_cookies(
397397
GatewayClient.clear_instance()
398398
_ = jp_configurable_serverapp(argv=argv)
399399

400-
cookie: SimpleCookie = SimpleCookie()
401-
cookie.load("SERVERID=1234567; Path=/")
400+
headers = {}
401+
# Use comma-separated Set-Cookie headers to demonstrate the issue
402+
headers["Set-Cookie"] = "SERVERID=016723f5|12345678; Max-Age=172800; Path=/; HttpOnly," \
403+
"username-my-server=2|1:0|10:1756250589|35:username-my-server|144:123abc789|87654321; " \
404+
"Max-Age=172800; Path=/; HttpOnly"
402405
if expire_arg == "Expires":
403406
expire_param = format_datetime(
404407
datetime.now(tz=timezone.utc) + timedelta(seconds=expire_param)
405408
)
406409
if expire_arg:
407-
cookie["SERVERID"][expire_arg] = expire_param
410+
# Replace the first SERVERID cookie's Max-Age with the new expire parameter
411+
headers["Cookie"] = headers["Set-Cookie"].replace("Max-Age=172800", f"{expire_arg}={expire_param}")
408412

409-
GatewayClient.instance().update_cookies(cookie)
413+
GatewayClient.instance().update_cookies(headers)
410414

411415
args = {}
412416
if existing_cookies:

0 commit comments

Comments
 (0)