Repository: cobbler/cobbler

Issue:
Depreacte XML-RPC Handle
### Is your feature request related to a problem?

Currently we have a second UID for the XML-RPC API. Those are redundant as we have an object UID.

### Provide a detailed description of the proposed feature

The XML-RPC API should not utilize their self built handles anymore but just utilize the uid of the object.

### Alternatives you've considered

None

### Additional information

None



Discussion:

Resolving patch:
diff --git a/cobbler/remote.py b/cobbler/remote.py
--- a/cobbler/remote.py
+++ b/cobbler/remote.py
@@ -27,15 +27,7 @@
 from cobbler import configgen
 from cobbler.items import (
     item,
-    package,
     system,
-    image,
-    profile,
-    repo,
-    mgmtclass,
-    distro,
-    file,
-    menu,
 )
 from cobbler import tftpgen
 from cobbler import utils
@@ -43,7 +35,6 @@
 from cobbler.cexceptions import CX
 from cobbler.validate import (
     validate_autoinstall_script_name,
-    validate_obj_id,
     validate_obj_name,
     validate_uuid,
 )
@@ -144,7 +135,7 @@ def __init__(self, api):
         self.api = api
         self.logger = logging.getLogger()
         self.token_cache: Dict[str, tuple] = {}
-        self.object_cache = {}
+        self.unsaved_items = {}
         self.timestamp = self.api.last_modified_time()
         self.events = {}
         self.shared_secret = utils.get_shared_secret()
@@ -379,15 +370,20 @@ def background_power_system(self, options: dict, token: str) -> str:
         """
 
         def runner(self):
-            for x in self.options.get("systems", []):
+            for system_name in self.options.get("systems", []):
                 try:
-                    system_id = self.remote.get_system_handle(x, token)
-                    system = self.remote.__get_object(system_id)
-                    self.remote.api.power_system(system, self.options.get("power", ""))
+                    system_obj = self.remote.api.find_system(name=system_name)
+                    if system_obj is None:
+                        raise ValueError(
+                            'System with name "%s" not found' % system_name
+                        )
+                    self.remote.api.power_system(
+                        system_obj, self.options.get("power", "")
+                    )
                 except Exception as e:
                     self.logger.warning(
                         "failed to execute power task on %s, exception: %s"
-                        % (str(x), str(e))
+                        % (str(system_name), str(e))
                     )
 
         self.check_access(token, "power_system")
@@ -410,9 +406,11 @@ def power_system(self, system_id: str, power: str, token: str) -> bool:
         :param system_id: system handle
         :param power: power operation (on/off/status/reboot)
         """
-        system = self.__get_object(system_id)
-        self.check_access(token, "power_system", system)
-        result = self.api.power_system(system, power)
+        system_obj = self.api.find_system(criteria={"uid": system_id})
+        if system_obj is None:
+            raise ValueError('System with uid "%s" not found' % system_id)
+        self.check_access(token, "power_system", system_obj)
+        result = self.api.power_system(system_obj, power)
         return True if result is None else result
 
     def background_signature_update(self, options: dict, token: str) -> str:
