0
0
Testing Fundamentalstesting~10 mins

Authentication testing 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 the login function returns True for valid credentials.

Testing Fundamentals
assert login('user1', 'password123') == [1]
Drag options to blanks, or click blank then click option'
ATrue
BFalse
CNone
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using False instead of True for successful login
Checking for None which means no return value
2fill in blank
medium

Complete the code to test that the login function raises an exception for empty username.

Testing Fundamentals
with pytest.raises([1]):
    login('', 'password123')
Drag options to blanks, or click blank then click option'
AKeyError
BValueError
CTypeError
DIndexError
Attempts:
3 left
💡 Hint
Common Mistakes
Using KeyError which is for missing dictionary keys
Using TypeError which is for wrong data types
3fill in blank
hard

Fix the error in the test that checks login failure with wrong password.

Testing Fundamentals
assert login('user1', [1]) == False
Drag options to blanks, or click blank then click option'
A'password123'
BNone
C'wrongpass'
D''
Attempts:
3 left
💡 Hint
Common Mistakes
Using the correct password which makes the test pass incorrectly
Using None which might cause exceptions
4fill in blank
hard

Fill both blanks to create a test that checks if the login function rejects SQL injection attempts.

Testing Fundamentals
assert login([1], [2]) == False
Drag options to blanks, or click blank then click option'
A'admin' OR '1'='1'
B'password123'
C' OR '1'='1'
D'admin'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the injection string as username instead of password
Using correct credentials which makes the test pass incorrectly
5fill in blank
hard

Fill all three blanks to create a test that verifies the lockout after 3 failed login attempts.

Testing Fundamentals
for _ in range([1]):
    assert login('user2', [2]) == False
assert login('user2', [3]) == 'locked'
Drag options to blanks, or click blank then click option'
A3
B'wrongpass'
C'password123'
D'locked'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the correct password which makes the test pass incorrectly
Using wrong number of attempts in the loop