How to test roles and permissions?

1.8k views Asked by At

I'm using a roles and permissions concept. There are about 300 possible combinations right now. I want to conduct the appropriate tests to make sure that I did not make a mistake. How should I go about this?

I can't do 300 different UATs. Should I define automatic tests and get the wanted result out of my permissions master table? Any ideas are appreciated.

1

There are 1 answers

0
ujlbu4 On BEST ANSWER

I'm not quite sure (for now) it is worthwhile to test role-permissions with autotests.

Assume you have matrix with roles and their permissions (for example take ours role-permission matrix). Assigning permissions to role is straightforward, without any code logic (if-else statements). So it depends only did you set required permission to role or not. Probably it's better to evidently visualize your permission/role matrix (in code or in some ui) for convenient check your settings.

Second reason is that permissions for roles usually dynamic and setting up from admin panel by some managers (so it's no way to run unit test when they apply new permissions).

Probably it worth to test code logic for role concatenation (when user have few roles simultaneously — does all permissions applyed or maybe you have other specific logic). In such case test it as usual (create few roles in test, append them to user, check expected permissions).


In case you really want to test all your roles and permissions, then consider data-driven tests.