Defensive verification cases
Define the requirement first
A verification case states the initial conditions, input, expected result and evidence to collect. A positive case checks intended behavior; a negative case checks that a forbidden operation is denied. In our local library model, an active member may read their own note; a different member or inactive account must be denied. These expectations come from a fictional approved requirement R1, independently of implementation.
Model ordinary behavior
Treat a decision function as a small toy application: read_allowed receives the authenticated identity, active flag, action and owner. It returns a boolean only, never actual note content. The fixed rule allows only a nonempty matching identity, explicit active status and action read. Missing or unknown values fail closed. There is no network, storage or real account in this example.
Compare expected decisions
For member A, active=True, action read, owner A, expect allow. For member A and owner B, expect deny; for member A inactive, expect deny even when owner matches. For an unknown action or absent identity, expect deny. The supplied static review says an earlier design omitted the ownership condition; do not run that design against a service. Implement the safe rule in a local copy of the starter, then check every supplied case.
Avoid misleading green tests
A function that always denies passes all negative cases but breaks authorized use. A function that always allows passes a positive case but fails protection. Separate the expected decisions from the code being tested and include both types. The model tests policy decisions only; they do not prove identity verification, database filtering, concurrency handling or complete coverage. A test skipped because of scope is not a pass.
Practice a decision table
Before opening the model, write expected results for active owner, inactive owner, another owner and missing identity. Implement the rule in the supplied starter, record the results and explain one limitation. Compare your outcomes to the approved requirement, not merely to a reference implementation. In the next lesson, document the static finding and its evidence.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Defensive verification cases — knowledge check
Apply authorized assessment principles to fictional scenarios.
Where do expected results originate?
An active owner reads their note. Expected?
What should a missing identity produce?
Why include a positive test?
What does a skipped case mean?