From 2964f206a610e3412f4f9918be5fa9422c2f2546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 1 Feb 2023 15:54:31 +0800 Subject: [PATCH] Revised the test site to use the secret key specified in the environment variables when possible, so that the secret key and session keeps in the development environment. --- tests/testsite/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testsite/__init__.py b/tests/testsite/__init__.py index 8254847..aac97e4 100644 --- a/tests/testsite/__init__.py +++ b/tests/testsite/__init__.py @@ -17,6 +17,7 @@ """The Mia! Accounting Flask demonstration website. """ +import os import typing as t from secrets import token_urlsafe @@ -45,7 +46,7 @@ def create_app(is_testing: bool = False) -> Flask: app: Flask = Flask(__name__) db_uri: str = "sqlite:///" if is_testing else "sqlite:///local.sqlite" app.config.from_mapping({ - "SECRET_KEY": token_urlsafe(32), + "SECRET_KEY": os.environ.get("SECRET_KEY", token_urlsafe(32)), "SQLALCHEMY_DATABASE_URI": db_uri, "BABEL_DEFAULT_LOCALE": "en", "ALL_LINGUAS": "zh_Hant|正體中文,en|English,zh_Hans|简体中文",