Beispiel #1
0
 def test_ssd_enforcement(self):
     """
     Test if SSD is enforced when assigning roles to a user.
     """
     with transaction.atomic():
         self.assertRaises(ValidationError, functions.AssignUser, self.user, self.role_ssdfour)
     self.assertEqual(functions.DeassignUser(self.user, self.role_a), True)
     self.assertEqual(functions.AssignUser(self.user, self.role_ssdfour), True)
     with transaction.atomic():
         self.assertRaises(ValidationError, functions.AssignUser, self.user, self.role_a)
Beispiel #2
0
    def setUp(self):
        RbacRoleProfile.create()
        RbacPermissionProfile.create()

        #after loading fixtures we need to populate the role and permission
        # profiles first
        self.role_a = RbacRole.objects.get(name="Role A")
        self.role_b = RbacRole.objects.get(name="Role B")
        self.role_c = RbacRole.objects.get(name="Role C")
        self.role_d = RbacRole.objects.get(name="Role D")
        self.role_ssdone = RbacRole.objects.get(name="Role SSD 1")
        self.role_ssdtwo = RbacRole.objects.get(name="Role SSD 2")
        self.role_ssdthree = RbacRole.objects.get(name="Role SSD 3")
        self.role_ssdfour = RbacRole.objects.get(name="Role SSD 4")

        # We're using the RBAC user model and do not need any fixtures.
        self.user = get_user_model().objects.create(id=1, username="******")

        functions.AssignUser(self.user, self.role_a)
        functions.AssignUser(self.user, self.role_c)