Skip to content

Commit

Permalink
Changing to a negative check for the environment list
Browse files Browse the repository at this point in the history
  • Loading branch information
srh-sloan committed Dec 5, 2024
1 parent 2e3c4d7 commit bcd824d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fsd_utils/config/commonconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CommonConfig:
def _resolve_secret_key(flask_env: str = None) -> str:
secret_key = os.getenv("SECRET_KEY", None)
if not secret_key:
if flask_env in ["dev", "test", "uat", "production"]:
if flask_env not in ["unit_test", "development"]:
raise KeyError("SECRET_KEY is not present in environment")
secret_key = "dev-secret" # pragma: allowlist secret
return secret_key
Expand Down
5 changes: 4 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
("development", "dev_key", "dev_key"),
("uat", "abc123", "abc123"),
("development", "", "dev-secret"),
("db_migrations", "", "dev-secret"),
("unit_test", "", "dev-secret"),
("prod", "prod_secret", "prod_secret"),
],
)
def test_config(flask_env, env_secret_key, exp_secret_key):
Expand Down Expand Up @@ -41,6 +42,8 @@ def test_config(flask_env, env_secret_key, exp_secret_key):
"production",
"",
),
("db_migrations", ""),
("prod", ""),
],
)
def test_config_error(flask_env, env_secret_key):
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bcd824d

Please sign in to comment.