Skip to content

Commit

Permalink
Replace hard-coded cookie expiration dates in WPT Python files
Browse files Browse the repository at this point in the history
These cookies are meant to expire in the future (i.e. be valid now), but
by hard-coding the expiration date, they will no longer be valid when
the date expires. This changes the hard-coded expiration dates to a date
guaranteed to be in the future.

Change-Id: Ia0aa5b02483af76d198f09061e6073f538bba8e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2872768
Auto-Submit: Lily Chen <[email protected]>
Reviewed-by: Aaron Tagliaboschi <[email protected]>
Commit-Queue: Lily Chen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#879417}
  • Loading branch information
chlily1 authored and chromium-wpt-export-bot committed May 5, 2021
1 parent c1b69da commit bae534d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions content-security-policy/reporting/support/set-cookie.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import date

def main(request, response):
"""
Returns cookie name and path from query params in a Set-Cookie header.
Expand All @@ -11,15 +13,16 @@ def main(request, response):
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Set-Cookie: match-slash=1; Path=/; Expires=Wed, 09 Jun 2021 10:18:14 GMT
< Set-Cookie: match-slash=1; Path=/; Expires=09 Jun 2021 10:18:14 GMT
< Server: BaseHTTP/0.3 Python/2.7.12
< Date: Tue, 04 Oct 2016 18:16:06 GMT
< Content-Length: 80
"""

name = request.GET[b'name']
path = request.GET[b'path']
cookie = b"%s=1; Path=%s; Expires=Wed, 09 Jun 2021 10:18:14 GMT" % (name, path)
expiry_year = date.today().year + 1
cookie = b"%s=1; Path=%s; Expires=09 Jun %d 10:18:14 GMT" % (name, path, expiry_year)

headers = [
(b"Content-Type", b"application/json"),
Expand Down
7 changes: 5 additions & 2 deletions cookies/resources/set-cookie.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import date

def main(request, response):
"""
Returns cookie name and path from query params in a Set-Cookie header.
Expand All @@ -11,15 +13,16 @@ def main(request, response):
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Set-Cookie: match-slash=1; Path=/; Expires=Wed, 09 Jun 2021 10:18:14 GMT
< Set-Cookie: match-slash=1; Path=/; Expires=09 Jun 2021 10:18:14 GMT
< Server: BaseHTTP/0.3 Python/2.7.12
< Date: Tue, 04 Oct 2016 18:16:06 GMT
< Content-Length: 80
"""

name = request.GET[b'name']
path = request.GET[b'path']
cookie = b"%s=1; Path=%s; Expires=Wed, 09 Jun 2021 10:18:14 GMT" % (name, path)
expiry_year = date.today().year + 1
cookie = b"%s=1; Path=%s; Expires=09 Jun %d 10:18:14 GMT" % (name, path, expiry_year)

headers = [
(b"Content-Type", b"application/json"),
Expand Down

0 comments on commit bae534d

Please sign in to comment.