From the course: Securing Django Applications
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Unit test for access control and group permissions - Django Tutorial
From the course: Securing Django Applications
Unit test for access control and group permissions
- [Instructor] Let's write another access control test to ensure group permissions are working properly. Before we get started, Let's take a look at this sign permission, shortcut function we used. As you can see the function imports the group model and then imports the assigned permission function from django guardian. And then for every group and the permissions, we are getting the group model instance. And then assigning each permission using the django guardian shortcut. Next, we have a function that checks whether a given group has permission to access a given object. We fetch the group model instance. And then we use the get objects for group django guardian shortcut to check whether out of the set of all objects that this group has permission to whether the given object is in that set. And lastly, we have the user has group perm function. Which will check whether a user has permission to access through their group…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Setting up per-object permissions in Django59s
-
(Locked)
Enabling per-object permissions in Django3m 47s
-
(Locked)
Unit test for per-object permissions in Django2m 48s
-
(Locked)
Creating a group permissions model4m 27s
-
(Locked)
Unit test for access control and group permissions3m 38s
-
(Locked)
Adding activity logs for auditing3m 4s
-
(Locked)
Deleting objects in an audit/compliance-compatible way3m 46s
-
-
-
-
-
-