diff --git a/requirements.txt b/requirements.txt index 599d6fa5f3f..961c13ce532 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ # Version updates managed by dependabot +apypie==0.4.0 betelgeuse==1.11.0 # broker[docker]==0.4.1 - Temporarily disabled, see below cryptography==42.0.5 diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 7596411fa56..9546b4177d5 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -14,6 +14,7 @@ from urllib.parse import urljoin, urlparse, urlunsplit import warnings +import apypie from box import Box from broker import Broker from broker.hosts import Host @@ -1762,6 +1763,7 @@ def __init__(self, hostname=None, **kwargs): # create dummy classes for later population self._api = type('api', (), {'_configured': False}) self._cli = type('cli', (), {'_configured': False}) + self._apidoc = None self.record_property = None def _swap_nailgun(self, new_version): @@ -1815,6 +1817,19 @@ class DecClass(cls): self._api._configured = True return self._api + @property + def apidoc(self): + """Provide Satellite's apidoc via apypie""" + if not self._apidoc: + self._apidoc = apypie.Api( + uri=self.url, + username=settings.server.admin_username, + password=settings.server.admin_password, + api_version=2, + verify_ssl=False, + ).apidoc + return self._apidoc + @property def cli(self): """Import all robottelo cli entities and wrap them under self.cli""" diff --git a/tests/foreman/api/test_capsulecontent.py b/tests/foreman/api/test_capsulecontent.py index 6df34b16188..3af44119f81 100644 --- a/tests/foreman/api/test_capsulecontent.py +++ b/tests/foreman/api/test_capsulecontent.py @@ -16,13 +16,12 @@ from datetime import datetime, timedelta import re from time import sleep -from urllib.parse import urlparse from nailgun import client from nailgun.entity_mixins import call_entity_method_with_timeout import pytest -from robottelo.config import get_credentials, settings +from robottelo.config import settings from robottelo.constants import ( CONTAINER_CLIENTS, CONTAINER_REGISTRY_HUB, @@ -1671,19 +1670,11 @@ def test_positive_reclaim_space( assert 'success' in task['result'], 'Reclaim task did not succeed' # Check the apidoc references the correct endpoint - response = client.get( - f'{target_sat.url}/apidoc/v2/capsule_content/reclaim_space.en.html', - auth=get_credentials(), - verify=False, + reclaim_doc = next( + method + for method in target_sat.apidoc['docs']['resources']['capsule_content']['methods'] + if '/apidoc/v2/capsule_content/reclaim_space' in method['doc_url'] ) - assert ( - response.status_code == 200 - ), f'{response.request.path} returned HTTP{response.status_code}' - - ep_path = target_sat.api.Capsule(id=module_capsule_configured.nailgun_capsule.id).path( - which='content_reclaim_space' - ) - ep_path = urlparse(ep_path).path - ep_path = ep_path.replace(str(module_capsule_configured.nailgun_capsule.id), ':id') - - assert f'POST {ep_path}' in response.text, 'Reclaim_space endpoint path missing in apidoc' + assert len(reclaim_doc['apis']) == 1 + assert reclaim_doc['apis'][0]['http_method'] == 'POST' + assert reclaim_doc['apis'][0]['api_url'] == '/katello/api/capsules/:id/reclaim_space'