Skip to content

Commit

Permalink
Merge pull request #369 from YunoHost/fix_tests
Browse files Browse the repository at this point in the history
test: Fix usage of deprecated non-str cookies
  • Loading branch information
alexAubin authored Dec 4, 2024
2 parents b479b17 + 2fbf88c commit 61610ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion test/src/authenticators/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#

import logging
import json
from moulinette.utils.text import random_ascii
from moulinette.core import MoulinetteError, MoulinetteAuthenticationError
from moulinette.authentication import BaseAuthenticator
Expand Down Expand Up @@ -56,7 +57,7 @@ def set_session_cookie(self, infos):

response.set_cookie(
"moulitest",
new_infos,
json.dumps(new_infos),
secure=True,
secret=session_secret,
httponly=True,
Expand All @@ -68,6 +69,7 @@ def get_session_cookie(self, raise_if_no_session_exists=True):

try:
infos = request.get_cookie("moulitest", secret=session_secret, default={})
infos = json.loads(infos)
except Exception:
if not raise_if_no_session_exists:
return {"id": random_ascii()}
Expand Down
4 changes: 3 additions & 1 deletion test/src/authenticators/yoloswag.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#

import logging
import json
from moulinette.utils.text import random_ascii
from moulinette.core import MoulinetteError, MoulinetteAuthenticationError
from moulinette.authentication import BaseAuthenticator
Expand Down Expand Up @@ -56,7 +57,7 @@ def set_session_cookie(self, infos):

response.set_cookie(
"moulitest",
new_infos,
json.dumps(new_infos),
secure=True,
secret=session_secret,
httponly=True,
Expand All @@ -68,6 +69,7 @@ def get_session_cookie(self, raise_if_no_session_exists=True):

try:
infos = request.get_cookie("moulitest", secret=session_secret, default={})
infos = json.loads(infos)
except Exception:
if not raise_if_no_session_exists:
return {"id": random_ascii()}
Expand Down

0 comments on commit 61610ce

Please sign in to comment.