Ejemplo n.º 1
0
 def test_success(self, mock_assign, find_target_or_group):
     find_target_or_group.return_value = "target_el"
     cmd_acl.assign_role_not_specific(self.mock_env, "role_id", "target_id")
     self.assert_get_cib_called()
     find_target_or_group.assert_called_once_with(self.cib, "target_id")
     mock_assign.assert_called_once_with(self.cib, "role_id", "target_el")
     self.assert_same_cib_pushed()
Ejemplo n.º 2
0
 def test_success(self, mock_assign, find_target_or_group):
     find_target_or_group.return_value = "target_el"
     cmd_acl.assign_role_not_specific(self.mock_env, "role_id", "target_id")
     self.assert_get_cib_called()
     find_target_or_group.assert_called_once_with(self.cib, "target_id")
     mock_assign.assert_called_once_with(self.cib, "role_id", "target_el")
     self.assert_same_cib_pushed()
Ejemplo n.º 3
0
 def test_success(self, mock_error_convert, mock_find_role, mock_assign, mock_get_tg):
     mock_get_tg.return_value = "target_el"
     mock_find_role.return_value = "role_el"
     cmd_acl.assign_role_not_specific(self.mock_env, "role_id", "target_id")
     self.assert_get_cib_called()
     mock_get_tg.assert_called_once_with(self.cib, "target_id")
     mock_find_role.assert_called_once_with(self.cib, "role_id")
     mock_assign.assert_called_once_with("target_el", "role_el")
     self.assertEqual(0, mock_error_convert.call_count)
     self.assert_same_cib_pushed()
Ejemplo n.º 4
0
 def test_success(self, mock_error_convert, mock_find_role, mock_assign,
                  mock_get_tg):
     mock_get_tg.return_value = "target_el"
     mock_find_role.return_value = "role_el"
     cmd_acl.assign_role_not_specific(self.mock_env, "role_id", "target_id")
     self.assert_get_cib_called()
     mock_get_tg.assert_called_once_with(self.cib, "target_id")
     mock_find_role.assert_called_once_with(self.cib, "role_id")
     mock_assign.assert_called_once_with("target_el", "role_el")
     self.assertEqual(0, mock_error_convert.call_count)
     self.assert_same_cib_pushed()
Ejemplo n.º 5
0
 def test_failure(self, mock_error_convert, mock_find_role, mock_assign, mock_get_tg):
     mock_get_tg.return_value = "target_el"
     exception_obj = acl_lib.AclRoleNotFound("role_id")
     mock_find_role.side_effect = exception_obj
     self.assert_raises(
         LibraryError, lambda: cmd_acl.assign_role_not_specific(self.mock_env, "role_id", "target_id")
     )
     self.assert_get_cib_called()
     self.assertEqual(0, mock_assign.call_count)
     mock_error_convert.assert_called_once_with(exception_obj)
     self.assert_cib_not_pushed()
Ejemplo n.º 6
0
 def test_failure(self, mock_error_convert, mock_find_role, mock_assign,
                  mock_get_tg):
     mock_get_tg.return_value = "target_el"
     exception_obj = acl_lib.AclRoleNotFound("role_id")
     mock_find_role.side_effect = exception_obj
     self.assert_raises(
         LibraryError, lambda: cmd_acl.assign_role_not_specific(
             self.mock_env, "role_id", "target_id"))
     self.assert_get_cib_called()
     self.assertEqual(0, mock_assign.call_count)
     mock_error_convert.assert_called_once_with(exception_obj)
     self.assert_cib_not_pushed()