Skip to content

Commit

Permalink
Updates to comments, steps
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed May 18, 2023
1 parent 8ece887 commit eca9ba3
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/foreman/api/test_http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,63 @@ def test_positive_assign_http_proxy_to_products():
assert r.http_proxy_id == http_proxy_b.id

product_a.sync({'async': True})


@pytest.mark.tier2
def test_positive_sync_proxy_with_certificate(request, target_sat, module_org, module_product):
"""Assign http_proxy with cacert.crt to repository and test
that http_proxy and cacert are used during sync.
:Steps:
1. Generate new cert files with custom_cert_generate
2. Create new repo using module_org and module_product
3. Create new http-proxy with path to cacert
4. Create repo using selected http proxy, perform repo sync
:expectedresults: http-proxy with cacert is assigned to repo,
sync operation uses assigned http-proxy with the cacert.
:id: a9645b7f-228e-4f4d-ab04-610382bd2d0b
:BZ: 2144044
:customerscenario: true
"""
# Cleanup any existing certs that may conflict
target_sat.custom_certs_cleanup()
proxy_host = settings.http_proxy.auth_proxy_url.replace("http://", "").replace(":3128", "")
cacert_path = '/root/cacert.crt'

# Create and fetch new cerfiticate
target_sat.custom_cert_generate(proxy_host)
cacert = target_sat.execute(f'cat {cacert_path}').stdout
assert "BEGIN CERTIFICATE" and "END CERTIFICATE" in cacert

# Create HTTP_Proxy and repository
http_proxy = 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=[module_org],
cacert=cacert_path,
).create()
repo = target_sat.api.Repository(
product=module_product,
http_proxy_policy='use_selected_http_proxy',
http_proxy_id=http_proxy.id,
).create()
module_product.update()

assert repo.http_proxy_policy == 'use_selected_http_proxy'
assert repo.http_proxy_id == http_proxy.id
assert http_proxy.cacert == cacert_path

response = repo.sync()
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()

0 comments on commit eca9ba3

Please sign in to comment.