Skip to content

Commit 52e78d6

Browse files
committed
test: Add test for Django cookie expiry time format
1 parent f7276c4 commit 52e78d6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/Django/test_django.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from inspect import isawaitable
1717
from typing import Any, Dict, Union
1818

19+
from datetime import datetime
1920
from django.http import HttpRequest, HttpResponse, JsonResponse
2021
from django.test import RequestFactory, TestCase
2122
from supertokens_python import InputAppInfo, SupertokensConfig, init
@@ -252,6 +253,13 @@ async def test_login_handle(self):
252253
assert len(cookies["sIdRefreshToken"]["value"]) > 0
253254
assert len(cookies["sRefreshToken"]["value"]) > 0
254255

256+
try:
257+
datetime.strptime(
258+
cookies["sAccessToken"]["expires"], "%a, %d %b %Y %H:%M:%S GMT"
259+
)
260+
except ValueError:
261+
assert False, "cookies expiry time doesn't have the correct format"
262+
255263
my_middleware = middleware(handle_view)
256264
request = self.factory.get("/handle", {"user_id": "user_id"})
257265

0 commit comments

Comments
 (0)