Prepare two fictional records

This is a paper-based teaching example. All accounts, clients, contracts and amounts below are fictional. You can use the cases in your own practice project and then record the actual results.

Practice account Client record it may read Contract ID Amount
A A-001 HT-A-01 10,000 CNY
B B-001 HT-B-01 20,000 CNY

The first requirement is to look up a contract by record ID after login, returning only records the current account may access. Adding, editing and exporting are outside this first exercise.

How the problem might arise

Suppose the page requires login, but its API looks up only the record ID in the input. A enters A-001 and gets its own contract. If entering B-001 also returns B's contract, the query lacks a data access restriction.

Showing only A's clients in the page does not protect the API. A request can come through another route or be modified.

How to arrange the query

  1. Obtain the current identity on the server from a validated login state. Reject reads of restricted material when there is no login.
  2. Search within the records that identity may access, together with the entered record ID. Do not trust an account identity supplied by the request itself.
  3. If there is no accessible record, return a message without contract content. The page might say, “No accessible record found.”

A real system may grant access by person, team or another business rule. Write the rules first, then choose the data structure and implementation that fit.

A test plan for checking a change

The table below contains planned tests and expected results. You need to run them in your own project; these are not completed test results.

Login state and action Expected result
A looks up A-001 Return HT-A-01, amount 10,000 CNY
A looks up B-001 Do not return B's contract or amount
B looks up B-001 Return HT-B-01, amount 20,000 CNY
B looks up A-001 Do not return A's contract or amount
No login; request A-001 directly Reject the read without returning contract content
A bypasses the page and requests B-001 directly Apply the same access check; do not return B's records
A enters an ID that does not exist Show a clear message without other contract content

Record the account, input and actual result for each attempt. Check whether the response contains other records that the page does not display. Looking only at the page can miss extra data returned by the API.

Apply the same rule to new entry points

If you later add search, export or AI Q&A, check that each uses the same data access scope. The system's permissions should also determine what AI can read before answering.

These cases mainly check reading across accounts. A complete project needs other checks according to its features: input handling, editing permissions, logs, deployment and backups. Use the pre-launch checklist to add relevant checks, and the one-page brief to define requirements first.

Questions

Is this a real client project?
No. It is a fictional, paper-based teaching example. The accounts, clients and contracts are practice data. The tables list test cases you can run in a practice project, not an executed test report.
Why might a logged-in user still see someone else’s records?
Login establishes identity. Server-side queries must also restrict data according to that identity. A lookup based only on a client name or record ID may not use the logged-in identity to check permission.

Read next


Book a free 15-minute call See pricing & scope