The test failed, but the code was fine.
The problem wasn’t the logic. It was the permissions. Somewhere between the controller and the database, the wrong user role had slipped through. That’s the kind of bug integration testing for RBAC exists to catch—and if you ignore it, your security and trust start to bleed out where nobody can see.
Integration testing RBAC (role-based access control) is about proving that the rules you’ve defined for who can do what still hold true once the whole system works together. It’s not enough to unit test individual role checks in isolation. Authorization lives at the seams between services, in API gateways, in messaging layers, in workflows that span multiple domains. Integration tests walk through the real interactions, using real roles, to confirm the fences are still there.
A solid approach starts with a clear RBAC matrix: roles, permissions, resources. Map every expected action. Then write integration tests that mimic actual user flows with those roles. If an "editor"should never delete a record, the test goes beyond hitting the endpoint: it authenticates as an editor, tries the delete through the same path a UI or client app would, and checks that it fails with the correct status code and message.