Skip to content

Commit

Permalink
ContentCredentials CLI fix for stream
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed May 23, 2024
1 parent 77d0790 commit a3caf87
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions tests/foreman/cli/test_contentcredentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ def create_gpg_key_file(content=None):
return None


def wait_for_repo_metadata_tasks(sat, org_name, repo_name='', product_name=''):
"""Search and wait for any repo metadata task(s).
param sat (satellite): is required.
param org_name (str): is required, rest are optional.
Scope by use of arguments, entity names,
ie: blank repo_name would return metadata tasks for all repos,
that match the scope of given org name, and product name if any.
return: the matching completed task(s)
"""
task_query = (
f'Metadata generate repository "{repo_name}";'
f' product "{product_name}";'
f' organization "{org_name}"'
)
return sat.wait_for_tasks(
search_query=task_query,
search_rate=15,
max_tries=10,
)


search_key = 'name'


Expand Down Expand Up @@ -403,6 +427,13 @@ def test_positive_add_product_with_repo(target_sat, module_org):
target_sat.cli.Product.update(
{'gpg-key-id': gpg_key['id'], 'id': product['id'], 'organization-id': module_org.id}
)
# wait for repo metadata task(s) before final read/assertions
wait_for_repo_metadata_tasks(
sat=target_sat,
org_name=module_org.name,
repo_name=repo['name'],
product_name=product['name'],
)
product = target_sat.cli.Product.info({'id': product['id'], 'organization-id': module_org.id})
repo = target_sat.cli.Repository.info({'id': repo['id']})
assert product['gpg']['gpg-key-id'] == gpg_key['id']
Expand All @@ -429,6 +460,12 @@ def test_positive_add_product_with_repos(target_sat, module_org):
target_sat.cli.Product.update(
{'gpg-key-id': gpg_key['id'], 'id': product['id'], 'organization-id': module_org.id}
)
# wait for repo metadata task(s) before final read/assertions
wait_for_repo_metadata_tasks(
sat=target_sat,
org_name=module_org.name,
product_name=product['name'],
)
product = target_sat.cli.Product.info({'id': product['id'], 'organization-id': module_org.id})
assert product['gpg']['gpg-key-id'] == gpg_key['id']
for repo in repos:
Expand All @@ -455,6 +492,13 @@ def test_positive_add_repo_from_product_with_repo(target_sat, module_org):
target_sat.cli.Repository.update(
{'gpg-key-id': gpg_key['id'], 'id': repo['id'], 'organization-id': module_org.id}
)
# wait for repo metadata task(s) before final read/assertions
wait_for_repo_metadata_tasks(
sat=target_sat,
org_name=module_org.name,
repo_name=repo['name'],
product_name=product['name'],
)
product = target_sat.cli.Product.info({'id': product['id'], 'organization-id': module_org.id})
repo = target_sat.cli.Repository.info({'id': repo['id']})
assert repo['gpg-key']['id'] == gpg_key['id']
Expand Down Expand Up @@ -482,6 +526,13 @@ def test_positive_add_repo_from_product_with_repos(target_sat, module_org):
target_sat.cli.Repository.update(
{'gpg-key-id': gpg_key['id'], 'id': repos[0]['id'], 'organization-id': module_org.id}
)
# wait for repo metadata task(s) before final read/assertions
wait_for_repo_metadata_tasks(
sat=target_sat,
org_name=module_org.name,
repo_name=repos[0]['name'],
product_name=product['name'],
)
product = target_sat.cli.Product.info({'id': product['id'], 'organization-id': module_org.id})
assert product['gpg'].get('gpg-key-id') != gpg_key['id']
# First repo should have a valid gpg key assigned
Expand Down Expand Up @@ -566,6 +617,13 @@ def test_positive_update_key_for_product_with_repo(target_sat, module_org):
{'id': gpg_key['id'], 'organization-id': module_org.id}
)
assert gpg_key['name'] == new_name
# wait for repo metadata task(s) before final read/assertions
wait_for_repo_metadata_tasks(
sat=target_sat,
org_name=module_org.name,
repo_name=repo['name'],
product_name=product['name'],
)
# Verify changes are reflected in the product
product = target_sat.cli.Product.info({'id': product['id'], 'organization-id': module_org.id})
assert product['gpg']['gpg-key'] == new_name
Expand Down Expand Up @@ -613,6 +671,12 @@ def test_positive_update_key_for_product_with_repos(target_sat, module_org):
{'id': gpg_key['id'], 'organization-id': module_org.id}
)
assert gpg_key['name'] == new_name
# wait for repo metadata task(s) before final read/assertions
wait_for_repo_metadata_tasks(
sat=target_sat,
org_name=module_org.name,
product_name=product['name'],
)
# Verify changes are reflected in the product
product = target_sat.cli.Product.info({'id': product['id'], 'organization-id': module_org.id})
assert product['gpg']['gpg-key'] == new_name
Expand Down Expand Up @@ -652,6 +716,13 @@ def test_positive_update_key_for_repo_from_product_with_repo(target_sat, module_
{'id': gpg_key['id'], 'organization-id': module_org.id}
)
assert gpg_key['name'] == new_name
# wait for repo metadata task(s) before final read/assertions
wait_for_repo_metadata_tasks(
sat=target_sat,
org_name=module_org.name,
repo_name=repo['name'],
product_name=product['name'],
)
# Verify changes are reflected in the repositories
repo = target_sat.cli.Repository.info({'id': repo['id']})
assert repo['gpg-key'].get('name') == new_name
Expand Down Expand Up @@ -697,6 +768,13 @@ def test_positive_update_key_for_repo_from_product_with_repos(target_sat, module
{'id': gpg_key['id'], 'organization-id': module_org.id}
)
assert gpg_key['name'] == new_name
# wait for repo metadata task(s) before final read/assertions
wait_for_repo_metadata_tasks(
sat=target_sat,
org_name=module_org.name,
repo_name=repos[0]['name'],
product_name=product['name'],
)
# Verify changes are reflected in the associated repository
repos[0] = target_sat.cli.Repository.info({'id': repos[0]['id']})
assert repos[0]['gpg-key'].get('name') == new_name
Expand Down

0 comments on commit a3caf87

Please sign in to comment.