diff --git a/requirements.txt b/requirements.txt index 96a9dafd866..e52116f42b3 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.9 cryptography==42.0.5 diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 7596411fa56..7a250069c95 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=settings.server.verify_ca, + ).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 fe471df8eed..818a808a4c2 100644 --- a/tests/foreman/api/test_capsulecontent.py +++ b/tests/foreman/api/test_capsulecontent.py @@ -1715,3 +1715,55 @@ def test_positive_read_with_non_admin_user( server_config=sc, id=module_capsule_configured.nailgun_capsule.id ).read() assert res.name == module_capsule_configured.hostname, 'External Capsule not found.' + + def test_positive_reclaim_space( + self, + target_sat, + module_capsule_configured, + ): + """Verify the reclaim_space endpoint spawns the Reclaim space task + and apidoc references the endpoint correctly. + + :id: eb16ed53-0489-4bb9-a0da-8d857a1c7d06 + + :setup: + 1. A registered external Capsule. + + :steps: + 1. Trigger the reclaim space task via API, check it succeeds. + 2. Check the apidoc references the correct endpoint. + + :expectedresults: + 1. Reclaim_space endpoint spawns the Reclaim space task and it succeeds. + 2. Apidoc references the correct endpoint. + + :CaseImportance: Medium + + :BZ: 2218179 + + :customerscenario: true + """ + # Trigger the reclaim space task via API, check it succeeds + task = module_capsule_configured.nailgun_capsule.content_reclaim_space() + assert task, 'No task was created for reclaim space.' + assert ( + 'Actions::Pulp3::CapsuleContent::ReclaimSpace' in task['label'] + ), 'Unexpected task triggered' + assert 'success' in task['result'], 'Reclaim task did not succeed' + + # Check the apidoc references the correct endpoint + try: + 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'] + ) + except StopIteration: + raise AssertionError( + 'Could not find the reclaim_space apidoc at the expected path.' + ) from None + assert len(reclaim_doc['apis']) == 1 + assert reclaim_doc['apis'][0]['http_method'] == 'POST', 'POST method was expected.' + assert ( + reclaim_doc['apis'][0]['api_url'] == '/katello/api/capsules/:id/content/reclaim_space' + ), 'Documented path did not meet the expectation.'