@@ -666,7 +664,7 @@ def _log(
             msg = "%s; name(%s)" % (msg, name)
 
         if object_id is not None:
-            if not validate_obj_id(object_id):
+            if not validate_uuid(object_id):
                 return
             msg = "%s; object_id(%s)" % (msg, object_id)
 
@@ -781,10 +779,9 @@ def __get_object(self, object_id: str):
         :param object_id: The id for the object to retrieve.
         :return: The item to the corresponding id.
         """
-        if object_id.startswith("___NEW___"):
-            return self.object_cache[object_id][1]
-        (otype, oname) = object_id.split("::", 1)
-        return self.api.get_item(otype, oname)
+        if object_id in self.unsaved_items:
+            return self.unsaved_items[object_id][1]
+        return self.api.find_items("", criteria={"uid": object_id}, return_list=False)
 
     def get_item_resolved_value(self, item_uuid: str, attribute: str):
         """
@@ -1362,112 +1359,102 @@ def has_item(self, what: str, name: str, token: Optional[str] = None):
         else:
             return True
 
-    def get_item_handle(self, what: str, name: str, token=None):
+    def get_item_handle(self, what: str, name: str):
         """
         Given the name of an object (or other search parameters), return a reference (object id) that can be used with
         ``modify_*`` functions or ``save_*`` functions to manipulate that object.
 
         :param what: The collection where the item is living in.
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
         found = self.api.get_item(what, name)
         if found is None:
             raise CX("internal error, unknown %s name %s" % (what, name))
-        return "%s::%s" % (what, found.name)
+        return found.uid
 
-    def get_distro_handle(self, name: str, token: str):
+    def get_distro_handle(self, name: str):
         """
         Get a handle for a distribution which allows you to use the functions ``modify_*`` or ``save_*`` to manipulate
         it.
 
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
-        return self.get_item_handle("distro", name, token)
+        return self.get_item_handle("distro", name)
 
-    def get_profile_handle(self, name: str, token: str):
+    def get_profile_handle(self, name: str):
         """
         Get a handle for a profile which allows you to use the functions ``modify_*`` or ``save_*`` to manipulate it.
 
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
-        return self.get_item_handle("profile", name, token)
+        return self.get_item_handle("profile", name)
 
-    def get_system_handle(self, name: str, token: str):
+    def get_system_handle(self, name: str):
         """
         Get a handle for a system which allows you to use the functions ``modify_*`` or ``save_*`` to manipulate it.
 
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
-        return self.get_item_handle("system", name, token)
+        return self.get_item_handle("system", name)
 
-    def get_repo_handle(self, name: str, token: str):
+    def get_repo_handle(self, name: str):
         """
         Get a handle for a repository which allows you to use the functions ``modify_*`` or ``save_*`` to manipulate it.
 
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
-        return self.get_item_handle("repo", name, token)
+        return self.get_item_handle("repo", name)
 
-    def get_image_handle(self, name: str, token: str):
+    def get_image_handle(self, name: str):
         """
         Get a handle for an image which allows you to use the functions ``modify_*`` or ``save_*`` to manipulate it.
 
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
-        return self.get_item_handle("image", name, token)
+        return self.get_item_handle("image", name)
 
-    def get_mgmtclass_handle(self, name: str, token: str):
+    def get_mgmtclass_handle(self, name: str):
         """
         Get a handle for a management class which allows you to use the functions ``modify_*`` or ``save_*`` to
         manipulate it.
 
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
-        return self.get_item_handle("mgmtclass", name, token)
+        return self.get_item_handle("mgmtclass", name)
 
-    def get_package_handle(self, name: str, token: str):
+    def get_package_handle(self, name: str):
         """
         Get a handle for a package which allows you to use the functions ``modify_*`` or ``save_*`` to manipulate it.
 
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
-        return self.get_item_handle("package", name, token)
+        return self.get_item_handle("package", name)
 
-    def get_file_handle(self, name: str, token: str):
+    def get_file_handle(self, name: str):
         """
         Get a handle for a file which allows you to use the functions ``modify_*`` or ``save_*`` to manipulate it.
 
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
-        return self.get_item_handle("file", name, token)
+        return self.get_item_handle("file", name)
 
-    def get_menu_handle(self, name: str, token: str):
+    def get_menu_handle(self, name: str):
         """
         Get a handle for a menu which allows you to use the functions ``modify_*`` or ``save_*`` to manipulate it.
 
         :param name: The name of the item.
-        :param token: The API-token obtained via the login() method.
         :return: The handle of the desired object.
         """
-        return self.get_item_handle("menu", name, token)
+        return self.get_item_handle("menu", name)
 
     def remove_item(self, what: str, name: str, token: str, recursive: bool = True):
         """
@@ -1601,7 +1588,9 @@ def copy_item(self, what: str, object_id: str, newname: str, token: str):
         """
         self._log("copy_item(%s)" % what, object_id=object_id, token=token)
         self.check_access(token, "copy_%s" % what)
-        obj = self.__get_object(object_id)
+        obj = self.api.find_items(what, criteria={"uid": object_id}, return_list=False)
+        if obj is None:
+            raise ValueError('Item with id "%s" not found.' % object_id)
         self.api.copy_item(what, obj, newname)
         return True
 
@@ -1704,7 +1693,9 @@ def copy_menu(self, object_id, newname, token=None):
         """
         return self.copy_item("menu", object_id, newname, token)
 
-    def rename_item(self, what, object_id, newname, token=None):
+    def rename_item(
+        self, what: str, object_id: str, newname: str, token: Optional[str] = None
+    ):
         """
         Renames an object specified by object_id to a new name.
 
@@ -1715,11 +1706,14 @@ def rename_item(self, what, object_id, newname, token=None):
         :return: True if the action succeeded.
         """
         self._log("rename_item(%s)" % what, object_id=object_id, token=token)
-        obj = self.__get_object(object_id)
+        self.check_access(token, "modify_%s" % what)
+        obj = self.api.find_items(what, criteria={"uid": object_id}, return_list=False)
+        if obj is None:
+            raise ValueError('Item with id "%s" not found!' % object_id)
         self.api.rename_item(what, obj, newname)
         return True
 
-    def rename_distro(self, object_id, newname, token=None):
+    def rename_distro(self, object_id: str, newname: str, token: Optional[str] = None):
         """
         Renames a distribution specified by object_id to a new name.
 
@@ -1730,7 +1724,7 @@ def rename_distro(self, object_id, newname, token=None):
         """
         return self.rename_item("distro", object_id, newname, token)
 
-    def rename_profile(self, object_id, newname, token=None):
+    def rename_profile(self, object_id: str, newname: str, token: Optional[str] = None):
         """
         Renames a profile specified by object_id to a new name.
 
@@ -1741,7 +1735,7 @@ def rename_profile(self, object_id, newname, token=None):
         """
         return self.rename_item("profile", object_id, newname, token)
 
-    def rename_system(self, object_id, newname, token=None):
+    def rename_system(self, object_id: str, newname: str, token: Optional[str] = None):
         """
         Renames a system specified by object_id to a new name.
 
@@ -1752,7 +1746,7 @@ def rename_system(self, object_id, newname, token=None):
         """
         return self.rename_item("system", object_id, newname, token)
 
-    def rename_repo(self, object_id, newname, token=None):
+    def rename_repo(self, object_id: str, newname: str, token: Optional[str] = None):
         """
         Renames a repository specified by object_id to a new name.
 
@@ -1763,7 +1757,7 @@ def rename_repo(self, object_id, newname, token=None):
         """
         return self.rename_item("repo", object_id, newname, token)
 
-    def rename_image(self, object_id, newname, token=None):
+    def rename_image(self, object_id: str, newname: str, token: Optional[str] = None):
         """
         Renames an image specified by object_id to a new name.
 
@@ -1774,7 +1768,9 @@ def rename_image(self, object_id, newname, token=None):
         """
         return self.rename_item("image", object_id, newname, token)
 
-    def rename_mgmtclass(self, object_id, newname, token=None):
+    def rename_mgmtclass(
+        self, object_id: str, newname: str, token: Optional[str] = None
+    ):
         """
         Renames a managementclass specified by object_id to a new name.
 
@@ -1785,7 +1781,7 @@ def rename_mgmtclass(self, object_id, newname, token=None):
         """
         return self.rename_item("mgmtclass", object_id, newname, token)
 
-    def rename_package(self, object_id, newname, token=None):
+    def rename_package(self, object_id: str, newname: str, token: Optional[str] = None):
         """
         Renames a package specified by object_id to a new name.
 
@@ -1796,7 +1792,7 @@ def rename_package(self, object_id, newname, token=None):
         """
         return self.rename_item("package", object_id, newname, token)
 
-    def rename_file(self, object_id, newname, token=None):
+    def rename_file(self, object_id: str, newname: str, token: Optional[str] = None):
         """
         Renames a file specified by object_id to a new name.
 
@@ -1807,7 +1803,7 @@ def rename_file(self, object_id, newname, token=None):
         """
         return self.rename_item("file", object_id, newname, token)
 
-    def rename_menu(self, object_id, newname, token=None):
+    def rename_menu(self, object_id: str, newname: str, token: Optional[str] = None):
         """
         Renames a menu specified by object_id to a new name.
 
@@ -1818,7 +1814,7 @@ def rename_menu(self, object_id, newname, token=None):
         """
         return self.rename_item("menu", object_id, newname, token)
 
-    def new_item(self, what, token, is_subobject: bool = False):
+    def new_item(self, what: str, token: str, is_subobject: bool = False):
         """Creates a new (unconfigured) object, returning an object handle that can be used.
 
         Creates a new (unconfigured) object, returning an object handle that can be used with ``modify_*`` methods and
@@ -1833,28 +1829,27 @@ def new_item(self, what, token, is_subobject: bool = False):
         self._log("new_item(%s)" % what, token=token)
         self.check_access(token, "new_%s" % what)
         if what == "distro":
-            d = distro.Distro(self.api, is_subobject=is_subobject)
+            new_item = self.api.new_distro(is_subobject=is_subobject)
         elif what == "profile":
-            d = profile.Profile(self.api, is_subobject=is_subobject)
+            new_item = self.api.new_profile(is_subobject=is_subobject)
         elif what == "system":
-            d = system.System(self.api, is_subobject=is_subobject)
+            new_item = self.api.new_system(is_subobject=is_subobject)
         elif what == "repo":
-            d = repo.Repo(self.api, is_subobject=is_subobject)
+            new_item = self.api.new_repo(is_subobject=is_subobject)
         elif what == "image":
-            d = image.Image(self.api, is_subobject=is_subobject)
+            new_item = self.api.new_image(is_subobject=is_subobject)
         elif what == "mgmtclass":
-            d = mgmtclass.Mgmtclass(self.api, is_subobject=is_subobject)
+            new_item = self.api.new_mgmtclass(is_subobject=is_subobject)
         elif what == "package":
-            d = package.Package(self.api, is_subobject=is_subobject)
+            new_item = self.api.new_package(is_subobject=is_subobject)
         elif what == "file":
-            d = file.File(self.api, is_subobject=is_subobject)
+            new_item = self.api.new_file(is_subobject=is_subobject)
         elif what == "menu":
-            d = menu.Menu(self.api, is_subobject=is_subobject)
+            new_item = self.api.new_menu(is_subobject=is_subobject)
         else:
             raise CX('internal error, collection name is "%s"' % what)
-        key = "___NEW___%s::%s" % (what, self.__get_random(25))
-        self.object_cache[key] = (time.time(), d)
-        return key
+        self.unsaved_items[new_item.uid] = (time.time(), new_item)
+        return new_item.uid
 
     def new_distro(self, token: str):
         """
@@ -2238,13 +2233,13 @@ def xapi_object_edit(
                 if "distro" in attributes:
                     raise ValueError("You can't change both 'parent' and 'distro'")
                 self.copy_item(object_type, handle, attributes["newname"], token)
-                handle = self.get_item_handle("profile", attributes["newname"], token)
+                handle = self.get_item_handle("profile", attributes["newname"])
                 self.modify_item(
                     "profile", handle, "parent", attributes["parent"], token
                 )
             else:
                 self.copy_item(object_type, handle, attributes["newname"], token)
-                handle = self.get_item_handle(object_type, attributes["newname"], token)
+                handle = self.get_item_handle(object_type, attributes["newname"])
 
         if edit_type in ["copy"]:
             del attributes["name"]
@@ -2374,7 +2369,7 @@ def __interface_edits(self, handle, attributes, object_name):
                 attributes.get("interface", ""), attributes.get("rename_interface", "")
             )
 
-    def save_item(self, what, object_id, token, editmode: str = "bypass"):
+    def save_item(self, what: str, object_id: str, token, editmode: str = "bypass"):
         """
         Saves a newly created or modified object to disk. Calling save is required for any changes to persist.
 
@@ -2392,6 +2387,8 @@ def save_item(self, what, object_id, token, editmode: str = "bypass"):
             self.api.add_item(what, obj, check_for_duplicate_names=True)
         else:
             self.api.add_item(what, obj)
+        if object_id in self.unsaved_items:
+            del self.unsaved_items[object_id]
         return True
 
     def save_distro(self, object_id, token, editmode: str = "bypass"):
@@ -3630,10 +3627,10 @@ def __invalidate_expired_tokens(self):
                 self._log("expiring token", token=token, debug=True)
                 del self.token_cache[token]
         # and also expired objects
-        for oid in list(self.object_cache.keys()):
-            (tokentime, entry) = self.object_cache[oid]
+        for oid in list(self.unsaved_items.keys()):
+            (tokentime, entry) = self.unsaved_items[oid]
             if timenow > tokentime + CACHE_TIMEOUT:
-                del self.object_cache[oid]
+                del self.unsaved_items[oid]
         for tid in list(self.events.keys()):
             (eventtime, name, status, who) = self.events[tid]
             if timenow > eventtime + EVENT_TIMEOUT:
@@ -3956,7 +3953,7 @@ def clear_system_logs(self, object_id: str, token: str):
         :param token: The API-token obtained via the login() method.
         :return: True if the operation succeeds.
         """
-        obj = self.__get_object(object_id)
+        obj = self.api.find_items(criteria={"uid": object_id}, return_list=False)
         self.check_access(token, "clear_system_logs", obj)
         self.api.clear_logs(obj)
         return True
diff --git a/cobbler/validate.py b/cobbler/validate.py
--- a/cobbler/validate.py
+++ b/cobbler/validate.py
@@ -624,18 +624,3 @@ def validate_obj_name(object_name: str) -> bool:
     if not isinstance(object_name, str):
         return False
     return bool(re.fullmatch(item.RE_OBJECT_NAME, object_name))
-
-
-def validate_obj_id(object_id: str) -> bool:
-    """
-    This validates a possible object ID against its Cobbler specific object id schema.
-
-    :param object_id: The possible object id candidate.
-    :return: True in case it is one, False otherwise.
-    """
-    if not isinstance(object_id, str):
-        return False
-    if object_id.startswith("___NEW___"):
-        object_id = object_id[9:]
-    (otype, oname) = object_id.split("::", 1)
-    return validate_obj_type(otype) and validate_obj_name(oname)


Test patch:
diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml
--- a/.github/workflows/testing.yml
+++ b/.github/workflows/testing.yml
@@ -22,6 +22,6 @@ jobs:
       - name: Run the Tests inside the Docker Container
         shell: 'script -q -e -c "bash {0}"'
         run: |
-          docker exec -u 0 -it cobbler bash -c "pytest --cov=./cobbler && codecov --token=1064928c-6477-41be-9ac2-7ce5e6d1fd8b --commit=${GITHUB_SHA}"
+          docker exec -u 0 -it cobbler bash -c "pytest --cov=./cobbler && git config --global --add safe.directory /code && codecov --token=1064928c-6477-41be-9ac2-7ce5e6d1fd8b --commit=${GITHUB_SHA}"
       - name: Stop and remove the container
         run: docker stop cobbler && docker rm cobbler
diff --git a/tests/xmlrpcapi/distro_test.py b/tests/xmlrpcapi/distro_test.py
--- a/tests/xmlrpcapi/distro_test.py
+++ b/tests/xmlrpcapi/distro_test.py
@@ -157,7 +157,7 @@ def test_copy_distro(self, remote, token):
         # Arrange --> Done in the fixture
 
         # Act
-        distro = remote.get_item_handle("distro", "testdistro0", token)
+        distro = remote.get_item_handle("distro", "testdistro0")
         result = remote.copy_distro(distro, "testdistrocopy", token)
 
         # Assert
@@ -172,7 +172,7 @@ def test_rename_distro(self, remote, token):
         Test: rename a distro object
         """
         # Arrange
-        distro = remote.get_item_handle("distro", "testdistro0", token)
+        distro = remote.get_item_handle("distro", "testdistro0")
 
         # Act
         result = remote.rename_distro(distro, "testdistro1", token)
diff --git a/tests/xmlrpcapi/file_test.py b/tests/xmlrpcapi/file_test.py
--- a/tests/xmlrpcapi/file_test.py
+++ b/tests/xmlrpcapi/file_test.py
@@ -131,7 +131,7 @@ def test_copy_file(self, remote, token, create_file, remove_file):
         )
 
         # Act
-        file = remote.get_item_handle("file", filename_base, token)
+        file = remote.get_item_handle("file", filename_base)
         result = remote.copy_file(file, filename_copy, token)
 
         # Cleanup
@@ -158,7 +158,7 @@ def test_rename_file(self, remote, token, create_file, remove_file):
             "/root/testfile0",
             "testtemplate0",
         )
-        file = remote.get_item_handle("file", filename, token)
+        file = remote.get_item_handle("file", filename)
 
         # Act
         result = remote.rename_file(file, filename_renamed, token)
diff --git a/tests/xmlrpcapi/image_test.py b/tests/xmlrpcapi/image_test.py
--- a/tests/xmlrpcapi/image_test.py
+++ b/tests/xmlrpcapi/image_test.py
@@ -81,7 +81,7 @@ def test_copy_image(self, remote, token):
         # Arrange
 
         # Act
-        image = remote.get_item_handle("image", "testimage0", token)
+        image = remote.get_item_handle("image", "testimage0")
 
         # Assert
         assert remote.copy_image(image, "testimagecopy", token)
@@ -92,7 +92,7 @@ def test_rename_image(self, remote, token, remove_item):
         """
         # Arrange
         name = "testimage1"
-        image = remote.get_item_handle("image", "testimagecopy", token)
+        image = remote.get_item_handle("image", "testimagecopy")
 
         # Act
         result = remote.rename_image(image, name, token)
diff --git a/tests/xmlrpcapi/menu_test.py b/tests/xmlrpcapi/menu_test.py
--- a/tests/xmlrpcapi/menu_test.py
+++ b/tests/xmlrpcapi/menu_test.py
@@ -111,7 +111,7 @@ def test_copy_menu(self, remote, token):
         # Arrange --> Done in fixture
 
         # Act
-        menu = remote.get_item_handle("menu", "testmenu0", token)
+        menu = remote.get_item_handle("menu", "testmenu0")
 
         # Assert
         assert remote.copy_menu(menu, "testmenucopy", token)
@@ -128,7 +128,7 @@ def test_rename_menu(self, remote, token):
         # Arrange
 
         # Act
-        menu = remote.get_item_handle("menu", "testmenu0", token)
+        menu = remote.get_item_handle("menu", "testmenu0")
         result = remote.rename_menu(menu, "testmenu1", token)
 
         # Assert
diff --git a/tests/xmlrpcapi/miscellaneous_test.py b/tests/xmlrpcapi/miscellaneous_test.py
--- a/tests/xmlrpcapi/miscellaneous_test.py
+++ b/tests/xmlrpcapi/miscellaneous_test.py
@@ -1042,7 +1042,7 @@ def test_render_vars(self, remote, token):
         kernel_options = "tree=http://@@http_server@@/cblr/links/@@distro_name@@"
 
         # Act
-        distro = remote.get_item_handle("distro", "testdistro0", token)
+        distro = remote.get_item_handle("distro", "testdistro0")
         remote.modify_distro(distro, "kernel_options", kernel_options, token)
         remote.save_distro(distro, token)
 
diff --git a/tests/xmlrpcapi/package_test.py b/tests/xmlrpcapi/package_test.py
--- a/tests/xmlrpcapi/package_test.py
+++ b/tests/xmlrpcapi/package_test.py
@@ -84,7 +84,7 @@ def test_copy_package(self, remote, token):
         # Arrange --> Done in fixture
 
         # Act
-        package = remote.get_item_handle("package", "testpackage0", token)
+        package = remote.get_item_handle("package", "testpackage0")
         result = remote.copy_package(package, "testpackagecopy", token)
 
         # Assert
@@ -99,9 +99,9 @@ def test_rename_package(self, remote, token):
         Test: rename a package object
         """
 
-        package = remote.get_item_handle("package", "testpackage0", token)
+        package = remote.get_item_handle("package", "testpackage0")
         assert remote.rename_package(package, "testpackage1", token)
-        package = remote.get_item_handle("package", "testpackage1", token)
+        package = remote.get_item_handle("package", "testpackage1")
         assert remote.rename_package(package, "testpackage0", token)
 
     @pytest.mark.usefixtures("create_package")
diff --git a/tests/xmlrpcapi/profile_test.py b/tests/xmlrpcapi/profile_test.py
--- a/tests/xmlrpcapi/profile_test.py
+++ b/tests/xmlrpcapi/profile_test.py
@@ -249,7 +249,7 @@ def test_copy_profile(self, remote, token):
         # Arrange --> Done in fixtures
 
         # Act
-        profile = remote.get_item_handle("profile", "testprofile0", token)
+        profile = remote.get_item_handle("profile", "testprofile0")
         result = remote.copy_profile(profile, "testprofilecopy", token)
 
         # Assert
@@ -272,7 +272,7 @@ def test_rename_profile(self, remote, token):
         """
 
         # Arrange
-        profile = remote.get_item_handle("profile", "testprofile0", token)
+        profile = remote.get_item_handle("profile", "testprofile0")
 
         # Act
         result = remote.rename_profile(profile, "testprofile1", token)
diff --git a/tests/xmlrpcapi/repo_test.py b/tests/xmlrpcapi/repo_test.py
--- a/tests/xmlrpcapi/repo_test.py
+++ b/tests/xmlrpcapi/repo_test.py
@@ -97,7 +97,7 @@ def test_copy_repo(self, remote, token):
         # Arrange --> Done in fixture
 
         # Act
-        repo = remote.get_item_handle("repo", "testrepo0", token)
+        repo = remote.get_item_handle("repo", "testrepo0")
 
         # Assert
         assert remote.copy_repo(repo, "testrepocopy", token)
@@ -114,7 +114,7 @@ def test_rename_repo(self, remote, token):
         # Arrange
 
         # Act
-        repo = remote.get_item_handle("repo", "testrepo0", token)
+        repo = remote.get_item_handle("repo", "testrepo0")
         result = remote.rename_repo(repo, "testrepo1", token)
 
         # Assert
diff --git a/tests/xmlrpcapi/system_test.py b/tests/xmlrpcapi/system_test.py
--- a/tests/xmlrpcapi/system_test.py
+++ b/tests/xmlrpcapi/system_test.py
@@ -296,7 +296,7 @@ def test_copy_system(self, remote, token):
         Test: copy a system object
         """
         # Arrange
-        system = remote.get_item_handle("system", "testsystem0", token)
+        system = remote.get_item_handle("system", "testsystem0")
 
         # Act
         result = remote.copy_system(system, "testsystemcopy", token)
@@ -323,7 +323,7 @@ def test_rename_system(self, remote, token):
         """
 
         # Arrange --> Done in fixtures also.
-        system = remote.get_item_handle("system", "testsystem0", token)
+        system = remote.get_item_handle("system", "testsystem0")
 
         # Act
         result = remote.rename_system(system, "testsystem1", token)