0
0
Testing Fundamentalstesting~10 mins

Security testing basics in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if a password input is not empty before testing security.

Testing Fundamentals
if [1]:
Drag options to blanks, or click blank then click option'
Apassword is None
Bpassword
Cnot password
Dpassword == ''
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'password == ''' which checks if password is empty, not if it exists.
Using 'not password' which is the opposite of what we want here.
2fill in blank
medium

Complete the code to test if user input contains SQL injection risk by checking for a single quote character.

Testing Fundamentals
if '[1]' in user_input:
Drag options to blanks, or click blank then click option'
A;
B"
C--
D'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for double quotes instead of single quotes.
Checking for semicolon which is less common in simple injection.
3fill in blank
hard

Fix the error in the code that tries to assert user role is 'admin' for security check.

Testing Fundamentals
assert user_role [1] 'admin', "User is not admin"
Drag options to blanks, or click blank then click option'
A!=
B=
C==
Dis
Attempts:
3 left
💡 Hint
Common Mistakes
Using single equals = instead of double equals ==.
Using is which checks identity, not equality.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps usernames to their hashed passwords only if password length is greater than 8.

Testing Fundamentals
secure_users = {user: [1] for user, password in users.items() if len(password) [2] 8}
Drag options to blanks, or click blank then click option'
Ahash(password)
B>
C<
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the raw password instead of hashing it.
Using less than < instead of greater than >.
5fill in blank
hard

Fill all three blanks to create a test that asserts the login function raises a ValueError when given an empty username.

Testing Fundamentals
with pytest.raises([1]):
    login([2]=[3])
Drag options to blanks, or click blank then click option'
AValueError
Busername
C""
DTypeError
Attempts:
3 left
💡 Hint
Common Mistakes
Using TypeError instead of ValueError.
Passing a non-empty username.
Using wrong argument name.