Skip to content

Commit

Permalink
Minor updates of other HTTP proxy e2es
Browse files Browse the repository at this point in the history
  • Loading branch information
vsedmik committed Mar 1, 2024
1 parent 9f824ea commit bd04de5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 50 deletions.
50 changes: 26 additions & 24 deletions tests/foreman/api/test_http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ def test_positive_end_to_end(
5. Discover yum type repo through HTTP proxy.
6. Discover docker type repo through HTTP proxy.
:expected results:
:expectedresults:
1. All repository updates and syncs succeed.
2. Yum and docker repos can be discovered through HTTP proxy.
:Team: Phoenix-content
:BZ: 2011303, 2042473, 2046337
:parametrized: yes
Expand Down Expand Up @@ -223,38 +221,42 @@ def test_positive_install_content_with_http_proxy(

@pytest.mark.e2e
@pytest.mark.tier2
def test_positive_assign_http_proxy_to_products(target_sat):
def test_positive_assign_http_proxy_to_products(target_sat, function_org):
"""Assign http_proxy to Products and check whether http-proxy is
used during sync.
:id: c9d23aa1-3325-4abd-a1a6-d5e75c12b08a
:expectedresults: HTTP Proxy is assigned to all repos present
in Products and sync operation uses assigned http-proxy.
:setup:
1. Create an Organization.
:Team: Phoenix-content
:steps:
1. Create two HTTP proxies.
2. Create two products and two repos in each product with various HTTP proxy policies.
3. Set the HTTP proxy through bulk action for both products.
4. Bulk sync one product.
:CaseImportance: Critical
:expectedresults:
1. HTTP Proxy is assigned to all repos present in Products
and sync operation uses assigned http-proxy and pass.
"""
org = target_sat.api.Organization().create()
# create HTTP proxies
# Create two HTTP proxies
http_proxy_a = target_sat.api.HTTPProxy(
name=gen_string('alpha', 15),
url=settings.http_proxy.un_auth_proxy_url,
organization=[org],
organization=[function_org],
).create()

http_proxy_b = target_sat.api.HTTPProxy(
name=gen_string('alpha', 15),
url=settings.http_proxy.auth_proxy_url,
username=settings.http_proxy.username,
password=settings.http_proxy.password,
organization=[org],
organization=[function_org],
).create()

# Create products and repositories
product_a = target_sat.api.Product(organization=org).create()
product_b = target_sat.api.Product(organization=org).create()
# Create two products and two repos in each product with various HTTP proxy policies
product_a = target_sat.api.Product(organization=function_org).create()
product_b = target_sat.api.Product(organization=function_org).create()
repo_a1 = target_sat.api.Repository(product=product_a, http_proxy_policy='none').create()
repo_a2 = target_sat.api.Repository(
product=product_a,
Expand All @@ -265,21 +267,20 @@ def test_positive_assign_http_proxy_to_products(target_sat):
repo_b2 = target_sat.api.Repository(
product=product_b, http_proxy_policy='global_default_http_proxy'
).create()
# Add http_proxy to products

# Set the HTTP proxy through bulk action for both products
target_sat.api.ProductBulkAction().http_proxy(
data={
"ids": [product_a.id, product_b.id],
"http_proxy_policy": "use_selected_http_proxy",
"http_proxy_id": http_proxy_b.id,
}
)

for repo in repo_a1, repo_a2, repo_b1, repo_b2:
r = repo.read()
assert r.http_proxy_policy == "use_selected_http_proxy"
assert r.http_proxy_id == http_proxy_b.id

product_a.sync({'async': True})
assert 'success' in product_a.sync()['result'], 'Product sync failed'


@pytest.mark.tier2
Expand Down Expand Up @@ -309,6 +310,11 @@ def test_positive_sync_proxy_with_certificate(request, target_sat, module_org, m

# Create and fetch new cerfiticate
target_sat.custom_cert_generate(proxy_host)

@request.addfinalizer
def _finalize():
target_sat.custom_certs_cleanup()

cacert = target_sat.execute(f'cat {cacert_path}').stdout
assert 'END CERTIFICATE' in cacert

Expand All @@ -335,7 +341,3 @@ def test_positive_sync_proxy_with_certificate(request, target_sat, module_org, m
assert response.get('errors') is None
assert repo.read().last_sync is not None
assert repo.read().content_counts['rpm'] >= 1

@request.addfinalizer
def _finalize():
target_sat.custom_certs_cleanup()
45 changes: 28 additions & 17 deletions tests/foreman/cli/test_http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ def test_insights_client_registration_with_http_proxy():
works with http proxy set.
:CaseAutomation: NotAutomated
:CaseImportance: High
"""


Expand All @@ -132,8 +130,6 @@ def test_positive_set_content_default_http_proxy(block_fake_repo_access, target_
4. Sync a repo.
:expectedresults: Repo is synced
:CaseImportance: High
"""
org = target_sat.api.Organization().create()
proxy_name = gen_string('alpha', 15)
Expand Down Expand Up @@ -186,8 +182,6 @@ def test_positive_environment_variable_unset_set():
:expectedresults: satellite-installer unsets system proxy and SSL environment variables
only for the duration of install and sets back those in the end.
:CaseImportance: High
:CaseAutomation: NotAutomated
"""

Expand All @@ -200,12 +194,22 @@ def test_positive_assign_http_proxy_to_products(module_org, module_target_sat):
:id: 6af7b2b8-15d5-4d9f-9f87-e76b404a966f
:expectedresults: HTTP Proxy is assigned to all repos present
in Products and sync operation performed successfully.
:steps:
1. Create two HTTP proxies.
2. Create two products and two repos in each product with various HTTP proxy policies.
3. Set the HTTP proxy through bulk action for both products to the selected proxy.
4. Bulk sync both products and verify packages counts.
5. Set the HTTP proxy through bulk action for both products to None.
:expectedresults:
1. HTTP Proxy is assigned to all repos present in Products
and sync operation uses assigned http-proxy and pass.
:CaseImportance: High
:expectedresults:
1. HTTP Proxy is assigned to all repos present in Products
and sync operation performed successfully.
"""
# create HTTP proxies
# Create two HTTP proxies
http_proxy_a = module_target_sat.cli.HttpProxy.create(
{
'name': gen_string('alpha', 15),
Expand All @@ -222,7 +226,8 @@ def test_positive_assign_http_proxy_to_products(module_org, module_target_sat):
'organization-id': module_org.id,
},
)
# Create products and repositories

# Create two products and two repos in each product with various HTTP proxy policies
product_a = module_target_sat.cli_factory.make_product({'organization-id': module_org.id})
product_b = module_target_sat.cli_factory.make_product({'organization-id': module_org.id})
repo_a1 = module_target_sat.cli_factory.make_repository(
Expand Down Expand Up @@ -257,31 +262,37 @@ def test_positive_assign_http_proxy_to_products(module_org, module_target_sat):
'url': settings.repos.yum_0.url,
},
)
# Add http_proxy to products
module_target_sat.cli.Product.update_proxy(

# Set the HTTP proxy through bulk action for both products to the selected proxy
res = module_target_sat.cli.Product.update_proxy(
{
'ids': f"{product_a['id']},{product_b['id']}",
'http-proxy-policy': 'use_selected_http_proxy',
'http-proxy-id': http_proxy_b['id'],
}
)
assert 'Product proxy updated' in res
for repo in repo_a1, repo_a2, repo_b1, repo_b2:
result = module_target_sat.cli.Repository.info({'id': repo['id']})
assert result['http-proxy']['http-proxy-policy'] == 'use_selected_http_proxy'
assert result['http-proxy']['id'] == http_proxy_b['id']
# Perform sync and verify packages count

# Bulk sync both products and verify packages counts
module_target_sat.cli.Product.synchronize(
{'id': product_a['id'], 'organization-id': module_org.id}
)
module_target_sat.cli.Product.synchronize(
{'id': product_b['id'], 'organization-id': module_org.id}
)
for repo in repo_a1, repo_a2, repo_b1, repo_b2:
info = module_target_sat.cli.Repository.info({'id': repo['id']})
assert int(info['content-counts']['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT

module_target_sat.cli.Product.update_proxy(
# Set the HTTP proxy through bulk action for both products to None
res = module_target_sat.cli.Product.update_proxy(
{'ids': f"{product_a['id']},{product_b['id']}", 'http-proxy-policy': 'none'}
)

assert 'Product proxy updated' in res
for repo in repo_a1, repo_a2, repo_b1, repo_b2:
result = module_target_sat.cli.Repository.info({'id': repo['id']})
assert result['http-proxy']['http-proxy-policy'] == 'none'
assert int(result['content-counts']['packages']) == FAKE_0_YUM_REPO_PACKAGES_COUNT
22 changes: 13 additions & 9 deletions tests/foreman/ui/test_http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ def test_positive_assign_http_proxy_to_products_repositories(
:id: 2b803f9c-8d5d-4467-8eba-18244ebc0201
:expectedresults: HTTP Proxy is assigned to all repos present
in Products.
:setup:
1. Create an Organization and Location.
:CaseImportance: Critical
:steps:
1. Create two HTTP proxies.
2. Create two products and two repos in each product with various HTTP proxy policies.
3. Set the HTTP proxy through bulk action for both products.
:expectedresults:
1. HTTP Proxy is assigned to all repos present in Products.
"""
# create HTTP proxies
# Create two HTTP proxies
http_proxy_a = target_sat.api.HTTPProxy(
name=gen_string('alpha', 15),
url=settings.http_proxy.un_auth_proxy_url,
Expand All @@ -93,14 +99,14 @@ def test_positive_assign_http_proxy_to_products_repositories(
organization=[module_org.id],
location=[module_location.id],
).create()
# Create products
# Create two products
product_a = target_sat.api.Product(
organization=module_org.id,
).create()
product_b = target_sat.api.Product(
organization=module_org.id,
).create()
# Create repositories from UI.
# Create two repositories in each product from UI
with target_sat.ui_session() as session:
repo_a1_name = gen_string('alpha')
session.organization.select(org_name=module_org.name)
Expand Down Expand Up @@ -152,7 +158,7 @@ def test_positive_assign_http_proxy_to_products_repositories(
'repo_content.http_proxy_policy': 'No HTTP Proxy',
},
)
# Add http_proxy to products
# Set the HTTP proxy through bulk action for both products
session.product.search('')
session.product.manage_http_proxy(
[product_a.name, product_b.name],
Expand Down Expand Up @@ -338,8 +344,6 @@ def test_positive_repo_discovery(setup_http_proxy, module_target_sat, module_org
:expectedresults: Repository is discovered and created.
:team: Phoenix-content
:BZ: 2011303, 2042473
:parametrized: yes
Expand Down

0 comments on commit bd04de5

Please sign in to comment.