Skip to content

Commit

Permalink
Update OS tests for password hashing default from sha256 to sha512 (#…
Browse files Browse the repository at this point in the history
…15780)

Signed-off-by: Gaurav Talreja <[email protected]>
  • Loading branch information
Gauravtalreja1 authored Jul 26, 2024
1 parent bb133df commit 957efb1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
11 changes: 6 additions & 5 deletions tests/foreman/api/test_operatingsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ def test_positive_end_to_end_os(self, module_target_sat, module_org, module_arch
:expectedresults: All CRUD operations are performed successfully.
:BZ: 2101435, 1230902
:Verifies: SAT-26071
"""
name = gen_string('alpha')
desc = gen_string('alpha')
os_family = 'Redhat'
minor_version = gen_string('numeric')
major_version = gen_string('numeric', 5)
pass_hash = 'SHA256'
default_pass_hash = 'SHA512'
os_parameters = [{'name': gen_string('alpha'), 'value': gen_string('alpha')}]
ptable = module_target_sat.api.PartitionTable().create()
medium = module_target_sat.api.Media(organization=[module_org]).create()
Expand All @@ -69,7 +71,6 @@ def test_positive_end_to_end_os(self, module_target_sat, module_org, module_arch
major=major_version,
family=os_family,
architecture=[module_architecture],
password_hash=pass_hash,
provisioning_template=[template],
ptable=[ptable],
medium=[medium],
Expand All @@ -81,12 +82,12 @@ def test_positive_end_to_end_os(self, module_target_sat, module_org, module_arch
assert os.major == major_version
assert os.description == desc
assert os.architecture[0].id == module_architecture.id
assert os.password_hash == pass_hash
assert os.ptable[0].id == ptable.id
assert os.provisioning_template[0].id == template.id
assert os.medium[0].id == medium.id
assert os.os_parameters_attributes[0]['name'] == os_parameters[0]['name']
assert os.os_parameters_attributes[0]['value'] == os_parameters[0]['value']
assert os.password_hash == default_pass_hash
# Read OS
os = module_target_sat.api.OperatingSystem(id=os.id).read()
assert os.name == name
Expand All @@ -95,18 +96,18 @@ def test_positive_end_to_end_os(self, module_target_sat, module_org, module_arch
assert os.major == major_version
assert os.description == desc
assert os.architecture[0].id == module_architecture.id
assert os.password_hash == pass_hash
assert str(ptable.id) in str(os.ptable)
assert str(template.id) in str(os.provisioning_template)
assert os.medium[0].id == medium.id
assert os.os_parameters_attributes[0]['name'] == os_parameters[0]['name']
assert os.os_parameters_attributes[0]['value'] == os_parameters[0]['value']
assert os.password_hash == default_pass_hash
new_name = gen_string('alpha')
new_desc = gen_string('alpha')
new_os_family = 'Rhcos'
new_minor_version = gen_string('numeric')
new_major_version = gen_string('numeric', 5)
new_pass_hash = 'SHA512'
new_pass_hash = 'SHA256'
new_arch = module_target_sat.api.Architecture().create()
new_ptable = module_target_sat.api.PartitionTable().create()
new_medium = module_target_sat.api.Media(organization=[module_org]).create()
Expand Down
6 changes: 4 additions & 2 deletions tests/foreman/api/test_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,13 @@ def test_rhel_pxe_provisioning_fips_enabled(
:parametrized: yes
:BZ: 2240076
:Verifies: SAT-26071
"""
sat = module_provisioning_sat.sat
host_mac_addr = provisioning_host._broker_args['provisioning_nic_mac_addr']
# Verify password hashing algorithm SHA256 is set in OS used for provisioning
assert module_provisioning_rhel_content.os.password_hash == 'SHA256'
# Verify password hashing algorithm SHA512 is set in OS used for provisioning
assert module_provisioning_rhel_content.os.password_hash == 'SHA512'

host = sat.api.Host(
hostgroup=provisioning_hostgroup,
Expand Down
6 changes: 4 additions & 2 deletions tests/foreman/cli/test_operatingsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ def test_positive_end_to_end_os(self, target_sat):
7. Check if OS is deleted
:expectedresults: All CRUD operations are performed successfully.
:Verifies: SAT-26071
"""
name = gen_string('alpha')
desc = gen_string('alpha')
os_family = 'Redhat'
pass_hash = 'SHA256'
default_pass_hash = 'SHA512'
minor_version = gen_string('numeric', 1)
major_version = gen_string('numeric', 1)
architecture = target_sat.cli_factory.make_architecture()
Expand All @@ -68,7 +70,7 @@ def test_positive_end_to_end_os(self, target_sat):
'name': name,
'description': desc,
'family': os_family,
'password-hash': pass_hash,
'password-hash': default_pass_hash,
'major': major_version,
'minor': minor_version,
'architecture-ids': architecture['id'],
Expand Down

0 comments on commit 957efb1

Please sign in to comment.