Skip to content

Commit

Permalink
Remove skipped tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg committed Jan 15, 2025
1 parent 15ae0c4 commit 4b2713b
Showing 1 changed file with 1 addition and 178 deletions.
179 changes: 1 addition & 178 deletions pulp_ansible/tests/functional/api/collection/v3/test_sync.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
"""Tests related to sync ansible plugin collection content type."""

import os
import unittest

from pulpcore.client.pulp_ansible import (
AnsibleRepositorySyncURL,
ContentCollectionVersionsApi,
DistributionsAnsibleApi,
PulpAnsibleApiV3CollectionsApi,
RepositoriesAnsibleApi,
RemotesCollectionApi,
)
from pulp_smash.pulp3.bindings import PulpTaskError, PulpTestCase
from pulp_smash.pulp3.bindings import PulpTaskError

from pulp_ansible.tests.functional.utils import (
gen_ansible_client,
gen_ansible_remote,
monitor_task,
tasks,
Expand Down Expand Up @@ -205,171 +196,3 @@ def test_sync_with_missing_collection(self):
task_result = cm.exception.task.to_dict()
msg = "absent.not_present does not exist"
self.assertIn(msg, task_result["error"]["description"], task_result["error"]["description"])


@unittest.skipUnless(
"AUTOMATION_HUB_TOKEN_AUTH" in os.environ,
"'AUTOMATION_HUB_TOKEN_AUTH' env var is not defined",
)
class AutomationHubV3SyncCase(PulpTestCase, SyncHelpersMixin):
"""Test syncing from Pulp to Pulp."""

@classmethod
def setUpClass(cls):
"""Create class-wide variables."""
cls.client = gen_ansible_client()
cls.repo_api = RepositoriesAnsibleApi(cls.client)
cls.remote_collection_api = RemotesCollectionApi(cls.client)
cls.distributions_api = DistributionsAnsibleApi(cls.client)
cls.collections_api = PulpAnsibleApiV3CollectionsApi(cls.client)
cls.cv_api = ContentCollectionVersionsApi(cls.client)
cls.url = "https://cloud.redhat.com/api/automation-hub/"
cls.aurl = (
"https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token"
)

def test_sync_with_token_from_automation_hub(self):
"""Test whether we can sync with an auth token from Automation Hub."""
body = gen_ansible_remote(
url=self.url,
requirements_file="collections:\n - ansible.posix",
auth_url=self.aurl,
token=os.environ["AUTOMATION_HUB_TOKEN_AUTH"],
rate_limit=10,
tls_validation=False,
sync_dependencies=False,
)
remote = self.remote_collection_api.create(body)
self.addCleanup(self.remote_collection_api.delete, remote.pulp_href)

repo = self._create_repo_and_sync_with_remote(remote)

# Check content of both repos.
original_content = self.cv_api.list(repository_version=f"{repo.pulp_href}versions/1/")
self.assertTrue(len(original_content.results) >= 3) # check that we have at least 3 results

@unittest.skip("Skipping until synclist no longer creates new repository")
def test_syncing_with_excludes_list_from_automation_hub(self):
"""Test if syncing collections know to be on the synclist will be mirrored."""
namespace = "autohubtest2"
# Collections are randomly generated, in case of failure, please change the names below:
name = "collection_dep_a_zzduuntr"
excluded = "collection_dep_a_tworzgsx"
excluded_version = "awcrosby.collection_test==2.1.0"
requirements = f"""
collections:
- {namespace}.{name}
- {namespace}.{excluded}
- {excluded_version}
"""
body = gen_ansible_remote(
url=self.url,
requirements_file=requirements,
auth_url=self.aurl,
token=os.environ["AUTOMATION_HUB_TOKEN_AUTH"],
rate_limit=10,
tls_validation=False,
sync_dependencies=False,
)
remote = self.remote_collection_api.create(body)
self.addCleanup(self.remote_collection_api.delete, remote.pulp_href)

repo = self._create_repo_and_sync_with_remote(remote)

# Assert that at least one CollectionVersion was downloaded
repo_ver = f"{repo.pulp_href}versions/1/"
content = self.cv_api.list(repository_version=repo_ver)
self.assertTrue(content.count >= 1)

# Assert that excluded collection was not synced
exclude_content = self.cv_api.list(repository_version=repo_ver, name=excluded)
self.assertTrue(exclude_content.count == 0)


# TODO QA-AH has been deprecated, remove/replace tests
@unittest.skipUnless(
"QA_AUTOMATION_HUB_TOKEN_AUTH" in os.environ,
"'QA_AUTOMATION_HUB_TOKEN_AUTH' env var is not defined",
)
class AutomationHubCIV3SyncCase(PulpTestCase, SyncHelpersMixin):
"""Test syncing from Pulp to Pulp."""

@classmethod
def setUpClass(cls):
"""Create class-wide variables."""
cls.client = gen_ansible_client()
cls.repo_api = RepositoriesAnsibleApi(cls.client)
cls.remote_collection_api = RemotesCollectionApi(cls.client)
cls.distributions_api = DistributionsAnsibleApi(cls.client)
cls.collections_api = PulpAnsibleApiV3CollectionsApi(cls.client)
cls.cv_api = ContentCollectionVersionsApi(cls.client)
cls.url = "https://qa.cloud.redhat.com/api/automation-hub/"
cls.aurl = (
"https://sso.qa.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token"
)

def test_mirror_from_automation_hub_ci_with_auth_token(self):
"""Test whether we can mirror from Automation Hub CI with an auth token."""
body = gen_ansible_remote(
url=self.url,
auth_url=self.aurl,
token=os.environ["QA_AUTOMATION_HUB_TOKEN_AUTH"],
rate_limit=10,
tls_validation=False,
sync_dependencies=False,
)
remote = self.remote_collection_api.create(body)
self.addCleanup(self.remote_collection_api.delete, remote.pulp_href)

repo = self._create_repo_and_sync_with_remote(remote)

# Assert at least one hundred CollectionVersions are returned
content = self.cv_api.list(repository_version=f"{repo.pulp_href}versions/1/")
self.assertTrue(len(content.results) >= 100)

def test_sync_from_automation_hub_ci_with_auth_token_and_requirements_file(self):
"""Test sync from Automation Hub CI with an auth token and requirements file."""
namespace = "autohubtest2"
# Collections are randomly generated, in case of failure, please change the name below:
name = "collection_dep_a_zzduuntr"
body = gen_ansible_remote(
url=self.url,
requirements_file=f"collections:\n - {namespace}.{name}",
auth_url=self.aurl,
token=os.environ["QA_AUTOMATION_HUB_TOKEN_AUTH"],
rate_limit=10,
tls_validation=False,
sync_dependencies=False,
)
remote = self.remote_collection_api.create(body)
self.addCleanup(self.remote_collection_api.delete, remote.pulp_href)

repo = self._create_repo_and_sync_with_remote(remote)

# Assert that at least one CollectionVersion was downloaded
content = self.cv_api.list(repository_version=f"{repo.pulp_href}versions/1/")
self.assertTrue(len(content.results) >= 1)

def test_install_collection_with_invalid_token_from_automation_hub_ci(self):
"""Test whether we can mirror from Automation Hub CI with an invalid auth token."""
body = gen_ansible_remote(
url=self.url,
auth_url=self.aurl,
token="invalid token string",
tls_validation=False,
sync_dependencies=False,
)
remote = self.remote_collection_api.create(body)
self.addCleanup(self.remote_collection_api.delete, remote.pulp_href)

with self.assertRaises(PulpTaskError) as cm:
self._create_repo_and_sync_with_remote(remote)

task_result = cm.exception.task.to_dict()
msg = (
"400, message='Bad Request', url=URL("
"'https://sso.qa.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token')"
)
self.assertEqual(
msg, task_result["error"]["description"], task_result["error"]["description"]
)

0 comments on commit 4b2713b

Please sign in to comment.