diff --git a/tests/foreman/api/test_convert2rhel.py b/tests/foreman/api/test_convert2rhel.py index 37bbfa30058..1416c3c88e8 100644 --- a/tests/foreman/api/test_convert2rhel.py +++ b/tests/foreman/api/test_convert2rhel.py @@ -311,6 +311,7 @@ def test_convert2rhel_oracle(module_target_sat, oracle, activation_key_rhel, ver assert host_content['subscription_status'] == 0 + @pytest.mark.e2e @pytest.mark.parametrize('version', ['centos7', 'centos8'], indirect=True) def test_convert2rhel_centos(module_target_sat, centos, activation_key_rhel, version): diff --git a/tests/foreman/cli/test_registration.py b/tests/foreman/cli/test_registration.py index 89d560ab862..4cdbfdc51ba 100644 --- a/tests/foreman/cli/test_registration.py +++ b/tests/foreman/cli/test_registration.py @@ -12,6 +12,9 @@ """ import pytest +import re + +from fauxfactory import gen_string from robottelo.config import settings from robottelo.constants import CLIENT_PORT @@ -167,6 +170,46 @@ def test_negative_register_twice(module_ak_with_cv, module_org, rhel_contenthost assert 'This system is already registered' in str(result.stderr) +@pytest.mark.rhel_ver_match('[^6]') +@pytest.mark.tier3 +def test_positive_force_register_twice(module_ak_with_cv, module_org, rhel_contenthost, target_sat): + """Register a host twice to Satellite, with force=true + + :id: 7ccd4efd-54bb-4207-9acf-4c6243a32fab + + :expectedresults: Host will be re-registered + + :parametrized: yes + + :BZ: 1361309 + + :customerscenario: true + """ + reg_id_pattern = r"The system has been registered with ID: ([^\n]*)" + name = gen_string('alpha') + ".example.com" + rhel_contenthost.execute(f'hostnamectl set-hostname {name}') + result = rhel_contenthost.register(module_org, None, module_ak_with_cv.name, target_sat) + reg_id_old = re.search(reg_id_pattern, result.stdout).group(1) + assert result.status == 0 + assert rhel_contenthost.subscribed + result = rhel_contenthost.register( + module_org, None, module_ak_with_cv.name, target_sat, force=True + ) + assert result.status == 0 + assert rhel_contenthost.subscribed + assert f'Unregistering from: {target_sat.hostname}' in str(result.stdout) + assert f'The registered system name is: {rhel_contenthost.hostname}' in str(result.stdout) + reg_id_new = re.search(reg_id_pattern, result.stdout).group(1) + assert f'The system has been registered with ID: {reg_id_new}' in str(result.stdout) + assert reg_id_new != reg_id_old + assert ( + target_sat.cli.Host.info({'name': rhel_contenthost.hostname}, output_format='json')[ + 'subscription-information' + ]['uuid'] + == reg_id_new + ) + + @pytest.mark.tier1 def test_negative_global_registration_without_ak(module_target_sat): """Attempt to register a host without ActivationKey