From 408ab618c66195391e6f157e1f3504b80ed2a66b Mon Sep 17 00:00:00 2001 From: Shubham Ganar Date: Fri, 27 Oct 2023 19:04:24 +0530 Subject: [PATCH] Closed loop BZ#2243679 Signed-off-by: Shubham Ganar --- .../foreman/api/test_provisioningtemplate.py | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/foreman/api/test_provisioningtemplate.py b/tests/foreman/api/test_provisioningtemplate.py index ac0567181c5..d6667c854e7 100644 --- a/tests/foreman/api/test_provisioningtemplate.py +++ b/tests/foreman/api/test_provisioningtemplate.py @@ -561,3 +561,70 @@ def test_positive_template_check_aap_snippet( assert 'systemctl enable ansible-callback' in render assert f'"host_config_key":"{config_key}"' in render assert '{"package_install": "zsh"}' in render + + @pytest.mark.parametrize('module_sync_kickstart_content', [7, 8, 9], indirect=True) + def test_positive_template_check_remote_execution_snippet( + self, + module_sync_kickstart_content, + module_target_sat, + module_provisioning_capsule, + module_sca_manifest_org, + module_location, + module_default_org_view, + module_lce_library, + default_architecture, + default_partitiontable, + ): + """Read the remote_execution_ssh_keys snippet and verify the home directory permissions are properly set. + + :id: e5212c46-d269-4bce-8e03-9d00c086e69e + + :expectedresults: The rendered remote_execution_ssh_keys snippet contains correct home directory permissions. + + :BZ: 2243679 + + :customerscenario: true + + :parametrized: yes + """ + macaddress = gen_mac(multicast=False) + remote_execution_user = gen_string('alpha') + host = module_target_sat.api.Host( + organization=module_sca_manifest_org, + location=module_location, + name=gen_string('alpha').lower(), + mac=macaddress, + operatingsystem=module_sync_kickstart_content.os, + architecture=default_architecture, + domain=module_sync_kickstart_content.domain, + root_pass=settings.provisioning.host_root_password, + ptable=default_partitiontable, + content_facet_attributes={ + 'content_source_id': module_provisioning_capsule.id, + 'content_view_id': module_default_org_view.id, + 'lifecycle_environment_id': module_lce_library.id, + }, + host_parameters_attributes=[ + { + 'name': 'remote_execution_ssh_user', + 'value': f'{remote_execution_user}', + 'parameter_type': 'string', + }, + { + 'name': 'remote_execution_create_user', + 'value': 'true', + 'parameter_type': 'boolean', + }, + ], + ).create() + remote_execution_snippet = host.read_template(data={'template_kind': 'provision'})[ + 'template' + ] + assert ( + f'chown -R {remote_execution_user}: ~{remote_execution_user}' + in remote_execution_snippet + ) + assert ( + f'chown -R {remote_execution_user}: ~{remote_execution_user}/.ssh' + in remote_execution_snippet + )