fix: clear TOTP_SECRET env var in test_verify_totp_no_secret_enabled
Run Tests / Backend Tests (push) Failing after 1m2s
Run Tests / Test Summary (push) Has been cancelled
Run Tests / Frontend Tests (push) Has started running

This commit is contained in:
Gan, Jimmy
2026-04-04 13:51:22 +08:00
parent 83fc231c75
commit 9f67c57a43
+6 -1
View File
@@ -230,10 +230,15 @@ class TestTOTP:
assert not verify_totp("000000") 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.""" """Test that TOTP verification passes when 2FA not enabled."""
# Clear any existing secret from previous tests # Clear any existing secret from previous tests
save_totp_secret("") 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) # No secret saved, should return True (2FA disabled)
assert verify_totp("any_code") assert verify_totp("any_code")