From 9f67c57a4385a5ee6778856cf3f7c5b713be8c70 Mon Sep 17 00:00:00 2001 From: "Gan, Jimmy" Date: Sat, 4 Apr 2026 13:51:22 +0800 Subject: [PATCH] fix: clear TOTP_SECRET env var in test_verify_totp_no_secret_enabled --- dashboard/backend/tests/unit/test_auth.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dashboard/backend/tests/unit/test_auth.py b/dashboard/backend/tests/unit/test_auth.py index f4b59ec..2fe8fdd 100644 --- a/dashboard/backend/tests/unit/test_auth.py +++ b/dashboard/backend/tests/unit/test_auth.py @@ -230,10 +230,15 @@ class TestTOTP: assert not verify_totp("000000") - def test_verify_totp_no_secret_enabled(self, mock_config, temp_auth_file): + def test_verify_totp_no_secret_enabled(self, mock_config, temp_auth_file, monkeypatch): """Test that TOTP verification passes when 2FA not enabled.""" # Clear any existing secret from previous tests save_totp_secret("") + # Also clear environment variable fallback + monkeypatch.setenv("TOTP_SECRET", "") + import importlib + import config + importlib.reload(config) # No secret saved, should return True (2FA disabled) assert verify_totp("any_code")