Design a tenant-and-role authorization test matrix.
Instruction: Use only the provided fixtures to test read and update access, including denied operations and their side effects.
In a fictional isolated test environment, you own tenants A and B, documents A1 and B1, and four fixture users: A-viewer, A-editor, B-viewer, and B-editor. Each user belongs only to the named tenant. Viewers may read their tenant’s document but may not update it. Editors may read and update their tenant’s document. No user may read or update another tenant’s document. The agreed API contract returns 200 for allowed operations, 403 for authenticated denials, and 401 without authentication. Denials must reveal no document content and cause no update. Test sessions and document identifiers must come only from these fixtures; production and unknown identifiers are out of scope.
Updated
Example Answer
I would cross each of the four authenticated users with both fixture documents and both operations, then add anonymous read and update checks for each document. That gives 16 authenticated checks plus four anonymous checks, or 20 total. The matrix contains six allowed outcomes and 14 denials.
I would keep sessions separate and verify fixture identity before each case. For allowed reads, I would compare the returned content with the expected tenant marker; for allowed updates, I would use a reversible unique value and verify the intended stored document changed. For denials, I would check the specified status, absence of document content, and unchanged stored state using an authorized verification session. A 403 response alone is insufficient if the update still occurred.
I would run these checks against the service boundary because a disabled UI action does not prove authorization. I would also retain a small UI check for the expected controls. All objects and identities are controlled fixtures; there is no need to search for real customer identifiers.
Complete authorization matrix
| Fixture principal → document | Read | Update |
|---|---|---|
| A-viewer → A1 | 200 | 403; unchanged |
| A-viewer → B1 | 403; no content | 403; unchanged |
| A-editor → A1 | 200 | 200; A1 only |
| A-editor → B1 | 403; no content | 403; unchanged |
| B-viewer → A1 | 403; no content | 403; unchanged |
| B-viewer → B1 | 200 | 403; unchanged |
| B-editor → A1 | 403; no content | 403; unchanged |
| B-editor → B1 | 200 | 200; B1 only |
| Anonymous → A1 | 401; no content | 401; unchanged |
| Anonymous → B1 | 401; no content | 401; unchanged |
What the interviewer is assessing
Core checks (1 point each):
- Covers both documents for all four roles and anonymous read/update.
- Produces six allowed and 14 denied outcomes under the supplied contract.
- Checks no data disclosure or update on denial.
Stronger (+1 after all core checks): Enumerates all 20 checks with six allowed outcomes, verifies session identity and stored state independently, and separates service enforcement from UI behavior.
Acceptable alternatives: A matrix or parameterized API suite works; UI hiding is insufficient.
Red flags: Checks only menu visibility, tests real customer records, or treats a denial status as proof that no side effect occurred.
Follow-up
The implementation returns 404 for cross-tenant requests instead of 403. Is that automatically a security failure?
Example response: It differs from the stated API contract, so I would record the mismatch and ask whether the team intentionally wants existence-hiding behavior. A consistent 404 can be a defensible design, but changing the status does not remove the requirement to reveal no content and perform no update. I would align the documented contract and tests after the owner’s decision.
Pressure test
A batch-update endpoint is added. The contract says any forbidden item rejects the whole batch with 403 and changes nothing. What new case matters?
Example response: I would submit one permitted fixture A1 and one forbidden fixture B1 in the same batch as A-editor, then verify 403 and that both documents are unchanged. I would repeat with the item order reversed to detect partial work before a late authorization check. A batch containing only A1 is the positive control. Testing each single-item request separately would not prove atomic authorization for the combined operation.
Related Questions
-
easy
-
easy
-
easy
-
easy
-
easy
-
easy