Skip to content

Commit

Permalink
Fix and update capsule certificate validation (SatelliteQE#14748)
Browse files Browse the repository at this point in the history
  • Loading branch information
Griffin-Sullivan authored and jyejare committed Oct 19, 2024
1 parent 74b01b0 commit 3a940a8
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions tests/foreman/destructive/test_katello_certs_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import pytest

from robottelo.utils.issue_handlers import is_open

pytestmark = pytest.mark.destructive


Expand Down Expand Up @@ -214,42 +212,31 @@ def test_positive_validate_capsule_certificate(capsule_certs_teardown):
:CaseAutomation: Automated
"""
file_setup, target_sat = capsule_certs_teardown
DNS_Check = False

# extract the cert from the tar file
result = target_sat.execute(
f'tar -xf {file_setup["tmp_dir"]}/capsule_certs.tar '
f'--directory {file_setup["tmp_dir"]}/ '
)
assert result.status == 0, 'Extraction to working directory failed.'
# Extract raw data from RPM to a file
target_sat.execute(
'rpm2cpio {0}/ssl-build/{1}/'
'{1}-qpid-router-server*.rpm'
'>> {0}/ssl-build/{1}/cert-raw-data'.format(
file_setup['tmp_dir'], file_setup['capsule_hostname']
)
)

# Extract the cert data from file cert-raw-data and write to cert-data
target_sat.execute(
'openssl x509 -noout -text -in {0}/ssl-build/{1}/cert-raw-data'
'openssl x509 -noout -text -in {0}/ssl-build/{1}/{1}-apache.crt'
'>> {0}/ssl-build/{1}/cert-data'.format(
file_setup['tmp_dir'], file_setup['capsule_hostname']
)
)

# use same location on remote and local for cert_file
target_sat.get(file_setup['caps_cert_file'])

# search the file for the line with DNS
with open(file_setup['caps_cert_file']) as file:
for line in file:
if re.search(r'\bDNS:', line):
match = re.search(r'{}'.format(file_setup['capsule_hostname']), line)
assert match, 'No proxy name found.'
if is_open('BZ:1747581'):
DNS_Check = True
else:
match = re.search(r'\[]', line)
assert not match, 'Incorrect parsing of alternative proxy name.'
DNS_Check = True
match = re.search(r'\[]', line)
assert not match, 'Incorrect parsing of alternative proxy name.'
break
# if no match for "DNS:" found, then raise error.
assert DNS_Check, 'Cannot find Subject Alternative Name'

0 comments on commit 3a940a8

Please sign in to comment.