I am writing a DRF API for an educational website where users can access data based on the permission groups and object level permissions they have. When I started writing the tests, I wondered whether it is necessary to test requests with all possible permission combinations. For example, say one endpoint of the API needs three permissions to give access to its data, then you could write a lot of test methods to test all possible combinations of permissions the user could have. Only one combination, the one where the user has all three permissions, will result in data and the rest will most likely result in a 403 Forbidden Response.
As an example, the three permissions could be something like IsAuthenticated, IsOwner and IsTeacher. The user needs to have all three permissions, so the 403 Forbidden Response combinations would be:
IsOwner IsAuthenticated IsTeacher
False False False,
False False True,
False True True,
True False False,
True True False,
True False True,
False True False,
The valid response which gives the user access to the data would be:
IsOwner IsAuthenticated IsTeacher
True True True
Is it necessary to test all of them? Should I test it in another way?