{
  "id": 23350343,
  "title": "We Replaced 85 Brittle RBAC UI Tests With One 60-Line Permission Matrix",
  "url": "https://urgent.news/2026/12/03/we-replaced-85-brittle-rbac-ui-tests-with-one-60-line-permission",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-03T22:46:40.000Z",
  "source": {
    "name": "HackerNoon",
    "slug": "hackernoon",
    "url": "https://hackernoon.com/we-replaced-85-brittle-rbac-ui-tests-with-one-60-line-permission-matrix?source=rss"
  },
  "original_language": null,
  "account": "The wire material describes how a software team replaced 85 brittle role-based access control (RBAC) UI tests with a single 60-line permission matrix. The team found that their 85 Playwright tests, which took 18 minutes to run in CI, missed a high-severity authorization bypass during a pentest. This was because UI tests checked what React rendered, not what Express allowed. As the SaaS platform grew from two roles to five, the number of browser tests exploded to 85, each testing 17 sensitive actions for each role. The team realized that UI tests masked backend neglect and that frontend developers often forgot to enforce backend role restrictions in API code.\n\nTo address this, the team created a single source of truth, a permission matrix in `src/auth/permissionMatrix.ts`, mapping every API route to the exact list of roles allowed to call it. This matrix was consumed by two things: an Express/Fastify route guard middleware that refused to start in CI if a route was missing from the matrix, and a single data-driven Vitest/Playwright API test that looped over every row in the matrix and fired real HTTP requests with pre-minted JWTs for five roles (owner, admin, billing, member, viewer). The test asserted 403 for every disallowed role and non-403 for allowed roles.\n\nThe fail-closed middleware (`src/auth/enforcePolicy.ts`) ensures that no engineer can ship an unprotected endpoint by accident. If a route is not found in the permission matrix, the middleware returns a 403 error with a JSON response detailing which roles are allowed. This puts the role list right in the GitHub PR diff for security and QA reviewers to see.\n\nWith the permission matrix in place, the team replaced their 85 Playwright tests with a single 65-line API test (`tests/security/rbac-matrix.test.ts`). This test proved to be much faster, running in just 1.9 seconds. Additionally, the team added horizontal tenant isolation to the loop, proving that even an Owner cannot read or delete another customer's invoice or card.",
  "summary": "Learn how an engineering team replaced slow Playwright RBAC tests with a declarative API permission matrix to improve authorization testing.",
  "summary_source": "publisher",
  "key_points": [
    "Replaced 85 brittle RBAC UI tests with a single 60-line permission matrix",
    "Permission matrix maps every API route to exact list of allowed roles",
    "New test runs in 1.9 seconds, catching high-severity authorization bypass"
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "outlets_capped": false,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}