Added the "decode_next" utility in the "accounting.utils.next_uri" module, and applied the "encode_next" and "decode_next" utilities to the NextUriTestCase test case, so that the test case do not need to get involved into the detail of the next URI encryption.

This commit is contained in:
2023-06-08 09:27:39 +08:00
parent 30fd9c2164
commit 9072de82d4
2 changed files with 24 additions and 28 deletions

View File

@ -75,8 +75,7 @@ def __get_next() -> str | None:
if next_uri is None:
return None
try:
return URLSafeSerializer(current_app.config["SECRET_KEY"])\
.loads(next_uri, "next")
return decode_next(next_uri)
except BadData:
return None
@ -107,6 +106,16 @@ def encode_next(uri: str) -> str:
.dumps(uri, "next")
def decode_next(uri: str) -> str:
"""Decodes the encoded next URI.
:param uri: The encoded next URI.
:return: The next URI.
"""
return URLSafeSerializer(current_app.config["SECRET_KEY"])\
.loads(uri, "next")
def init_app(bp: Blueprint) -> None:
"""Initializes the application.