CY10: Capstone: a clinic app you can vouch for

Lesson 3 of 5 · reading 15–25 minutes; practice and project time is on the module page

Project 2: fixing the app, with proof

🎯You'll be able to

Fix the app's code flaws, login and session weaknesses and settings, each with a test that failed first.

🏠The everyday picture

An electrician who fixes faults hands over a test certificate for each circuit, so the next electrician knows exactly what was done and checked.

📘What it really is

📝A worked example

Input: test 6 failing in the starter, because unknown users get "No such user".

Steps:

  1. Read the failure: unknown users and wrong passwords must get the same message.
  2. Change login to return "Wrong user ID or password." for both, and check a dummy hash for unknown users so timing is similar.
  3. Add the lock: count failures in the last 15 minutes before checking the password.

Expected output: test 6 passing, and a fix note naming the flaw, the change and the test.

🌍Where it's used

📝Case scenario

A team fixed the injection flaw in March without a test, then removed the fix during a refactor in June. In the capstone, every fix has a test, so the same refactor would fail at once.

🖱️Try it

After finishing, run python -m pytest tests/test_fixes.py -q. Success: 10 passed, and your fix notes name a test for each fix.

⚠️Common mistakes

🛠️For your project

Project 2 is complete when its 10 tests pass and its marking guide is ticked with evidence.

✅Quick check

Which test checks that the right password still has to wait during a lock?

Show the answer

Test 6.

What must the fix notes say for each fix?

Show the answer

The flaw, the change, the test that proves it, and what someone could have done with the flaw.

← PreviousProject 1: assessing the old server
ProLearners Assist