Skip to content

Commit

Permalink
giving status code as expected for failure test
Browse files Browse the repository at this point in the history
  • Loading branch information
amolpati30 committed Feb 27, 2024
1 parent 5f0c3a0 commit 8e61ad5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tests/foreman/api/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,34 +329,36 @@ def test_positive_host_registration_with_non_admin_user_with_setup_false(


@pytest.mark.rhel_ver_match('[^6]')
def test_negative_generate_curl_command_and_fail_registration_intentionally(
def test_negative_verify_bash_exit_status_failing_host_registration(
module_sca_manifest_org,
module_location,
module_target_sat,
rhel_contenthost,
):
"""Verify status code, when curl command registration fail intentionally
:id: 4789e8da-6391-4ea4-aa0d-73c93220ce44
:steps:
1. Generate a curl command and make the registration fail intentionally.
2. Check the exit code for the command.
:expectedresults: Exit code returns 1 if registration fails and returns 0 otherwise.
:expectedresults: Exit code returns 1 if registration fails.
:BZ: 2155444
:customerscenario: true
:parametrized: yes
"""
ac_key = module_target_sat.api.ActivationKey(unlimited_hosts=True).create()
ac_key_name = gen_string('alpha')
ac_key = module_target_sat.api.ActivationKey(name=ac_key_name).create()
# create RegistrationCommand with invalid activation_keys
command = module_target_sat.api.RegistrationCommand(
organization=module_sca_manifest_org,
activation_keys=[ac_key.name],
activation_keys=[ac_key.name], # activation_keys generated only with name parameter
location=module_location,
).create()
result = rhel_contenthost.execute(command)
if 'The system has been registered' in result.stdout:
assert result.status == 0
else:
assert result.status == 1
assert result.status == 1
assert "Couldn't find activation key" in result.stderr

0 comments on commit 8e61ad5

Please sign in to comment.