Complete the code to check if a password input is not empty before testing security.
if [1]:
We check if the variable password has any value (not empty) before proceeding.
Complete the code to test if user input contains SQL injection risk by checking for a single quote character.
if '[1]' in user_input:
We check for a single quote ' because it is commonly used in SQL injection attacks.
Fix the error in the code that tries to assert user role is 'admin' for security check.
assert user_role [1] 'admin', "User is not admin"
= instead of double equals ==.is which checks identity, not equality.The assertion must check equality with ==. Using = causes syntax error.
Fill both blanks to create a dictionary comprehension that maps usernames to their hashed passwords only if password length is greater than 8.
secure_users = {user: [1] for user, password in users.items() if len(password) [2] 8}< instead of greater than >.We hash the password for security and only include users with passwords longer than 8 characters.
Fill all three blanks to create a test that asserts the login function raises a ValueError when given an empty username.
with pytest.raises([1]): login([2]=[3])
TypeError instead of ValueError.The test expects a ValueError when username is empty string "".