From 671e2d9e44f71c9a61cb9cda5b6c9e21179cc5d5 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 24 Jul 2026 14:55:47 +0200 Subject: [PATCH 1/4] refactor paramiko host fetcher --- tests/conftest.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a87f61dcf..91da557b6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -135,20 +135,24 @@ def database_mode(obsah_params): return obsah_params.get('database_mode', 'internal') +def get_paramiko_host(hostname): + return testinfra.get_host(f'paramiko://{hostname}', sudo=True, ssh_config=SSH_CONFIG) + + @pytest.fixture(scope="module") def server(server_hostname): - yield testinfra.get_host(f'paramiko://{server_hostname}', sudo=True, ssh_config=SSH_CONFIG) + yield get_paramiko_host(server_hostname) @pytest.fixture(scope="module") def client(client_hostname): - yield testinfra.get_host(f'paramiko://{client_hostname}', sudo=True, ssh_config=SSH_CONFIG) + yield get_paramiko_host(client_hostname) @pytest.fixture(scope="module") def database(database_mode, server): if database_mode == 'external': - yield testinfra.get_host('paramiko://database', sudo=True, ssh_config=SSH_CONFIG) + yield get_paramiko_host('database') else: yield server From 2c68f7633312f14ee600a1f15285e3f3acf2730f Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 24 Jul 2026 15:12:12 +0200 Subject: [PATCH 2/4] use the quadlet cert in curl_request --- tests/conftest.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 91da557b6..9d1f7bf97 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -130,6 +130,17 @@ def default_certificates(certificate_source): pytest.skip("Only applies to non-custom certificate deployments") +@pytest.fixture(scope="module") +def quadlet_client_certificate(): + # this intentionally uses get_paramiko_host directly, as we want the cert of the quadlet box + # not the one "server" points at, as that can be the proxy + quadlet = get_paramiko_host('quadlet') + hostname = quadlet.run("hostname -f").stdout.strip() + cert = quadlet.file(f"/var/lib/foremanctl/certs/certs/{hostname}-client.crt").content_string + key = quadlet.file(f"/var/lib/foremanctl/certs/private/{hostname}-client.key").content_string + return (cert, key) + + @pytest.fixture(scope="module") def database_mode(obsah_params): return obsah_params.get('database_mode', 'internal') @@ -344,13 +355,17 @@ def proxy_base_url(server_fqdn): @pytest.fixture(scope="module") -def curl_request(server, certificates, server_fqdn): +def curl_request(server, certificates, quadlet_client_certificate, server_fqdn): + cert, key = quadlet_client_certificate + server.run(f"echo '{cert}' > /tmp/quadlet.crt") + server.run(f"echo '{key}' > /tmp/quadlet.key") + def _request(path, base_url=None, method=None, data=None, headers=None, return_body=False): url = f"{base_url or f'https://{server_fqdn}'}/{path}" curl_opts = ( f"--cacert {certificates['server_ca_certificate']} " - f"--cert {certificates['client_certificate']} " - f"--key {certificates['client_key']} " + f"--cert /tmp/quadlet.crt " + f"--key /tmp/quadlet.key " f"--silent " ) if not return_body: From 21421f4b30a15b5fb83aba4dbfa2c70f3050fef4 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 24 Jul 2026 15:12:51 +0200 Subject: [PATCH 3/4] add bmc feature to the proxy --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9acfe2396..f39a18c8e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -443,7 +443,8 @@ jobs: --auth-bundle $(pwd)/.var/lib/foremanctl/proxy.example.com.tar.gz \ --foreman-fqdn quadlet.example.com \ --templates-listen-on http \ - --templates-url http://proxy.example.com:8000 + --templates-url http://proxy.example.com:8000 \ + --add-feature bmc - name: Run tests run: | ./forge test --pytest-args="--server-hostname=proxy" From aaa39bde4cb792e24142c43db8fd390c8cedc752 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Thu, 30 Jul 2026 14:39:50 +0200 Subject: [PATCH 4/4] try overriding the fixture --- tests/conftest.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9d1f7bf97..a59ec135b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -141,6 +141,11 @@ def quadlet_client_certificate(): return (cert, key) +@pytest.fixture(scope="module") +def client_certificate(): + return quadlet_client_certificate + + @pytest.fixture(scope="module") def database_mode(obsah_params): return obsah_params.get('database_mode', 'internal') @@ -355,8 +360,8 @@ def proxy_base_url(server_fqdn): @pytest.fixture(scope="module") -def curl_request(server, certificates, quadlet_client_certificate, server_fqdn): - cert, key = quadlet_client_certificate +def curl_request(server, server_fqdn, certificates, client_certificate): + cert, key = client_certificate server.run(f"echo '{cert}' > /tmp/quadlet.crt") server.run(f"echo '{key}' > /tmp/quadlet.key")