N
Neon11mo ago
useful-bronze

What are the tools you're using to write units tests for RLS?

What are the tools you're using to write units tests for RLS?
3 Replies
afraid-scarlet
afraid-scarlet11mo ago
The best method I've seen so far is to use branching to make your changes and then run integration type tests that check access. When you've verified the int tests run correctly on the branch you can merge them to production.
useful-bronze
useful-bronzeOP11mo ago
Got it. Seems like someone (maybe my team) needs to write a testing library, we also need to test things such as different PG roles. Maybe we can do something on top of https://github.com/theory/pgtap
afraid-scarlet
afraid-scarlet11mo ago
oh i see, yes. that will allow you to have a bit more of a unit like test against the RLS code. my tests have so been "should fail when trying to write to the row of another user" kind of tests.

Did you find this page helpful?