Would a Bristol school portal let you in with your username and a friend's password?
You’re signing in to a fictional school portal in Bristol. You type your own username, but you put in a friend’s password by mistake. The portal has both details on file. Should it let you in?
You’ve already used presence and length checks. Here, the portal checks that you typed a username and that your password has at least six characters. Passing validation just means your input meets those rules.
Watch the two test records appear. Nia’s row has mint four two. Sam’s row has kite eight three. If you type nia as the username, follow that row across. Mint four two is the password you need to compare with what you typed.
You’ve entered sam and a password with six characters, so both validation checks pass. Before you compare the password, which stored record should you use? Pick one answer.
This check is called authentication. When you enter a username, you claim to be that account holder. A password that matches the same record is the evidence this routine accepts. The readable passwords are for exam practice. Real systems should store salted password hashes.
Try nia with mint four two. Nia is present, and mint four two has six characters, so validation passes. Now look up nia’s record. Its stored password is mint four two, which matches exactly. Both checks pass, so the portal grants access.
Now you enter sam with mint four two. You’ve changed the username and kept the password from the worked example. What happens at validation and authentication? Pick the result that fits both checks.
You expect the portal to reject nia with kite eight three. Separate searches find the username in row one and the password in row two, so they wrongly grant access. That’s a logic error. Compare kite eight three with mint four two in nia’s record instead, and the routine correctly denies access.
Predict what each test should do. Seven characters is a normal valid length, but this password doesn’t match. At the boundary, six passes and matches, while five fails validation. An empty username is erroneous even with a long enough password. Run the tests and compare actual results with your predictions.