Skip to content

Commit e3f2739

Browse files
committed
WIP: Copy test_verify_engine_certs to test_001
I want to use it as a simple means to make sure the engine is up. Making it loop, in a previous patch, was enough then, but now that I need the engine to be up also for test_add_dwh_to_keycloak_redirect_uris_for_grafana, that's not enough. For now, just copy it. Later, perhaps reorganize, perhaps move test_add_dwh_to_keycloak_redirect_uris_for_grafana elsewhere, etc. Change-Id: Id141160a36d360517586a0180dcc145890521687 Signed-off-by: Yedidyah Bar David <[email protected]>
1 parent 31adca8 commit e3f2739

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

separate-machine-basic-suite-master/test-scenarios/test_001_initialize_engine_and_dwh.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@
55
#
66
from __future__ import absolute_import
77

8+
import logging
9+
import pytest
10+
import tempfile
11+
12+
from ost_utils import assert_utils
13+
from ost_utils import shell
814
from ost_utils.ansible.collection import engine_setup
915

1016

17+
LOGGER = logging.getLogger(__name__)
18+
19+
1120
def test_initialize_engine(
1221
ansible_engine,
1322
ansible_inventory,
@@ -62,6 +71,43 @@ def test_initialize_dwh(
6271
)
6372

6473

74+
@pytest.mark.parametrize(
75+
"key_format, verification_fn",
76+
[
77+
pytest.param(
78+
'X509-PEM-CA',
79+
lambda path: shell.shell(["openssl", "x509", "-in", path, "-text", "-noout"]),
80+
id="CA certificate",
81+
),
82+
pytest.param(
83+
'OPENSSH-PUBKEY',
84+
lambda path: shell.shell(["ssh-keygen", "-l", "-f", path]),
85+
id="ssh pubkey",
86+
),
87+
],
88+
)
89+
def test_verify_engine_certs(key_format, verification_fn, engine_fqdn, engine_download):
90+
url_template = 'http://{}/ovirt-engine/services/pki-resource?resource=ca-certificate&format={}'
91+
url = url_template.format(engine_fqdn, key_format)
92+
93+
def _verify_engine_certs_once():
94+
with tempfile.NamedTemporaryFile() as tmp:
95+
try:
96+
engine_download(url, tmp.name)
97+
except shell.ShellError as ex:
98+
LOGGER.debug("Certificate download failed for %s", url, exc_info=True)
99+
return False
100+
try:
101+
verification_fn(tmp.name)
102+
except shell.ShellError:
103+
LOGGER.debug("Certificate verification failed. Certificate contents:\n")
104+
LOGGER.debug(tmp.read())
105+
return False
106+
return True
107+
108+
assert assert_utils.true_within_short(_verify_engine_certs_once)
109+
110+
65111
def test_add_dwh_to_keycloak_redirect_uris_for_grafana(
66112
ansible_engine,
67113
engine_fqdn,

0 commit comments

Comments
 (0)