def test_RBAC_rv_not_allowed(self, mock_auth):
        decorator = rbac_rv.action("", "")

        mock_function = mock.Mock()
        wrapper = decorator(mock_function)

        mock_permission = mock.Mock()
        mock_permission.get_permission.return_value = False
        mock_auth.return_value = mock_permission

        self.assertRaises(StandardError, wrapper)
    def test_RBAC_rv_rbac_action_failed_not_allowed(self, mock_auth):
        decorator = rbac_rv.action("", "")

        mock_function = mock.Mock()
        mock_function.side_effect = rbac_exceptions.RbacActionFailed
        wrapper = decorator(mock_function)

        mock_permission = mock.Mock()
        mock_permission.get_permission.return_value = False
        mock_auth.return_value = mock_permission

        self.assertIsNone(wrapper())
    def test_RBAC_rv_forbidden_not_allowed(self, mock_auth):
        decorator = rbac_rv.action("", "")

        mock_function = mock.Mock()
        mock_function.side_effect = exceptions.Forbidden
        wrapper = decorator(mock_function)

        mock_permission = mock.Mock()
        mock_permission.get_permission.return_value = False
        mock_auth.return_value = mock_permission

        self.assertIsNone(wrapper())
 def test_RBAC_rv_rbac_action_failed(self, mock_auth):
     decorator = rbac_rv.action("", "")
     mock_function = mock.Mock()
     mock_function.side_effect = rbac_exceptions.RbacActionFailed
     wrapper = decorator(mock_function)
     self.assertRaises(exceptions.Forbidden, wrapper)
 def test_RBAC_rv_forbidden(self, mock_auth):
     decorator = rbac_rv.action("", "")
     mock_function = mock.Mock()
     mock_function.side_effect = exceptions.Forbidden
     wrapper = decorator(mock_function)
     self.assertRaises(exceptions.Forbidden, wrapper)
 def test_RBAC_rv_happy_path(self, mock_auth):
     decorator = rbac_rv.action("", "")
     mock_function = mock.Mock()
     wrapper = decorator(mock_function)
     wrapper()