diff --git a/tests/foreman/api/test_registration.py b/tests/foreman/api/test_registration.py index f421d70137b..011d00b6a96 100644 --- a/tests/foreman/api/test_registration.py +++ b/tests/foreman/api/test_registration.py @@ -18,6 +18,7 @@ """ import uuid +from fauxfactory import gen_ipaddr, gen_mac import pytest from robottelo.constants import CLIENT_PORT, ENVIRONMENT @@ -120,3 +121,50 @@ def test_positive_allow_reregistration_when_dmi_uuid_changed( target_sat.execute(f'echo \'{{"dmi.system.uuid": "{uuid_2}"}}\' > /etc/rhsm/facts/uuid.facts') result = rhel_contenthost.register_contenthost(module_org.label, lce=ENVIRONMENT) assert result.status == 0 + + +@pytest.mark.no_containers +def test_positive_rex_interface_for_global_registration( + module_target_sat, + module_org, + module_location, + rhel8_contenthost, + module_ak_with_synced_repo, +): + """Test remote execution interface is set for global registration + + :id: 982de593-dd1a-4c6c-81fe-728f40a7ad4d + + :steps: + 1. Register host with global registration template to Satellite specifying remote execution interface parameter. + + :expectedresults: remote execution interface passed in the registration command is properly set for the host. + + :BZ: 1841048 + + :customerscenario: true + """ + mac_address = gen_mac(multicast=False) + ip = gen_ipaddr() + # Create eth1 interface on the host + add_interface_command = f'ip link add eth1 type dummy;ifconfig eth1 hw ether {mac_address};ip addr add {ip}/24 brd + dev eth1 label eth1:1;ip link set dev eth1 up' + result = rhel8_contenthost.execute(add_interface_command) + assert result.status == 0 + command = module_target_sat.api.RegistrationCommand( + organization=module_org, + location=module_location, + activation_keys=[module_ak_with_synced_repo.name], + update_packages=True, + remote_execution_interface='eth1', + ).create() + result = rhel8_contenthost.execute(command) + assert result.status == 0, f'Failed to register host: {result.stderr}' + host = module_target_sat.api.Host().search( + query={'search': f'name={rhel8_contenthost.hostname}'} + )[0] + # Check if eth1 interface is set for remote execution + for interface in host.read_json()['interfaces']: + if 'eth1' in str(interface): + assert interface['execution'] is True + assert interface['ip'] == ip + assert interface['mac'] == mac_address