Complete the code to check if the login function correctly rejects empty passwords.
def test_empty_password(): result = login(username='user1', password=[1]) assert result == False
The test passes an empty string as password to verify the system rejects it.
Complete the code to test if the system locks the account after 3 failed login attempts.
def test_account_lock(): for _ in range(3): login(username='user2', password='wrong') locked = check_account_locked(username='user2') assert locked == [1]
The test expects the account to be locked (True) after 3 failed attempts.
Fix the error in the test that checks if password reset tokens expire after 1 hour.
def test_token_expiry(): token = generate_reset_token(user_id=5) time.sleep([1]) expired = is_token_expired(token) assert expired == True
The token expires after 3600 seconds (1 hour), so the test waits that long before checking.
Fill both blanks to create a test that verifies the system rejects SQL injection attempts in the username field.
def test_sql_injection(): malicious_input = "admin' OR 1=1 --" result = login(username=malicious_input, password=[1]) assert result == [2]
The test uses a malicious username and expects login to fail (False) regardless of password.
Fill all three blanks to write a test that checks if multi-factor authentication (MFA) is required after login.
def test_mfa_required(): user = login(username='user3', password=[1]) mfa_status = check_mfa_status(user_id=[2]) assert mfa_status == [3]
The test logs in with a valid password, checks MFA status for user ID 3, and expects MFA to be required (True).