Ravindra BagaleCourses & study guides मराठी Track your progress

26. Row-Level Security (RLS)

26.4 Testing RLS

Start with a problem

Ravindra published RLS but did not test it. A manager saw another city's data.

Explain simply

Test in Desktop with View as and in the Service with Test as role, using real emails.

Show the data

User (email) City in security table Rows visible Total Sales (₹)
ravindra@example.com Pune 301, 302, 306 850
shraddha@example.com Nashik 303, 304, 307 800
zoya@example.com Kolhapur 305, 308 450
salman@example.com Pune, Nashik 6 orders 1,650
Rani (no role, workspace Viewer with all-cities role) All 301–308 2,100

About this data: This table uses columns: User (email), City in security table, Rows visible, Total Sales (₹). This table uses columns: Wrong result, Reason, Correction. Values shown are the lesson examples already on this page (not a new dataset).

Fictional sample data. Practice file: rls_user_security.csv (source: src/practice/).

Demonstrate

  1. Desktop › Modeling › View as › role + Other user ravindra@example.com.
  2. Check card ₹850.
  3. Service › model › Security › role › Test as role.
  4. Repeat for each user in the table.

Show the result

Testing RLS per user, sample layout with fictional data

Your result should look like this (fictional sample):

User (email) City in security table Rows visible Total Sales (₹)
ravindra@example.com Pune 301, 302, 306 850
shraddha@example.com Nashik 303, 304, 307 800
zoya@example.com Kolhapur 305, 308 450
salman@example.com Pune, Nashik 6 orders 1,650
Rani (no role, workspace Viewer with all-cities role) All 301–308 2,100

Explain what happened

Testing simulates the user's security filter before go-live.

Explore further

  • Keep a test checklist with expected totals.

Detailed reference for this lesson:

In Desktop: Modeling › View as › tick a role (and/or tick Other user and type an e-mail such as zoya@example.com to test dynamic RLS) › OK. A yellow bar shows "Now viewing as…". Check that cards and tables show only Kolhapur data (Rajarampuri and Tarabai Park stores). Click Stop viewing to return.

In the Service:

  1. Publish the report.
  2. In the workspace, open the semantic model's … › Security.
  3. Select each role and add members – individual users or (better) security groups.
  4. Use … › Test as role to check the result, optionally as a specific person.

Test kelyashivay RLS publish karu naka – bilkul nahi!

Ravindra Bagale's Tip

Friends, many students publish RLS without testing it with View as in Desktop and Test as role in the Service. Test every role, including a user who should see nothing and a user with several cities. Check totals, not just the list of cities. Never forget this.

Fix common mistakes

Wrong result Reason Correction
Tested as Admin, saw all Edit roles bypass RLS Test with View as
Expected ₹850 but ₹2,100 Role not selected Select role and user
Totals right, details wrong Only card tested Test tables too

Practise independently

Practice task

Expected total for shraddha@example.com?

Hints
  • Nashik.
Solution

₹800.

Think like a professional

A written RLS test table with expected numbers is strong evidence of quality.

Ravi Sir's Cards for this lesson

मराठी cards