From 796726376a6d2c221f9438bf1eb5473c0b9c797b Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 18 Jun 2024 14:46:40 -0700 Subject: [PATCH] chore: make flask-talisman work with test config (#29277) --- docker/pythonpath_dev/superset_config.py | 1 - scripts/tests/run.sh | 3 +++ superset/config.py | 2 +- superset/initialization/__init__.py | 2 +- tests/integration_tests/superset_test_config.py | 1 - 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docker/pythonpath_dev/superset_config.py b/docker/pythonpath_dev/superset_config.py index 69477d56e..c78a50414 100644 --- a/docker/pythonpath_dev/superset_config.py +++ b/docker/pythonpath_dev/superset_config.py @@ -97,7 +97,6 @@ ALERT_REPORTS_NOTIFICATION_DRY_RUN = True WEBDRIVER_BASEURL = "http://superset:8088/" # When using docker compose baseurl should be http://superset_app:8088/ # The base URL for the email report hyperlinks. WEBDRIVER_BASEURL_USER_FRIENDLY = WEBDRIVER_BASEURL - SQLLAB_CTAS_NO_LIMIT = True # diff --git a/scripts/tests/run.sh b/scripts/tests/run.sh index d77adc08e..bf8431cae 100755 --- a/scripts/tests/run.sh +++ b/scripts/tests/run.sh @@ -61,7 +61,10 @@ function test_init() { DB_NAME="test" DB_USER="superset" DB_PASSWORD="superset" + +# Pointing to use the test database in local docker-compose setup export SUPERSET__SQLALCHEMY_DATABASE_URI=${SUPERSET__SQLALCHEMY_DATABASE_URI:-postgresql+psycopg2://"${DB_USER}":"${DB_PASSWORD}"@localhost/"${DB_NAME}"} + export SUPERSET_CONFIG=${SUPERSET_CONFIG:-tests.integration_tests.superset_test_config} RUN_INIT=1 RUN_RESET_DB=1 diff --git a/superset/config.py b/superset/config.py index 3dfeb3ad4..d3a4694a0 100644 --- a/superset/config.py +++ b/superset/config.py @@ -261,7 +261,7 @@ WTF_CSRF_EXEMPT_LIST = [ ] # Whether to run the web server in debug mode or not -DEBUG = os.environ.get("FLASK_DEBUG") +DEBUG = parse_boolean_string(os.environ.get("FLASK_DEBUG")) FLASK_USE_RELOAD = True # Enable profiling of Python calls. Turn this on and append ``?_instrument=1`` diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py index 65e518b7c..a98b8c948 100644 --- a/superset/initialization/__init__.py +++ b/superset/initialization/__init__.py @@ -586,7 +586,7 @@ class SupersetAppInitializer: # pylint: disable=too-many-public-methods talisman_enabled = self.config["TALISMAN_ENABLED"] talisman_config = ( self.config["TALISMAN_DEV_CONFIG"] - if self.superset_app.debug + if self.superset_app.debug or self.config["DEBUG"] else self.config["TALISMAN_CONFIG"] ) csp_warning = self.config["CONTENT_SECURITY_POLICY_WARNING"] diff --git a/tests/integration_tests/superset_test_config.py b/tests/integration_tests/superset_test_config.py index e0a112395..a23472b01 100644 --- a/tests/integration_tests/superset_test_config.py +++ b/tests/integration_tests/superset_test_config.py @@ -40,7 +40,6 @@ SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join( # noqa: F405 DATA_DIR, "unittests.integration_tests.db", # noqa: F405 ) -DEBUG = False SILENCE_FAB = False # Allowing SQLALCHEMY_DATABASE_URI and SQLALCHEMY_EXAMPLES_URI to be defined as an env vars for # continuous integration