Example #1
0
 def test_get_all_tenant_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_tenant_permissions(self.user)), 0)
 def test_get_all_tenant_permissions_without_tenant(self):
     clear_current_tenant()
     auth_backend = TenantModelBackend()
     self.assertEqual(
         len(auth_backend.get_all_tenant_permissions(self.user)),
         0
     )
Example #3
0
 def test_get_all_tenant_permissions(self):
     set_current_tenant(self.tenant.slug)
     auth_backend = TenantModelBackend()
     self.assertEqual(
         len(auth_backend.get_all_tenant_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())
 def test_get_all_tenant_permissions_without_user_in_tenant(self):
     set_current_tenant(self.tenant.slug)
     self.user.relationships.all().delete()
     auth_backend = TenantModelBackend()
     self.assertEqual(
         len(auth_backend.get_all_tenant_permissions(self.user)),
         0
     )
Example #5
0
 def test_get_all_tenant_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_tenant_permissions(self.user)),
         Permission.objects.all().count())
     self.assertEqual(len(self.user._tenant_perm_cache[self.tenant.pk]),
                      Permission.objects.all().count())