Merge dev to main: Security improvements and comprehensive test infrastructure #39

Merged
jimmy merged 195 commits from dev into main 2026-04-08 01:42:27 +08:00
Showing only changes of commit 7fb92ccebf - Show all commits
+11 -1
View File
@@ -245,11 +245,21 @@ class TestTOTP:
def test_verify_totp_replay_protection(self, mock_config, temp_auth_file, sample_totp_secret):
"""Test that same TOTP code cannot be used twice."""
save_totp_secret(sample_totp_secret)
# Ensure auth file is properly initialized with last_totp_ts
import json
with open(temp_auth_file, 'r') as f:
data = json.load(f)
data['last_totp_ts'] = 0
with open(temp_auth_file, 'w') as f:
json.dump(data, f)
totp = pyotp.TOTP(sample_totp_secret)
valid_code = totp.now()
# First use should succeed
assert verify_totp(valid_code)
result = verify_totp(valid_code)
assert result, f"First TOTP verification failed for code {valid_code}"
# Second use of same code should fail (replay protection)
assert not verify_totp(valid_code)