diff --git a/tests/foreman/api/test_http_proxy.py b/tests/foreman/api/test_http_proxy.py index 8f82c4a36be..a6f0e1172a2 100644 --- a/tests/foreman/api/test_http_proxy.py +++ b/tests/foreman/api/test_http_proxy.py @@ -266,26 +266,37 @@ def test_positive_assign_http_proxy_to_products(): @pytest.mark.tier2 -def test_positive_sync_proxy_with_certificate(target_sat): +def test_positive_sync_proxy_with_certificate(request, target_sat): """Assign http_proxy with ca.crt to Repo and test whether http_proxy and cert are used during sync. Steps: - Generate cert files with custom_cert_generate, collect cacert path. - - Create new org, product, and http-proxy with cacert. + - Create new org, product, and http-proxy with path to cacert. - 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 cert. + sync operation uses assigned http-proxy with the cert. - """ - proxy_host = settings.http_proxy.auth_proxy_url.replace("http://", "").replace(":3128", "") + :id: a9645b7f-228e-4f4d-ab04-610382bd2d0b + + :BZ: 2144044 + + :customerscenario: true + + :Team: Phoenix-content + """ # Cleanup any existing certs that may conflict target_sat.custom_certs_cleanup() - target_sat.custom_cert_generate(proxy_host) + proxy_host = settings.http_proxy.auth_proxy_url.replace("http://", "").replace(":3128", "") + cacert_path = '/root/cacert.crt' + target_sat.custom_cert_generate(proxy_host) + # Pull cert contents from the Satellite + cacert = target_sat.execute(f'cat {cacert_path}').stdout + assert "BEGIN CERTIFICATE" and "END CERTIFICATE" in cacert # Create org, HTTP_Proxy, and repo org = target_sat.api.Organization().create() http_proxy = target_sat.api.HTTPProxy( @@ -294,7 +305,7 @@ def test_positive_sync_proxy_with_certificate(target_sat): username=settings.http_proxy.username, password=settings.http_proxy.password, organization=[org], - cacert="/root/cacert.crt", + cacert=cacert_path, ).create() product = target_sat.api.Product(organization=org).create() repo = target_sat.api.Repository( @@ -306,6 +317,13 @@ def test_positive_sync_proxy_with_certificate(target_sat): assert repo.http_proxy_policy == 'use_selected_http_proxy' assert repo.http_proxy_id == http_proxy.id + assert http_proxy.cacert == cacert_path - repo.sync() - target_sat.custom_certs_cleanup() + 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()