Role-Based Access Control Test Cases: Admin, Member, and Viewer

By HiTest
6 min read

Role-based access control test cases should verify two outcomes: people can do the work their role permits, and they cannot complete actions their role forbids. Checking whether a settings link is visible covers only part of that behavior.

Start with a permission matrix, prepare separate accounts, and test allowed and denied paths against the same resource. Add organization context wherever a user can belong to multiple workspaces. A role name alone does not tell you which customer's data the account may access.

Write a permission matrix before writing cases

The following matrix is an example policy for a workspace app. It is not a universal definition of admin, member, or viewer. Your product owner should approve the actual rules, including ownership exceptions and custom permissions.

ActionAdminMemberViewer
Read workspace projectsAllowAllowAllow
Create a projectAllowAllowDeny
Invite a teammateAllowDenyDeny
Change another user's roleAllow, subject to owner rulesDenyDeny
Manage billingAllow if designated billing ownerDenyDeny

Prepare at least one account per role and two workspaces with distinguishable data. Avoid switching the role of one shared account between all tests: cached sessions and parallel runs can make the starting condition uncertain.

An example permission matrix allows all three roles to read, admin and member to create, and only admin to invite.

Open full size

Example policy: compare allowed and denied actions for each role, then add separate checks for server-side enforcement.

OWASP recommends denying access by default and validating authorization on every request. A hidden UI control does not establish server-side enforcement. Pair browser scenarios with integration tests that exercise the relevant endpoints. OWASP Authorization Cheat Sheet.

Core role-based access control test cases

Use disposable records and an authorized test environment for the following cases.

CaseActionExpected result
Allowed readOpen a workspace project as each permitted roleThe intended record is readable with the correct workspace context
Allowed creationCreate a project as a role permitted by the matrixThe saved project belongs to the selected workspace
Restricted creationAttempt the same workflow as a viewerCreation cannot be completed and no project is created
Admin navigationOpen member management as an adminThe expected management controls are usable
Restricted navigationOpen the known management URL as a memberThe app handles denied access without exposing protected content
Restricted mutationExercise the restricted operation through an integration testThe server rejects it and the target record remains unchanged
Resource ownershipTry editing another user's restricted recordBehavior follows the documented ownership rule
Organization boundaryUse a workspace A account to request a workspace B resourceThe resource is unavailable to that account
Role downgradeDowngrade an account while its browser session remains openSubsequent actions follow the documented revocation policy
Role upgradeGrant an additional permission and revisit the affected workflowAccess becomes available according to the documented refresh policy
Member removalRemove a test member and retry a protected actionAccess is revoked according to the product's session policy
Owner safeguardAttempt an owner transfer or final-owner removal in a disposable workspaceThe product enforces its ownership continuity rule

For boundary tests, knowing the resource identifier in advance makes the assertion stronger. An empty list may simply mean that the UI never asked for the other workspace's data. Test the relevant backend access separately rather than treating the empty list as complete isolation proof.

Example: verify a member cannot invite teammates

Suppose the approved policy reserves invitations for admins. A useful browser specification is:

Preconditions: an admin account and a member account in the same staging workspace; a disposable recipient; a documented invitation policy.

  1. As admin, open the invitation screen and confirm that the supported invitation workflow is available.
  2. Start a separate browser session as the member. Confirm the identity and active workspace.
  3. Try reaching the invitation workflow through ordinary navigation and its known route. Expect access to follow the member restriction.
  4. Confirm no invitation was created by the denied browser attempt.
  5. In an integration check, submit the invitation operation using the member's authorization context. Expect denial and no new invitation.

This is a test design example. It does not claim that a browser agent can inspect all invitation records or issue arbitrary authenticated API requests. The final two observations require the evidence sources your team has prepared.

Test permission changes with a session already open

Many useful regressions occur during a transition. An account opens the member list as admin; another admin downgrades it; the first account submits a change from its old tab.

Write the intended revocation rule before automating that scenario. If your product permits a documented propagation interval, test against that interval. Avoid inventing a universal immediate-refresh promise. Record the time of the role change and the time of the attempted operation so that a reviewer can distinguish stale UI from an enforcement failure.

Also check workspace switching. A person can be an admin in one organization and a viewer in another. Switch between those organizations and repeat the affected operation; the application should use the active organization's policy, including after a reload or direct navigation.

Keep role, plan, and ownership separate

A feature can depend on a paid plan as well as a role. A workspace admin may be allowed to manage a feature that the workspace has not purchased. Another resource may be editable only by its creator, even though two users share the same role.

Record these conditions separately in the test: role, workspace, subscription state, resource owner, and expected action. When a failure occurs, that context makes the rule under test identifiable. See subscription testing for entitlement transitions.

Run browser permission checks in HiTest

Create distinct test accounts for the roles your case uses. Include the intended workspace in account context, then write actions and expected results for each visible workflow. Keep denied access as an explicit expected result; an agent must not switch to a more privileged account to finish the task.

Review screenshots or recordings when available alongside the account and failed step. Treat the result as evidence for the tested journey. Endpoint-level authorization, tenant isolation, and a full security assessment need their own coverage.

See role-based workflow testing with HiTest for how these browser checks fit into the product workflow.

Frequently asked questions

Is hiding an admin button enough to pass an RBAC test?

It can satisfy a navigation requirement, but not an authorization requirement. Verify denied access through relevant routes and backend operations as well.

How many accounts are needed?

Start with separate accounts for the roles in the permission matrix and distinct organization data. Add ownership, custom-role, and subscription variations when they change the expected outcome.

Are RBAC regression tests a security audit?

They check specified permission behavior. They do not establish that every request, resource, integration, or attack path is secure. Use them alongside dedicated authorization and security testing.