Beispiel #1
0
 def test_get_all_permissions(self):
     set_current_tenant(self.tenant.slug)
     auth_backend = TenantModelBackend()
     self.assertEqual(len(auth_backend.get_all_permissions(self.user)),
                      self.relationship.groups.first().permissions.count())
     self.assertEqual(len(self.user._tenant_perm_cache[self.tenant.pk]),
                      self.relationship.groups.first().permissions.count())
Beispiel #2
0
 def test_get_all_permissions_with_superuser(self):
     set_current_tenant(self.tenant.slug)
     self.user.is_superuser = True
     self.user.save()
     auth_backend = TenantModelBackend()
     self.assertEqual(len(auth_backend.get_all_permissions(self.user)),
                      Permission.objects.all().count())
     self.assertEqual(len(self.user._tenant_perm_cache[self.tenant.pk]),
                      Permission.objects.all().count())
 def test_get_all_permissions_without_active_user(self):
     set_current_tenant(self.tenant.slug)
     self.user.is_active = False
     self.user.save()
     auth_backend = TenantModelBackend()
     self.assertEqual(
         len(auth_backend.get_all_permissions(self.user)),
         0
     )