def test_undo_share_resource_with_user(self):
     george = self.george
     bikes = self.bikes
     alva = self.alva
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.NONE)
     george.uaccess.share_resource_with_user(bikes, alva,
                                             PrivilegeCodes.CHANGE)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.CHANGE)
     george.uaccess.undo_share_resource_with_user(bikes, alva)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.NONE)
     george.uaccess.share_resource_with_user(bikes, alva,
                                             PrivilegeCodes.VIEW)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.VIEW)
     george.uaccess.undo_share_resource_with_user(bikes, alva)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.NONE)
 def test_userresourceresult_update(self):
     george = self.george
     bikes = self.bikes
     alva = self.alva
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.NONE)
     UserResourcePrivilege.update(resource=bikes,
                                  user=alva,
                                  privilege=PrivilegeCodes.CHANGE,
                                  grantor=george)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.CHANGE)
Esempio n. 3
0
def check_provenance_synchronization(self):
    for u in User.objects.all():
        for r in BaseResource.objects.all():
            prov = UserResourceProvenance.get_privilege(resource=r, user=u)
            priv = UserResourcePrivilege.get_privilege(resource=r, user=u)
            self.assertEqual(
                prov, priv,
                str.format("prov={}, priv={}, resource={}, user={}", prov,
                           priv, r, u))
    for u in User.objects.all():
        for g in Group.objects.all():
            prov = UserGroupProvenance.get_privilege(group=g, user=u)
            priv = UserGroupPrivilege.get_privilege(group=g, user=u)
            self.assertEqual(
                prov, priv,
                str.format("prov={}, priv={}, group={}, user={}", prov, priv,
                           g, u))
    for g in Group.objects.all():
        for r in BaseResource.objects.all():
            prov = GroupResourceProvenance.get_privilege(resource=r, group=g)
            priv = GroupResourcePrivilege.get_privilege(resource=r, group=g)
            self.assertEqual(
                prov, priv,
                str.format("prov={}, priv={}, group={}, resource={}", prov,
                           priv, g, r))
 def test_userresourceresult_update(self):
     george = self.george
     bikes = self.bikes
     alva = self.alva
     self.assertEqual(
         UserResourcePrivilege.get_privilege(
             resource=bikes,
             user=alva),
         PrivilegeCodes.NONE)
     UserResourcePrivilege.update(
         resource=bikes,
         user=alva,
         privilege=PrivilegeCodes.CHANGE,
         grantor=george)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(
             resource=bikes,
             user=alva),
         PrivilegeCodes.CHANGE)
 def test_can_undo_share_resource_with_user(self):
     george = self.george
     bikes = self.bikes
     alva = self.alva
     self.assertFalse(george.uaccess.can_undo_share_resource_with_user(bikes, alva))
     self.assertFalse(george.uaccess.can_undo_share_resource_with_user(bikes, george))
     self.assertFalse(alva.uaccess.can_undo_share_resource_with_user(bikes, george))
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.NONE)
     george.uaccess.share_resource_with_user(bikes, alva, PrivilegeCodes.CHANGE)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.CHANGE)
     self.assertTrue(george.uaccess.can_undo_share_resource_with_user(bikes, alva))
     self.assertFalse(george.uaccess.can_undo_share_resource_with_user(bikes, george))
     self.assertFalse(alva.uaccess.can_undo_share_resource_with_user(bikes, george))
     george.uaccess.undo_share_resource_with_user(bikes, alva)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.NONE)
     self.assertFalse(george.uaccess.can_undo_share_resource_with_user(bikes, alva))
     self.assertFalse(george.uaccess.can_undo_share_resource_with_user(bikes, george))
     self.assertFalse(alva.uaccess.can_undo_share_resource_with_user(bikes, george))
     george.uaccess.share_resource_with_user(bikes, alva, PrivilegeCodes.VIEW)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.VIEW)
     self.assertTrue(george.uaccess.can_undo_share_resource_with_user(bikes, alva))
     self.assertFalse(george.uaccess.can_undo_share_resource_with_user(bikes, george))
     self.assertFalse(alva.uaccess.can_undo_share_resource_with_user(bikes, george))
     george.uaccess.undo_share_resource_with_user(bikes, alva)
     self.assertEqual(
         UserResourcePrivilege.get_privilege(resource=bikes, user=alva),
         PrivilegeCodes.NONE)
     self.assertFalse(george.uaccess.can_undo_share_resource_with_user(bikes, alva))
     self.assertFalse(george.uaccess.can_undo_share_resource_with_user(bikes, george))
     self.assertFalse(alva.uaccess.can_undo_share_resource_with_user(bikes, george))
Esempio n. 6
0
def check_provenance_synchronization(self):
    for u in User.objects.all():
        for r in BaseResource.objects.all():
            prov = UserResourceProvenance.get_privilege(resource=r, user=u)
            priv = UserResourcePrivilege.get_privilege(resource=r, user=u)
            self.assertEqual(prov, priv,
                             str.format("prov={}, priv={}, resource={}, user={}",
                                        prov, priv, r, u))
    for u in User.objects.all():
        for g in Group.objects.all():
            prov = UserGroupProvenance.get_privilege(group=g, user=u)
            priv = UserGroupPrivilege.get_privilege(group=g, user=u)
            self.assertEqual(prov, priv,
                             str.format("prov={}, priv={}, group={}, user={}",
                                        prov, priv, g, u))
    for g in Group.objects.all():
        for r in BaseResource.objects.all():
            prov = GroupResourceProvenance.get_privilege(resource=r, group=g)
            priv = GroupResourcePrivilege.get_privilege(resource=r, group=g)
            self.assertEqual(prov, priv,
                             str.format("prov={}, priv={}, group={}, resource={}",
                                        prov, priv, g, r))